Search code examples
masstransitautomatonymous

Conditional transition in MassTransit Automatonymous saga


I have some state in the saga and trying to implement status check retries until I get some satisfactory value in a message I receved.

Say, I have something like this:

.During(Pending,
    When(StatusChecked)
        .TransitionTo(somethingThatDependsOnStatusCheckedData)

I can only feed a specific state to TransitionTo but I want it to transition depending on the received message content, is it possible?


Solution

  • For received message content, you can use the conditional expression on the When clause.

    During(Pending,
        When(StatusChecked, context => context.Data.IsMessageCondition)
            .Then(...));