Exemple #1
0
 private void InitializeEventHandlers()
 {
     agentEventHandler    = new AgentEventHandler(logger, this, tenantIOService);
     tenantEventHandler   = new TenantEventHandler(logger, this, tenantIOService);
     producerEventHandler = new ProducerEventHandler(logger, this, producerIOService);
     consumerEventHandler = new ConsumerEventHandler(logger, this, consumerIOService, messageIOService);
     messageEventHandler  = new MessageEventHandler(logger, this, messageIOService);
 }
Exemple #2
0
        public void StartConsuming(ConsumerEventHandler messageReceived, string queueName, string forwardQueue)
        {
            _consumerEventHandler = messageReceived;
            _queueName            = queueName;
            _forwardQueue         = forwardQueue;

            CreateConsumer();
        }
 public void AddConsumer(string queueName, IList<string> messageTypes, ConsumerEventHandler eventHandler, IConfiguration config)
 {
     new Thread(() =>
     {
         var consumer = config.GetConsumer();
         consumer.StartConsuming(eventHandler, queueName);
         foreach (string messageType in messageTypes)
         {
             consumer.ConsumeMessageType(messageType);
         }
         _consumers.Add(consumer);
     }).Start();
 }
 public void AddConsumer(string queueName, IList <string> messageTypes, ConsumerEventHandler eventHandler, IConfiguration config)
 {
     new Thread(() =>
     {
         var consumer = config.GetConsumer();
         consumer.StartConsuming(eventHandler, queueName);
         foreach (string messageType in messageTypes)
         {
             consumer.ConsumeMessageType(messageType);
         }
         _consumers.Add(consumer);
     }).Start();
 }
Exemple #5
0
        public void StartConsuming(ConsumerEventHandler messageReceived, string queueName, string forwardQueue)
        {
            // Ensure connection open
            _connection.Connect();

            // Create threads & start them consuming
            _pool = new ConcurrentBag <Consumer>();

            for (var i = 0; i < Environment.ProcessorCount * 2; i++)
            {
                new Thread(() =>
                {
                    var threadConsumer = new Consumer(_connection);
                    threadConsumer.StartConsuming(messageReceived, queueName, forwardQueue);

                    _pool.Add(threadConsumer);
                }).Start();
            }
        }
 public bool AssignEventHandler(ConsumerEventHandler eventHandler)
 {
     _fakeEventHandler = eventHandler;
     return true;
 }
 public void StartConsuming(string queueName, IList <string> messageTypes, ConsumerEventHandler eventHandler, IConfiguration config)
 {
     throw new NotImplementedException();
 }
 public bool AssignEventHandler(ConsumerEventHandler eventHandler)
 {
     _fakeEventHandler = eventHandler;
     return(true);
 }
 public void StartConsuming(ConsumerEventHandler messageReceived, string queueName, bool?exclusive = null,
                            bool?autoDelete = null)
 {
 }
 public void StartConsuming(ConsumerEventHandler messageReceived, string routingKey, string queueName = null, bool?exclusive = null, bool?autoDelete = null)
 {
     throw new NotImplementedException();
 }
Exemple #11
0
 public void StartConsuming(string queueName, IList <string> messageTypes, ConsumerEventHandler eventHandler, IConfiguration config)
 {
 }
Exemple #12
0
        public void StartConsuming(string queueName, IList <string> messageTypes, ConsumerEventHandler eventHandler, IConfiguration config)
        {
            _transportSettings = config.TransportSettings;
            _durable           = !_transportSettings.ClientSettings.ContainsKey("Durable") || (bool)_transportSettings.ClientSettings["Durable"];
            _exclusive         = _transportSettings.ClientSettings.ContainsKey("Exclusive") && (bool)_transportSettings.ClientSettings["Exclusive"];
            _autoDelete        = _transportSettings.ClientSettings.ContainsKey("AutoDelete") && (bool)_transportSettings.ClientSettings["AutoDelete"];
            _queueArguments    = _transportSettings.ClientSettings.ContainsKey("Arguments") ? (IDictionary <string, object>)_transportSettings.ClientSettings["Arguments"] : new Dictionary <string, object>();
            _retryDelay        = _transportSettings.RetryDelay;

            if (_connection == null)
            {
                _connection = new Connection(config.TransportSettings, queueName, _logger);
            }

            if (_model == null)
            {
                _model = _connection.CreateModel();
            }

            // Configure exchanges
            foreach (string messageType in messageTypes)
            {
                ConfigureExchange(messageType, "fanout");
            }

            // Configure queue
            ConfigureQueue(queueName);

            // Purge all messages on queue
            if (_transportSettings.PurgeQueueOnStartup)
            {
                _logger.Debug("Purging queue");
                _model.QueuePurge(queueName);
            }

            // Configure retry queue
            ConfigureRetryQueue(queueName);

            // Configure Error Queue/Exchange
            var errorExchange = ConfigureErrorExchange();
            var errorQueue    = ConfigureErrorQueue();

            if (!string.IsNullOrEmpty(errorExchange))
            {
                _model.QueueBind(errorQueue, errorExchange, string.Empty, null);
            }

            // Configure Audit Queue/Exchange
            if (_transportSettings.AuditingEnabled)
            {
                var auditExchange = ConfigureAuditExchange();
                var auditQueue    = ConfigureAuditQueue();

                if (!string.IsNullOrEmpty(auditExchange))
                {
                    _model.QueueBind(auditQueue, auditExchange, string.Empty, null);
                }
            }

            var clientCount = config.Clients;

            for (int i = 0; i < clientCount; i++)
            {
                var client = new Client(_connection, config.TransportSettings, _logger);
                client.StartConsuming(eventHandler, queueName);
                foreach (string messageType in messageTypes)
                {
                    client.ConsumeMessageType(messageType);
                }
                _clients.Add(client);
            }
        }