public EventBusRabbitMQ(IRabbitMQPersisterConnection persisterConnection, ILogger <EventBusRabbitMQ> logger) { _persisterConnection = persisterConnection ?? throw new ArgumentNullException(nameof(persisterConnection)); _logger = logger ?? throw new ArgumentNullException(nameof(logger)); _consumerChannel = CreateConsumerChannel(); }
public EventBusRabbitMQ(IRabbitMQPersisterConnection persistentConnection, ILogger logger, ILifetimeScope autofac, ISubscriptionsManager subsManager, string queueName = null, int retryCount = 5) { _persistentConnection = persistentConnection ?? throw new ArgumentNullException(nameof(persistentConnection)); _logger = logger ?? throw new ArgumentNullException(nameof(logger)); _autofac = autofac; _subsManager = subsManager ?? new InMemoryEventSubscriptionManager(); _retryCount = retryCount; _subsManager.OnEventRemoved += _subsManager_OnEventRemoved; _queueName = queueName; _consumerChannel = CreateConsumerChannel(); }
/// <summary> /// 初始化事件总线RabbitMQ实现 /// </summary> /// <param name="persisterConnection">RabbitMQ连接管理</param> /// <param name="logger">日志</param> /// <param name="lifetimeScope">Autofac范围</param> /// <param name="subscriptionsManager">事件总线订阅管理器</param> /// <param name="queueName">队列名称</param> /// <param name="retryCount">重试次数</param> public EventBusRabbitMQ(IRabbitMQPersisterConnection persisterConnection, ILogger <EventBusRabbitMQ> logger, ILifetimeScope lifetimeScope, IEventBusSubscriptionsManager subscriptionsManager, string queueName = null, int retryCount = 5) { this.persisterConnection = persisterConnection; this.logger = logger; this.subscriptionsManager = subscriptionsManager; this.lifetimeScope = lifetimeScope; this.queueName = queueName; this.retryCount = retryCount; this.consumerChannel = this.CreateConsumerChannel(); this.subscriptionsManager.OnEventRemoved += new EventHandler <string>(this.SubscriptionsManager_OnEventRemoved); }
public EventBusRabbitMQ( IServiceProvider serviceProvider, string queueName, int retryCount = 5) { _persister = serviceProvider.GetRequiredService <IRabbitMQPersisterConnection>() ?? throw new ArgumentNullException(nameof(_persister)); _logger = serviceProvider.GetRequiredService <ILogger <EventBusRabbitMQ> >() ?? throw new ArgumentNullException(nameof(_logger)); _subscriptionManager = serviceProvider.GetRequiredService <IEventBusSubscriptionManager>() ?? new InMemoryEventBusSubscriptionsManager(); _serviceProvider = serviceProvider; _queueName = queueName; _retryCount = retryCount; _consumerChannel = CreateConsumerChannel(_queueName); _subscriptionManager.OnEventRemoved += SubsManager_OnEventRemoved; }