liveBook · Manning

Chapter 10: Saga coordination mechanisms

What you will learn in chapter 10 of Microservices Patterns, Second Edition

Introduces what saga coordination must accomplish and distinguishes choreography’s event-driven control from orchestration’s dedicated orchestrator.

After this chapter you will be able to

What it builds on

Section by section

Introduction

Introduces what saga coordination must accomplish and distinguishes choreography’s event-driven control from orchestration’s dedicated orchestrator.

Key terms: coordination mechanism, participant, forward transactions, compensating transactions, choreography, orchestration, event, saga orchestrator

10.1 Choreography-based sagas

Introduces choreography-based saga coordination by showing how participants use events to advance steps and trigger compensation after a failure.

Key terms: choreography-based saga, participant, event handler, forward transaction, system command, failure event, compensating transaction

10.1.1 The choreography-based version of the Create Order Saga

This section traces how events coordinate the choreography-based Create Order Saga from order creation through credit reservation to approval or rejection.

Key terms: choreography-based saga, Order Service, Customer Service, OrderCreated, publish/subscribe, Credit Reserved, Customer Lookup Failed, Credit Limit Exceeded, approveOrder(), rejectOrder()

10.1.2 Design elements: events, channels, publishers and handlers

This section explains the events, channels, publishers, and handlers that coordinate a choreography-based saga, and the design choices involved.

Key terms: choreography-based saga, publish-subscribe channel, inbound adapter, outbound adapter, event handler, event type, service operation, system command, pass-through design-time coupling, integration events

10.1.3 Using fan-out choreography

This section shows how fan-out choreography reduces pass-through coupling in a Create Order saga, while making concurrent outcomes and compensation harder to coordinate.

Key terms: pass-through design-time coupling, fan-out choreography, linear choreography, productSpecification, Credit Reserved, Inventory Reserved, PENDING* states, failure events, compensating transactions, Order Rejected event

10.1.4 Benefits and drawbacks of choreography-based saga coordination

This section weighs the simplicity and loose coupling of choreography-based saga coordination against its distributed logic and potentially undesirable service dependencies.

Key terms: choreography, publish and consume events, message broker client library, loose runtime coupling, asynchronous messages, at least once delivery guarantee, fan-out choreography, pass-through design-time coupling, API Gateway, choreography-based sagas

10.2 Orchestration-based sagas

Introduces orchestration as centralized saga coordination and identifies the main choices for placing and invoking the orchestrator.

Key terms: orchestrator, saga participants, forward transaction, compensating transactions, synchronously, asynchronously, sequentially, concurrently

10.2.1 Example orchestration-based Create Order Saga

This section traces how the Order Service orchestrates a Create Order Saga through credit and inventory reservations, including an out-of-stock failure path.

Key terms: CreateOrderSagaOrchestrator, saga participants, asynchronous request/response, reply channel, Reserve Credit, Credit Reserved, Reserve Inventory, Inventory Reserved, Release Credit, reject the Order

10.2.2 Implementing the saga orchestrator

Explains how a saga orchestration framework models, persists, and executes an orchestrator’s state machine, and why reliable execution is more complex than the basic flow suggests.

Key terms: state machine, 'ING_' states, entry action, transitions, final states, orchestrator state, application data, system command parameters, unique ID, database

10.2.3 Location of orchestrator

This section compares two locations for a saga orchestrator and the coupling and complexity trade-offs of each.

Key terms: separate orchestration service, system command’s entry point, participants, design-time coupling, runtime coupling, embedded in participant, entry point service, dual responsibilities

10.2.4 Implementing orchestration using asynchronous messaging

This section explains how an orchestration-based saga coordinates participants through asynchronous commands and replies, including message design, state-machine execution, and variations for local operations and one-way notifications.

Key terms: saga orchestrator, command handler, inbound adapter, outbound adapter, reply handler, command message, reply message, command channel, reply channel, point-to-point channels

10.2.5 Implementing orchestration using synchronous request/response

This section explains how a saga orchestrator can invoke participants over HTTP, handle duplicate requests, and persist and retry execution when communication fails.

Key terms: synchronous request/response, outbound adapter, inbound adapter, REST endpoint, idempotency key, Idempotency-Key, idempotency token, duplicate request, state entry action, HTTP response

10.2.6 Benefits and drawbacks of orchestration-based sagas

This section weighs the benefits of orchestration-based sagas against their added complexity and the risk of putting participant business logic in the orchestrator.

Key terms: saga orchestrator, centralized definition, persistent, design-time coupling, saga coordination logic, participants, saga orchestration framework, Insider trading code smell, smart orchestrator and dumb participants

10.3 Summary

Where this is used later

Concepts explained in this chapter

← Chapter 9: Implementing system commands with sagas Chapter 11: The design of the FTGO 'Create Order saga' →

These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.