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.

10.1 Choreography-based sagas

10.1.1 The choreography-based version of the Create Order Saga

10.1.2 Design elements: events, channels, publishers and handlers

10.1.3 Using fan-out choreography

10.1.4 Benefits and drawbacks of choreography-based saga coordination

10.2 Orchestration-based sagas

10.2.1 Example orchestration-based Create Order Saga

10.2.2 Implementing the saga orchestrator

10.2.3 Location of orchestrator

10.2.4 Implementing orchestration using asynchronous messaging

10.2.5 Implementing orchestration using synchronous request/response

10.2.6 Benefits and drawbacks of orchestration-based sagas

10.3 Summary