public MessageDeserializationRejectionHandler(RabbitMQConnectionPool connectionPool, string exchangeName = "",
     string rejectionRoutingKey = "RejectedMessages", ISerializer serializer = null)
 {
     _rabbitMQClient = new RabbitMQClient(connectionPool, serializer);
     _exchangeName = exchangeName;
     _rejectionRoutingKey = rejectionRoutingKey;
     _serializer = serializer ?? new JsonSerializer();
 }
        public RabbitMQConsumer(RabbitMQConnectionPool connectionPool, string queueName,
                                IMessageProcessingWorker <T> messageProcessingWorker, ISerializer serializer = null, IErrorLogger errorLogger = null,
                                IConsumerCountManager consumerCountManager = null, IMessageRejectionHandler messageRejectionHandler           = null)
        {
            _connectionPool          = connectionPool;
            _queueName               = queueName;
            _serializer              = serializer ?? new JsonSerializer();
            _errorLogger             = errorLogger;
            _messageProcessingWorker = messageProcessingWorker;
            _consumerCountManager    = consumerCountManager ?? new ConsumerCountManager();
            _messageRejectionHandler = messageRejectionHandler ?? new MessageDeserializationRejectionHandler(connectionPool);

            _consumerWorkersCount    = 0;
            _cancellationTokenSource = new CancellationTokenSource();
        }
Пример #3
0
        public RabbitMQClient(string hostName, int port, string userName, string password, string virtualHost,
                              ISerializer serializer = null, IErrorLogger errorLogger = null)
        {
            var connectionFactory = new ConnectionFactory
            {
                HostName    = hostName,
                Port        = port,
                UserName    = userName,
                Password    = password,
                VirtualHost = virtualHost
            };

            _connectionPool = new RabbitMQConnectionPool(connectionFactory);
            _serializer     = serializer ?? new JsonSerializer();
            _errorLogger    = errorLogger;
        }
Пример #4
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="connectionString">Format {user}:{password}@{host}:{port}/{virtualHost}</param>
        /// <param name="serializer"></param>
        /// <param name="errorLogger"></param>
        public RabbitMQClient(string connectionString, ISerializer serializer = null, IErrorLogger errorLogger = null)
        {
            var match = _connectionStringPattern.Match(connectionString);

            if (!match.Success)
            {
                throw new ArgumentException("Expected format: {user}:{password}@{host}:{port}/{virtualHost}", nameof(connectionString));
            }

            var connectionFactory = new ConnectionFactory
            {
                HostName    = match.Groups["host"].Value,
                Port        = int.Parse(match.Groups["port"].Value),
                UserName    = match.Groups["user"].Value,
                Password    = match.Groups["password"].Value,
                VirtualHost = match.Groups["vhost"].Value,
            };

            _connectionPool = new RabbitMQConnectionPool(connectionFactory);
            _serializer     = serializer ?? new JsonSerializer();
            _errorLogger    = errorLogger;
        }
Пример #5
0
 public RabbitMQClient(RabbitMQConnectionPool connectionPool, ISerializer serializer = null, IErrorLogger errorLogger = null)
 {
     _connectionPool = connectionPool;
     _serializer     = serializer ?? new JsonSerializer();
     _errorLogger    = errorLogger;
 }
Пример #6
0
 public RabbitMQClient(ConnectionFactory connectionFactory, ISerializer serializer = null, IErrorLogger errorLogger = null)
 {
     _connectionPool = new RabbitMQConnectionPool(connectionFactory);
     _serializer     = serializer ?? new JsonSerializer();
     _errorLogger    = errorLogger;
 }