Orchestration-Based Saga
Coordinate a saga using a central orchestrator that tells each participant what to do.
Intent & Description
⚠️ Problem
How to coordinate saga participants with a central controller?
📋 Context
You have applied the Saga pattern to implement distributed transactions across multiple services. You need to decide how to coordinate the saga participants.
💡 Solution
Use a saga orchestrator that is responsible for telling each participant what local transaction to execute. The orchestrator sends command messages to each participant and waits for reply messages indicating the outcome. Based on the outcome, the orchestrator decides the next step: proceed with the next transaction or initiate compensating transactions. For example, an OrderSagaOrchestrator sends a ReserveCredit command to the Customer Service. If it receives a CreditReserved reply, it sends an ApproveOrder command to the Order Service. If it receives a CreditLimitExceeded reply, it sends a RejectOrder command. The orchestrator models the saga as a state machine, making the coordination logic explicit and centralized.
Real-world Use Case
Source
Advantages
- Centralized saga logic is easier to understand and maintain
- Avoids cyclic dependencies between services
- Separation of concerns—saga logic is separate from business logic
- Easier to implement complex workflows with conditional branching
- Participants don’t need to know about each other’s events
Disadvantages
- Risk of centralizing too much business logic in the orchestrator
- Orchestrator can become a single point of failure if not designed for high availability
- Additional infrastructure complexity to deploy and manage the orchestrator
- Orchestrator must be carefully designed to handle failures and retries