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.
Shows Order Created triggering both services and productSpecification flowing directly to Inventory. section 10.1.3
