Course contentsShow
← Software Engineering
Lesson 1370 of 1,93340. Event-Driven ArchitectureFree lesson

Saga Execution Coordinators

Implementing saga execution logic through orchestrators or choreography-based coordination mechanisms.

Saga Execution Coordinators

You'll learn: How to implement saga execution logic through orchestrators or choreography-based coordination mechanisms.

Core Idea

When managing a saga (a sequence of distributed transactions with compensating actions), you need something to coordinate the flow. There are two main approaches: orchestration and choreography. Think of orchestration like a conductor directing an orchestra—one central coordinator tells each service what to do next. Choreography is more like a flash mob—each participant knows their part and reacts to what others do, without a central director.

Orchestration: Central Coordinator

An orchestrator is a dedicated service that manages the entire saga workflow. It explicitly invokes each step, tracks state, handles failures, and triggers compensating transactions when needed.

Example flow: The Order Orchestrator calls Payment → waits → calls Inventory → if Inventory fails → calls Payment Compensation.

Pros: Clear visibility, centralized logic, easier debugging
Cons: Single point of failure, orchestrator can become complex, tight coupling to the orchestrator

Choreography: Distributed Coordination

In choreography, services listen for events and publish new events in response. There's no central brain—the saga emerges from services reacting to each other's events.

Example flow: OrderCreated event → Payment Service processes and emits PaymentCompleted → Inventory Service reacts to PaymentCompleted and reserves stock → if reservation fails, emits ReservationFailed → Payment Service listens and compensates.

Pros: High decoupling, no single point of failure, scales naturally
Cons: Harder to understand overall flow, difficult debugging, implicit dependencies

Choosing Your Coordinator

Use orchestration when you need clear visibility and centralized control. Use choreography when you want maximum autonomy between services. Hybrid approaches also exist—orchestration for complex sagas, choreography for simple ones.

Key Takeaway: Saga execution coordinators implement either orchestration (central controller) or choreography (distributed event reactions) to manage multi-step distributed transactions and their compensations.