I'm new to saga.
Here a simple scenario :
- User click "Create Order" : an order is created (holding its state = NEW at first)
- Once the user has finished filling the order, click SAVE --> state is now SUBMITTED
- When another check the order and VALIDATE it, then a process must occur. The order is VALIDATED only if some others services are called and give their GO.
The whole workflow is :
NEW
->SUBMITTED
.- From
SUBMITTED
the user can cancel is submission and the order switch back toNEW
. - The validation can either set the Order status to
VALIDATED
orREJECTED
. - If
REJECTED
the orginal user must fix his order before put it to VALIDATION again.
So I need to avoid that the order can rollback to NEW
when a VALIDATION
is in progress.
My question is, for step 3, is it better to :
- update the state of the order to PENDING, raise an event and start a saga (with its own state and the orchestration of the process and the routine slip) ?
- remove the state from the order aggregate and put it into the saga (so the saga starts at step 1) ? the saga is named OrderSaga and encapsulates all the process from start to finish and not only the parts where external services are needed, i.e distributed transaction).
- something else ? (links to blog or google group mail appreciated)
thanks