Case 8
Sagas and Orchestration
Long-running flows span services. Sagas coordinate forward steps and compensating rollbacks.
A multistep checkout is not one database transaction — payment, inventory, shipping, and email span systems. Sagas make partial failure explicit instead of hoping for the best.
Step-by-step walkthrough
Forward saga — happy path
- ① Start checkout — Client kicks off a durable workflow with a correlation ID.
- ② Reserve stock — Orchestrator calls inventory service; hold ID returned and persisted in workflow history.
- ③ Capture payment — Payments service charges card; idempotent on retry with same key.
- ④ Create shipment — Shipping service creates label only after payment succeeds.
- ⑤ Order complete — Client notified; workflow marked succeeded in orchestrator history.
Compensation — payment failure
- FAILED — Stripe returns card_declined; orchestrator branches to compensate, not retry forever.
- ⑥ Compensate: release hold — Inventory hold released before error returned to client — no orphaned locks.
Why these technologies?
sagaorchestrationchoreographyTemporalcompensationKafka