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>();
        }
Beispiel #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;
        }