liveBook · Manning

Fan-out choreography

As explained in Microservices Patterns, Second Edition

A choreography arrangement in which a request or event is published to multiple participants that independently consume the data they need.

Fan-out choreography triggers multiple saga participants from the same event rather than passing data through a sequential chain. Routing each participant only the data it needs can eliminate pass-through design-time coupling. section 10.1.3

Consider the coordination costs before choosing this arrangement:

  • Participants can act concurrently, but the coordinating service must handle results arriving in any order, track pending states, and reject an order only once. section 10.1.3
  • If one participant succeeds and another fails, the successful participant must compensate. An Order Rejected event can trigger compensation without adding dependencies between participants. section 10.1.3
  • Choreography uses asynchronous event publishing and consumption, but can become difficult to understand as participants and interactions multiply. section 10.1.4

Create Order saga

The Order Service publishes Order Created to the Customer Service and Inventory Service. The customer service reserves credit; inventory reserves products using productSpecification sent directly by the Order Service. If either reservation fails, Order Rejected triggers compensation where needed. section 10.1.3 section 10.1.3

Figure 10.6 A version of the Create Order Saga that uses fan-out publish/subscribe. The Order Created event triggers both the Customer Service and the Inventory Service, which eliminates pass-through coupling in the Customer Service. The productSpecification is passed directly from the Order Service to the Inventory Service.
events transport data with inventory fanout happy

Shows Order Created triggering both services and productSpecification flowing directly to Inventory. section 10.1.3

How Microservices Patterns, Second Edition covers it

How deep it goes
Traces concurrent event flows through pending states, failure handling, and compensating transactions.
Examples
Uses order creation to reserve customer credit and inventory, routing productSpecification directly to the Inventory Service.
What you can do after
Apply fan-out by routing events directly to participants, tracking out-of-order results, and triggering compensation after rejection.
How it connects
Connects saga choreography with publish/subscribe, asynchronous messaging, design-time coupling, and compensating transactions.

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.