Пример #1
0
        public RabbitMQEventBusEngine(IOptions <RabbitMQEngineOptions> options, ILoggerFactory loggerFactory, IRabbitMQConnectionManager connectionManager, IRedisDatabase redis)
        {
            _logger            = loggerFactory.CreateLogger <RabbitMQEventBusEngine>();
            _options           = options.Value;
            _connectionManager = connectionManager;
            _redis             = redis;

            //publish
            ILogger publishTaskManagerLogger = loggerFactory.CreateLogger <PublishTaskManager>();

            foreach (RabbitMQConnectionSetting connectionSetting in _options.ConnectionSettings)
            {
                _publishManagers.Add(connectionSetting.BrokerName, new PublishTaskManager(connectionSetting, _connectionManager, _redis, publishTaskManagerLogger));
            }

            //publish history
            ILogger historyTaskManagerLogger = loggerFactory.CreateLogger <HistoryTaskManager>();

            foreach (RabbitMQConnectionSetting connectionSetting in _options.ConnectionSettings)
            {
                _historyManager.Add(connectionSetting.BrokerName, new HistoryTaskManager(connectionSetting, _connectionManager, _redis, historyTaskManagerLogger));
            }

            //Consume
            _consumeTaskManagerLogger = loggerFactory.CreateLogger <ConsumeTaskManager>();
        }
Пример #2
0
 public EventBusRabbitMQ(IEventbusSubscriptionManager eventbusSubscriptionManager, IRabbitMQConnectionManager connectionManager, IConfiguration configuration, IServiceProvider serviceProvider)
 {
     queueName              = configuration["QueueName"];
     subscriptionManager    = eventbusSubscriptionManager;
     this.connectionManager = connectionManager;
     this.serviceProvider   = serviceProvider;
     consumerChannel        = CreateConsumerChannel();
     eventbusSubscriptionManager.OnEventRemoved += EventbusSubscriptionManager_OnEventRemoved;
 }
Пример #3
0
        public ConsumeTaskManager(string eventType, IEventHandler eventHandler, RabbitMQConnectionSetting connectionSetting, IRabbitMQConnectionManager connectionManager, IRedisDatabase redis, ILogger logger)
        {
            _redis             = redis;
            _eventType         = eventType.ThrowIfNull(nameof(eventType));
            _handler           = eventHandler.ThrowIfNull(nameof(eventHandler));
            _logger            = logger.ThrowIfNull(nameof(logger));
            _connectionManager = connectionManager.ThrowIfNull(nameof(connectionManager));
            _connectionSetting = connectionSetting.ThrowIfNull(nameof(connectionSetting));

            Restart();
        }
Пример #4
0
        protected RabbitMQAndDistributedQueueDynamicTaskManager(RabbitMQConnectionSetting connectionSetting, IRabbitMQConnectionManager connectionManager, IRedisDatabase redis, ILogger logger)
        {
            _logger            = logger;
            _connectionManager = connectionManager;
            _redis             = redis;
            _connectionSetting = connectionSetting;

            int taskCount = EstimatedTaskNumber;

            AddTaskAndStart(taskCount > MaxWorkerThread() ? MaxWorkerThread() : taskCount);
        }
Пример #5
0
        public RabbitMQEventBus(IRabbitMQConnectionManager rabbitMQConnectionManager, ILogger <RabbitMQEventBus> logger,
                                IServiceProvider serviceProvider, IEventBusSubscriptionsManager subsManager, RabbitMQOptions rabbitMQOptions)
        {
            _rabbitMQConnectionManager = rabbitMQConnectionManager ?? throw new ArgumentNullException(nameof(rabbitMQConnectionManager));
            _logger                      = logger ?? throw new ArgumentNullException(nameof(logger));
            _subsManager                 = subsManager ?? new InMemoryEventBusSubscriptionsManager();
            _serviceProvider             = serviceProvider;
            _retryCount                  = rabbitMQOptions.RetryCount;
            _subsManager.OnEventRemoved += SubsManager_OnEventRemoved;

            _consumerChannels = new Dictionary <string, IModel>();
        }
Пример #6
0
 public HistoryTaskManager(RabbitMQConnectionSetting connectionSetting, IRabbitMQConnectionManager connectionManager, IRedisDatabase redis, ILogger logger)
     : base(connectionSetting, connectionManager, redis, logger)
 {
 }