Skip to Content

Manage a multi-service “transaction” as a sequence of local transactions + compensating actions.

Data Flow (choreography)

OrderService -> emits OrderCreated
  PaymentService  -- listens -> charges card -- emits PaymentCompleted
  InventoryService -- listens -> reserves SKU -- emits InventoryReserved

if any step fails:
PaymentService    -> emits PaymentRefundNeeded
InventoryService  -> emits InventoryRelease
OrderService      -> marks order FAILED

Two styles

Pitfalls

When to use

Analogy

A road trip with many stops: each stop is one local task; if the last stop is closed, you reverse course to undo priors.

Interview tip: Always mention compensations are not free — design idempotency from day one.

Advertisement