private static void CreateReplyContextFromHeaders(MessageBrokerContext messageContext, InboundBrokeredMessage inboundMessage) { if (inboundMessage.ApplicationProperties.TryGetValue(ApplicationProperties.ReplyToAddress, out var replyTo)) { inboundMessage.ApplicationProperties.TryGetValue(ApplicationProperties.ReplyToGroupId, out var replyToSessionId); inboundMessage.ApplicationProperties.TryGetValue(ApplicationProperties.GroupId, out var groupId); replyToSessionId = !string.IsNullOrWhiteSpace((string)replyToSessionId) ? (string)replyToSessionId : (string)groupId; var replyContext = new ReplyToRoutingContext((string)replyTo, (string)replyToSessionId, messageContext.Container); messageContext.Container.Include(replyContext); inboundMessage.ClearReplyToProperties(); } }
public ReplyToRoutingExceptions(ReplyToRoutingContext replyToContext, Exception causeOfRoutingFailure) : base(replyToContext, causeOfRoutingFailure, "Routing 'reply to' message failed.") { _replyToContext = replyToContext ?? throw new ArgumentNullException(nameof(replyToContext), "A 'reply to' context is required."); }
public Task Route(InboundBrokeredMessage inboundBrokeredMessage, TransactionContext transactionContext, ReplyToRoutingContext destinationRouterContext) { if (destinationRouterContext is null) { //TODO: log return(Task.CompletedTask); } try { var outbound = new OutboundBrokeredMessage(_messageIdGenerator?.GenerateId(inboundBrokeredMessage.Body).ToString(), inboundBrokeredMessage.Body, (IDictionary <string, object>)inboundBrokeredMessage.MessageContext, destinationRouterContext?.DestinationPath, inboundBrokeredMessage.BodyConverter); outbound.MessageContext[MessageContext.ReplyToGroupId] = destinationRouterContext.ReplyToGroupId; return(_router.Route(outbound, transactionContext)); } catch (Exception e) { throw new ReplyToRoutingExceptions(destinationRouterContext, e); } }
public Task Route(InboundBrokeredMessage inboundBrokeredMessage, TransactionContext transactionContext, ReplyToRoutingContext destinationRouterContext) { if (destinationRouterContext is null) { //TODO: log return(Task.CompletedTask); } try { var outbound = OutboundBrokeredMessage.Forward(inboundBrokeredMessage, destinationRouterContext?.DestinationPath); outbound.ApplicationProperties[ApplicationProperties.ReplyToGroupId] = destinationRouterContext.ReplyToGroupId; return(_router.Route(outbound, transactionContext)); } catch (Exception e) { throw new ReplyToRoutingExceptions(destinationRouterContext, e); } }