Closed mteinum closed 4 years ago
Hi @mteinum
Unfortunately this is a bug in NServiceBus itself. The Saga data does not include the CorrelationId of the original message so it applies the message ID instead.
What persistence do you use? With SQL persistence you might be able to work around this scenario using the metadata. With other persistences your would actually need to store the initial CorrelationId in the SagaData itself. I can help you craft the pipeline behaviors necessary to accomplish this.
Hi @SzymonPobiega,
I came across this issue the other day and resorted to using pub/sub instead, but I would be grateful if you could post how to get around this issue by storing the correlationid in SagaData and the subsequent alteration of the reply to enable this to work.
@Evad-s
Here's the workaround:
AttachCorrelationIdBehavior
that has a State
inner class. The only thing the new behavior would do is try to get its state from the context and, if that state is present, override the correlation ID header with the value from the stateRegisterStep
class as in https://docs.particular.net/nservicebus/pipeline/manipulate-with-behaviors#skip-serialization and enforce (in the RegisterStep
ctor) that the new behavior is placed after AttachCorrelationIdBehavior
(so that it overrides the default correlation ID)ReplyToOriginator
method but uses your new behavior's state object instead of AttachCorrelationIdBehavior
's state and sets the stored original message correlation ID there.Hope it helps.
Hi!
The router is working fine when the message is processed by a handler. IHandleMessages/context.Reply and correlationId is not changed.
But, when the message is processed by a Saga, ReplyToOriginator will set the correlationid to the originating messageid.
Line 110:
https://github.com/Particular/NServiceBus/blob/65fee422bdd79a3e5d4adc3dcc40353cb5b9dd82/src/NServiceBus.Core/Sagas/Saga.cs
and line 11:
https://github.com/Particular/NServiceBus/blob/65fee422bdd79a3e5d4adc3dcc40353cb5b9dd82/src/NServiceBus.Core/Correlation/AttachCorrelationIdBehavior.cs
Any plans on supporting this scenario?
Adding TLV to the outgoing MessageId might solve this issue together with the CorrelationId.