private static IntegrationMessageDispatcherHandler GetHandler(IIntegrationMessage message) { var genericDispatcherType = typeof(IntegrationMessageDispatcherHandler <>) .MakeGenericType(message.GetType()); return((IntegrationMessageDispatcherHandler) Activator.CreateInstance(genericDispatcherType)); }
public Task Handle(IIntegrationMessage message, MessageContext context) { var messageType = message.GetType(); if (_currentHandlers == null) { throw new InvalidMessageForStateException(null, messageType); } var handler = _currentHandlers.GetHandler(messageType); if (handler == null) { return(Unhandled(message, context)); } else { return(handler.Invoke(message, context)); } }
protected virtual Task Unhandled(IIntegrationMessage message, MessageContext context) { throw new InvalidMessageForStateException(_currentHandlers.StateName, message.GetType()); }
public Task Dispatch(IIntegrationMessage message, MessageMetaData metaData = null, IOutboxSession outbox = null) { var endpoint = MessagingMap.FindEndpoint(message) ?? throw new ApplicationException($"Unable to dispatch message. Type: {message.GetType()} Message Type: {message.MessageType}"); return(Dispatch(message, metaData, endpoint, outbox)); }
public K FindKey(IIntegrationMessage message, MessageMetaData meta) { return(_keyMappers[message.GetType()].Invoke(message, meta)); }