Пример #1
0
        private void OnMessageReceived(object sender, MessageEventArgs e)
        {
            var message = e.MessageBody;

            if (message is AddSubscriberMessage)
            {
                var subscriber = ((AddSubscriberMessage)message).SubscriberQueue;
                _logger.Info($"Adding the subscriber: {subscriber}");
                _commandSender.AddSubscriber(subscriber);
                return;
            }

            var handler = _messageHandlers.FirstOrDefault(x => x.CanHandle(message));

            if (handler == null)
            {
                _logger.Warn($"Unable to process the message of the type {message.GetType()}");
                return;
            }

            handler.Handle(message);
        }