Choreography-Based Saga
Coordinate a saga by having each participant publish domain events that trigger the next participant.
Intent & Description
⚠️ Problem
How to coordinate saga participants without a central orchestrator?
📋 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
Implement each saga step as a service that publishes domain events that trigger the next step. Each participant listens for events, performs its local transaction, and publishes a new event. For example, in an order creation saga: the Order Service creates an order and publishes OrderCreated. The Customer Service listens for OrderCreated, reserves credit, and publishes CreditReserved. The Order Service listens for CreditReserved and approves the order. If any step fails, the participant publishes a failure event that triggers compensating transactions in the preceding participants.
Real-world Use Case
Source
Advantages
- Simple to implement for straightforward workflows with few participants
- No single point of failure from a central orchestrator
- Loosely coupled—each service only needs to know about the events it consumes and produces
- Good for simple, linear workflows
Disadvantages
- Difficult to understand and debug as the number of participants grows
- Risk of cyclic dependencies between services
- Hard to implement complex coordination logic or conditional branching
- Adding new steps requires modifications across multiple services