Because each service owns its own database, ShopNexus cannot use a single ACID transaction across services. The Saga pattern coordinates a business transaction as a sequence of local transactions, each with a compensating action to undo its effect on failure.

Styles

Each service reacts to events and emits the next event. No central coordinator.
  • Decentralized and loosely coupled.
  • Harder to follow the end-to-end flow as steps grow.

Compensation

When a step fails, previously completed steps are rolled back with compensating transactions (e.g. release reserved stock, refund a payment) rather than a database rollback.
Sagas provide eventual consistency, not isolation. Design steps to be idempotent and handle out-of-order or duplicate messages.