Esempio n. 1
0
        /// <summary>
        /// 启用第三方事件总线
        /// </summary>
        /// <param name="connectionName">连接字符串名称</param>
        public static void UseEventBus(this IEventBusConfiguration eventBusConfiguration, string connectionName)
        {
            if (eventBusConfiguration == null)
            {
                throw new ArgumentNullException("eventBusConfiguration");
            }
            if (string.IsNullOrEmpty(connectionName))
            {
                throw new ArgumentNullException("connectionName");
            }

            ConnectionName = connectionName;

            var eventBusExtensions = IocManager.Instance.Resolve <IEventBusExtensions>();

            //释放ABP自带的EventBus
            var releaseEventBus = IocManager.Instance.Resolve <IEventBus>();

            IocManager.Instance.Release(releaseEventBus);

            //加载第三方EventBus
            if (!IocManager.Instance.IsRegistered <IEventBus>())
            {
                IocManager.Instance.IocContainer.Register(
                    Component.For <IEventBus>().UsingFactoryMethod(() => eventBusExtensions)
                    );
            }
            eventBusExtensions.Start();
        }
Esempio n. 2
0
 public void Initialize()
 {
     Localization  = IocManager.Resolve <ILocalizationConfiguration>();
     Modules       = IocManager.Resolve <IModuleConfigurations>();
     Navigation    = IocManager.Resolve <INavigationConfiguration>();
     Authorization = IocManager.Resolve <IAuthorizationConfiguration>();
     Settings      = IocManager.Resolve <ISettingsConfiguration>();
     UnitOfWork    = IocManager.Resolve <IUnitOfWorkDefaultOptions>();
     EventBus      = IocManager.Resolve <IEventBusConfiguration>();
 }
Esempio n. 3
0
        public static IEventBusConfiguration RegisterEvents(this IEventBusConfiguration configuration, IMessageSender sender, Assembly assembly, Func <IQueryable <Type>, IQueryable <Type> > typeFilter = null)
        {
            // Get types.
            IQueryable <Type> types = assembly.GetTypes()
                                      .AsQueryable()
                                      .Where(t => typeof(IEvent).IsAssignableFrom(t));

            if (typeFilter != null)
            {
                types = typeFilter(types);
            }

            // Add types.
            configuration.RegisterEvents(sender, types.ToArray());

            // Done.
            return(configuration);
        }
        /// <summary>
        /// 启用第三方事件总线
        /// </summary>
        /// <param name="connectionName">连接字符串名称</param>
        public static void UseEventBus(this IEventBusConfiguration eventBusConfiguration, string connectionName = "Microsoft.ServiceBus.ConnectionString", int timeOut = 10, string queueName = "SinoQueue")
        {
            if (string.IsNullOrEmpty(connectionName))
            {
                throw new ArgumentNullException(nameof(connectionName));
            }

            BusHub = Bus.Factory.CreateUsingAzureServiceBus(cfg =>
            {
                var host = cfg.Host(CloudConfigurationManager.GetSetting(connectionName), h =>
                {
                    h.OperationTimeout = TimeSpan.FromSeconds(timeOut);
                    h.TransportType    = Microsoft.ServiceBus.Messaging.TransportType.NetMessaging;
                });
                cfg.ReceiveEndpoint(host, "SinoQueue", e =>
                {
                    e.UseMessageScope();
                    e.LoadFrom(Ioc.IocContainer);
                });
            });

            //释放ABP自带的EventBus
            var releaseEventBus = Ioc.Resolve <IEventBus>();

            Ioc.Release(releaseEventBus);

            Ioc.IocContainer.Register(Component.For <IBus>().Instance(BusHub).Named("BusRegister"));
            Ioc.IocContainer.Register(Component.For <IBusControl>().Instance(BusHub).Named("BusControlRegister"));

            var eventBusExtensions = Ioc.Resolve <IEventBusExtensions>();

            Ioc.IocContainer.Register(
                Component.For <IEventBus>().
                Instance(eventBusExtensions).
                IsDefault().
                Named("Sino.EventBus")
                );

            BusHub.Start();
        }
Esempio n. 5
0
        public RabbitMQEventBus(
            PersisterConnection connection,
            IEventBusConfiguration eventBusConfiguration,
            IQueueConfiguration queueConfiguration,
            IAckConfiguration ackConfiguration
            )
        {
            _connection = connection;

            _eventBusConfiguration = eventBusConfiguration;

            _queueConfiguration = queueConfiguration;

            _ackConfiguration = ackConfiguration;

            _subscriptionManager = new SubscriptionsManager();
            _subscriptionManager.OnEventRemoved += OnSubscriptionManagerEventRemoved;
            _subscriptionManager.OnEventAdded   += OnSubscriptionManagerEventAdded;

            _eventCancellationTokenPool = new EventCancellationTokenPool(_subscriptionManager);

            _onSetRunner = new OnSetRunner(true);
        }
Esempio n. 6
0
 public EventBusInstaller(IIocResolver iocResolver)
 {
     _iocResolver           = iocResolver;
     _eventBusConfiguration = iocResolver.Resolve <IEventBusConfiguration>();
 }
Esempio n. 7
0
 public EventBusInstaller(IIocResolver iocResolver)
 {
     _iocResolver = iocResolver;
     _eventBusConfiguration = iocResolver.Resolve<IEventBusConfiguration>();
 }
Esempio n. 8
0
        public static void Configure(IApplicationBuilder app, IHostingEnvironment env, IEventBusConfiguration bus)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }
            else
            {
                app.UseHsts();
            }

            app.UseHttpsRedirection();

            app.UseRouting();
            app.UseEndpoints(endpoints =>
            {
                endpoints.MapControllerRoute("default", "{controller=Home}/{action=Index}/{id?}");
            });

            bus.Configure();
        }
Esempio n. 9
0
 public EventBusProvider(IEventBusConfiguration configuration)
 {
     this.Configuration = configuration;
 }
Esempio n. 10
0
 public RabbitMQEventBusProvider(IEventBusConfiguration configuration) : base(configuration)
 {
 }
Esempio n. 11
0
 public EventBus(IEventBusConfiguration configuration = null)
 {
     _eventBusConfiguration = configuration ?? EventBusConfiguration.Default;
     _subscriptions         = new Dictionary <Type, List <ISubscription> >();
 }