private void _setReplyTo(IEndpoint commandEndpoint, IIntegrationCommand command, MessageMetaData commandMeta) { if (commandMeta == null) { throw new InvalidOperationException("Command cannot be sent. Unable to set replyTo on null MessageMetaData"); } if (!String.IsNullOrEmpty(commandMeta.ReplyTo)) { return; } if (!String.IsNullOrEmpty(commandMeta.ReplyToEndpointName)) { var replyToEndpoint = MessagingMap.FindEndpointByName(commandMeta.ReplyToEndpointName); replyToEndpoint.SetReplyToForCommand(command, commandMeta); return; } else if (MessagingMap.DefaultReplyToEndpoint != null) { MessagingMap.DefaultReplyToEndpoint.SetReplyToForCommand(command, commandMeta); return; } throw new InvalidOperationException("Command cannot be sent because replyTo endpoint could not be determined"); }
/// <summary> /// Send a serialized message to an endpoint bypassing the outbound pipeline /// useful for services relay messages like the outbox /// </summary> /// <param name="messageTypeIdentifier"></param> /// <param name="message"></param> /// <param name="metaData"></param> /// <param name="endpointName"></param> /// <returns></returns> public Task DispatchCore(string messageTypeIdentifier, byte[] message, MessageMetaData metaData, string endpointName, bool isTransient = false) { var endpoint = endpointName != null?MessagingMap.FindEndpointByName(endpointName) : MessagingMap.FindEndpoint(messageTypeIdentifier); if (endpoint == null) { throw new ApplicationException($"Unable to dispatch message. Endpoint not found. MessageTypeIdentifier: {messageTypeIdentifier}. Endpoint: {endpointName}"); } if (isTransient && metaData != null) { if (metaData.SkipTransientDispatch) { throw new ApplicationException($"Unable to dispatch transient message. SkipTransient was set to True. MessageTypeIdentifier: {messageTypeIdentifier}. Endpoint: {endpointName}"); } if (metaData.DispatchDelay.HasValue && !endpoint.SupportsDelayedDispatch) { throw new ApplicationException($"Unable to dispatch transient message. Delay not supported by transport. MessageTypeIdentifier: {messageTypeIdentifier}. Endpoint: {endpointName}"); } } return(DispatchCore(messageTypeIdentifier, message, metaData, endpoint)); }