Fix cascading message SagaId propagation with Separated mode #2060
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
When a saga handler returns a cascading message, the Sagaid wasn't being set on the MessageContext, so outbound messages had no SagaId attached. This caused IndeterminateSagaStateIdException when the cascaded message tried to correlate back to the saga.
Workaround 1
Explicitly set the Saga identity on the cascaded message by any of the supported ways documented here https://wolverinefx.net/guide/durability/sagas.html#saga-message-identity
Workaround 2
Publish directly using
IMessageContext.PublishAsyncand using DeliveryOptions { SagaId }Solution
The SagaId extracted from the incoming message wasn't being set on
MessageContext._sagaId, so when cascading messages were enqueued the outbound envelope had no SagaId.Changes:
SetSagaId(object sagaId)method toMessageContextto allow generated code to set the saga ID for correlationSetSagaIdFrame- generatescontext.SetSagaId(sagaId)for existing saga handler paths wheresagaIdvariable is availableSetSagaIdFromSagaFrame- generatescontext.SetSagaId(saga.Id)for Start method paths where only the saga object is available