Sagas
On This Lesson 4 topics
This lesson is planned. The outline below lists the topics it will cover. The full lesson has not been published yet.
In this lesson
model a process as local transactions plus compensations.
Planned topics
- A saga is a sequence of local transactions; each publishes the trigger for the next.
- If a step fails, earlier steps are undone by compensating transactions.
- Sagas give no isolation: others can see intermediate states (for example stock reserved but unpaid).
- Some steps cannot be undone (email sent); put those last or make them semantic ("send apology").
- Each step and compensation must be idempotent (MID-029).
Draft outline details
Demonstration
| Step | Local transaction | Compensation |
|---|---|---|
| 1 | Create order PENDING | Mark CANCELLED |
| 2 | Reserve stock | Release stock |
| 3 | Authorize payment | Void authorization |
| 4 | Confirm order | none (final) |
Check your understanding
Why is a saga not isolated like a database transaction?
Show answer
Intermediate states are committed and visible to others.
Practice
Apply this lesson with the module's lab, exercises and quiz.
Marking a lesson complete is optional and you can undo it any time. Your progress stays in this browser.