liveBook · Manning

Orchestration-based saga coordination

As explained in Microservices Patterns, Second Edition

A saga whose steps are coordinated by a centralized orchestrator.

When a system command spans multiple services, a saga must coordinate their transactions and handle failures. Orchestration centralizes that coordination in an orchestrator: it invokes a participant, evaluates the outcome, and decides which participant to invoke next. If a forward transaction fails, it invokes compensating transactions for preceding steps. section 10.0 section 10.2

The orchestrator can invoke participants synchronously or asynchronously, and can live in a separate service or be embedded in a participant. Steps often run sequentially, although independent transactions can sometimes run concurrently. If a request’s outcome is unknown, simply rejecting the overall operation can leave the system inconsistent; the coordination logic may need to send a compensating request. section 10.2 section 9.2.3

Creating an order

A six-step Create Order Saga involves four participants, with compensation for four steps. Its orchestrator is embedded in the Order Service and sends commands to participant channels; replies arrive on a reply channel. Order creation and updates are local operations. Eventuate Tram Saga supplies orchestration infrastructure, while the Transaction Outbox and Idempotent Consumer patterns support reliable message delivery and processing. section 11.1.2 section 11.4

Figure 11.1 Implementing the Create Order Saga using orchestration. The Order Service implements a saga orchestrator, which invokes the saga participants using asynchronous request/response.
SagaOrchestration

The diagram shows the Order Service orchestrator invoking participants through asynchronous request/response. section 11.1.2

Choose the coordination approach by weighing clarity against complexity:

  • Orchestration gives a saga a centralized definition and persistent, queryable state. Participants depend less on one another and can keep coordination logic out of their domain objects. section 10.2.6
  • Orchestration adds framework complexity and can accumulate business logic that belongs in participants. Keep the orchestrator focused on coordination; for example, let the Customer Service perform its own credit check. section 10.2.6
  • Choreography distributes sequencing through events and works well for simple sagas. As steps and participants multiply, its distributed flow can be harder to understand than a centralized orchestrator. section 10.3

How Microservices Patterns, Second Edition covers it

How deep it goes
Explains orchestration flow, placement, communication options, trade-offs, and an enterprise implementation with framework and messaging responsibilities.
Examples
Uses a six-step Create Order Saga with four participants and four compensating transactions.
What you can do after
Apply it via Eventuate Tram Saga using declarative saga definitions and participant command handlers.
How it connects
Connects sagas with compensating transactions, choreography, asynchronous messaging, Transaction Outbox, and Idempotent Consumer.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Microservices Patterns, Second Edition. The section links point to the parts of the book it draws on.