Raju Donthula
Raju Donthula

Reputation: 97

Can a saga has multiple timeout handlers

We have implemented a saga that has a timeout method and worked as expected. Later we wanted to add one more timeout method. So, I have added it to the same saga but the second timeout is not getting called. These two messages will be called at a time. Can we have two IHandlerTimeouts in a single saga?

 public class SagaPolicy1 : Saga<SagaPolicyData>,
        IAmStartedByMessages<OrderPlacedCommand>,
        IHandleTimeouts<TimoutMsg1>,//timespan 20min
        IHandleTimeouts<TimoutMsg2>

await RequestTimeout<TimoutMsg1>(context, TimeSpan.FromSeconds(1200));
await RequestTimeout<TimoutMsg2>(context, TimeSpan.FromSeconds(360));

Upvotes: 0

Views: 85

Answers (1)

Sean Feldman
Sean Feldman

Reputation: 25994

The short answer is yes. The documentation explicitly calls it out. Remember that a timeout can be queued after its saga has been completed (using MarkAsComplete()). Because a timeout is tied to a specific saga instance, it will be ignored once the saga instance is completed.

Upvotes: 1

Related Questions