Nathan A
Nathan A

Reputation: 11319

Using Sagas with Recoverabilty

We are having an issue with recovery for messages originating from Sagas.

When a Saga sends a message for processing, the message handler can sometimes fail with an exception. We currently use a try/catch and when an exception is thrown, we "Reply" with a failed message to the Saga. The issue with this approach is that Recoverability retries don't happen since we are handling the error in the message handler.

My thought was to add custom logic to the pipeline and if the Command message implements some special Interface, the custom logic would send a failed message response to the Saga if an exception occurs (after the retries fails), but I'm not sure where to plug into the pipeline that would allow me to send messages after retries fails.

Is this a valid approach? If not, how can I solve for Saga to Handler failure messages after retries?

Upvotes: 0

Views: 131

Answers (1)

Dennis van der Stelt
Dennis van der Stelt

Reputation: 2178

You can use immediate dispatch to not wait for a handler to complete.

However, I would like to suggest an alternate approach. Why not create a Timeout in the saga? If the reply from the processing-handler isn't received within a certain TimeSpan, you take an alternate path. The processing-handler gets 5 minutes and if it doesn't respond within 5 minutes, we do something else. If it still responds after 6 minutes, we know we've already taken the alternate path (use a boolean flag or so and store that inside the saga data) and put aside the reply that arrived too late.

If you want to start a discussion based on this, check our community platform.

Upvotes: 0

Related Questions