chapter ten
10 Saga coordination mechanisms
This chapter covers
- The two saga coordination styles - choreography and orchestration
- Designing choreography-based sagas using events, channels, publishers, and handlers
- The benefits and drawbacks of choreography-based saga coordination
- Designing orchestration-based sagas using an explicit orchestrator and state machine
- Implementing orchestration using asynchronous messaging and synchronous request/response
- The benefits and drawbacks of orchestration-based saga coordination
In the previous chapter, you learned why classic distributed transactions are not a good fit and why sagas are the preferred way to implement system commands that span multiple services. As I described, when implementing a saga, you must choose a mechanism - either choreography or orchestration - that coordinates the execution of its steps. The coordination mechanism invokes a participant, evaluates the outcome, and determines which participant to invoke next. It ensures that the saga completes: either by executing all the forward transactions or, if a step fails, by invoking the compensating transactions for the preceding steps.