public void Handle(ReceiveMessageContext context) { // todo get rid of reflection, cache it? IMessageEnvelop messageEnvelop; if (!context.TryGetMessageEnvelop(out messageEnvelop)) return; var handlers = _messageBrokerManager.GetHandlers(messageEnvelop.MessageType, context.MessageBrokerType); context.MessageHandlerContainers = new List<IMessageHandlerContainer>(); context.MessageHandlerContainers.AddRange(handlers); // todo don't continue the chain if we didn't find the handler }
public void Handle(ReceiveMessageContext context) { IMessageEnvelop messageEnvelop; if (!context.TryGetMessageEnvelop(out messageEnvelop)) return; var message = messageEnvelop.Message; foreach (var messageHandlerContainer in context.MessageHandlerContainers) { var handlerInstance = messageHandlerContainer.Instance; try { messageHandlerContainer.Invoke(handlerInstance, message); } catch (Exception exception) { //_logger.Error("Error handling message:"); //_logger.Error(exception); } } }