I’m getting some odd routing behaviour on sending additional messages in an outbound behaviour handler (specifically a Behavior<IOutgoingLogicalMessageContext>)
Let’s say I have services A, B and C.
All routes are set on the EndpointConfiguration object at service startup.
Service A is processing a Saga and needs to send a message to Service B
In Service A we register a Behavior<IOutgoingLogicalMessageContext> that contains some business logic, and will send an extra message to Service C using IOutgoingLogicalMessageContext.Send<IMessage>(m => …)
That works fine, the original message gets to B, the extra message gets to C.
If instead of sending from A to B though, we send a message from A back to itself using IMessageHandlerContext.SendLocal it doesn’t behave as we’d expect.
The same Behavior picks up the outgoing message, sends the extra message using the same logic and message type.
The original message gets to A, but the extra message is also delivered to A, not to C.
It looks like there’s some state in the IOutgoingLogicalMessageContext that causes it to ignore routing on all outgoing messages if the context was created by a call to SendLocal().
All this observed using NServiceBus 7.4.7 on NetCore5 in Azure docker images.