Example #1
0
        public static void AddEventBusRabbitMq(this IServiceCollection services,
                                               Action <EventBusRabbitMqOptions> configureOptions)
        {
            var options = new EventBusRabbitMqOptions();

            configureOptions(options);
            services.Configure(configureOptions);

            services.AddSingleton <IRabbitMqPersistentConnection, DefaultRabbitMqPersistentConnection>();
            services.AddEventBus <EventBusRabbitMq>();
        }
Example #2
0
        public EventBusRabbitMq(
            IServiceProvider services,
            IOptions <EventBusRabbitMqOptions> options,
            IRabbitMqPersistentConnection persistentConnection,
            ILogger <EventBusRabbitMq> logger,
            IEventBusSubscriptionsManager subsManager)
        {
            _logger               = logger;
            _services             = services;
            _persistentConnection =
                persistentConnection ?? throw new ArgumentNullException(nameof(persistentConnection));
            _subsManager = subsManager ?? new EventBusSubscriptionsManager();

            _options                     = options.Value;
            _exchangeType                = "direct";
            _consumerChannel             = CreateConsumerChannel();
            _subsManager.OnEventRemoved += SubsManager_OnEventRemoved;
        }