public RabbitConsumer(string queueName,
                              RabbitMQOptions options,
                              IConnectionChannelPool connectionChannelPool,
                              ILoggerFactory loggerFactory)
        {
            _queueName             = queueName;
            _options               = options;
            _connectionChannelPool = connectionChannelPool;

            _connection = new Lazy <IConnection>(() =>
            {
                return(_connectionChannelPool.Connection());
            });

            _channel = new Lazy <IModel>(() =>
            {
                var channel = _connection.Value.CreateModel();
                channel.ExchangeDeclare(_options.ExchangeName, _options.ExchangeType, true);

                var arguments = new Dictionary <string, object>
                {
                    { "x-message-ttl", _options.MessageExpriesInMill }
                };
                channel.QueueDeclare(_queueName, true, false, false, arguments);
                return(channel);
            });
        }
Exemple #2
0
 public RabbitMQMessagePublisher(RabbitMQOptions options,
                                 IConnectionChannelPool connectionChannelPool,
                                 ILoggerFactory loggerFactory)
 {
     _options = options;
     _connectionChannelPool = connectionChannelPool;
 }
Exemple #3
0
 public RabbitMQConsumerFactory(RabbitMQOptions options,
                                IConnectionChannelPool connectionChannelPool,
                                ILoggerFactory loggerFactory)
 {
     _options = options;
     _connectionChannelPool = connectionChannelPool;
     _loggerFactory         = loggerFactory;
 }