liveBook · Manning

Saga instance

As explained in Microservices Patterns, Second Edition

A saga instance is a runtime record representing one execution of a saga, including its request data and current state.

A saga instance is the runtime record for one saga execution. It is initialized with request parameters, invoked to execute its first state, and persisted by the orchestration service. section 10.2.4

In request/asynchronous-response orchestration, the instance participates in this cycle:

  • A reply identifies the instance by saga ID; the orchestrator loads and invokes it, transitions it to the next state, runs that state’s entry action, and persists it again. section 10.2.4
  • The cycle repeats until the saga completes. The Transaction outbox sends command messages, while the Idempotent consumer check detects duplicate replies. section 10.2.4
Figure 10.13 The state machine for a saga orchestrator that invokes the participants using request/asynchronous-response. The state entry actions send command messages. The state transitions are triggered by reply messages.
orchestration async state machine

The state machine diagram shows how state entry actions send commands and reply messages trigger transitions. section 10.2.4

How Microservices Patterns, Second Edition covers it

How deep it goes
Traces initialization, persistence, reply-driven loading, state transitions, and completion.
Examples
Uses a Create Order Saga and reply-triggered transitions to illustrate instance execution.
What you can do after
Operate an instance by initializing it from request parameters, persisting it, and loading it by saga ID when replies arrive.
How it connects
Connects saga instances to state machines, asynchronous messaging, the Transaction outbox pattern, and the Idempotent consumer pattern.

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.