Workflow state in Saga or AR


I was wondering what's considered best practice in CQRS/Axon:

Suppose you have an AR with a related saga. The saga handles events
and generates new commands/events. Where should we put the variable
containing the workflow state (OrderState.NEW/PROCESSED/SENT etc)? in
the AR or in the Saga?

If it's kept in the Saga, the query service would have to deserialize
a lot of sagas to be able to extract let's say all not SENT orders.

If kept in the AR, the Saga would have to look up the AR to read or
change the OrderState.

Any thoughts?


Hi Geir,

you should keep the state in all places where you need it. So if the Saga needs it to decide which commands to send out, store it there. If the AR needs it to decide which Events to send, store it there. If a … query … there… ;-). That’s the power of uqituitous events. If that state changes, you emit an event that updates all these locations.

Hope that makes sense.