The saga pattern is the mechanism of defining a distributed transaction across microservices who each have their own levels of transactions. Think: “I need to commit this in 2 different databases”.

It can be accomplished through choreography or orchestration.

Choreography, like a ballet, “everyone knows what to do”.

  • Order service gets a new order. Writes CREATED event
  • Customer service sees event, does payment stuff, writes PAID event
  • Order service completes

Orchestration, like an ensemble, “people do what they’re told”.

  • Order service gets a new order.
  • Sends “get payment” command to customer service, receives response
  • Order service completes

also