Capabilities
Sagas & Workflows
Long-running processes as first-class citizens: sagas, declarative state machines, and routing slips with compensation.
Some operations aren’t one transaction — they’re a process: reserve inventory, capture payment, arrange shipping, and undo the right steps in the right order when step four fails. Modeling that as flags on a row ends in impossible states; Relay models it explicitly.
What ships: imperative Saga<TState> process managers with durable
state, the declarative StateMachineSaga<TState> DSL (states, events,
transitions — impossible states become unrepresentable), routing slips with
LIFO compensation for distributed transactions without 2PC, and
standalone courier activities for reusable, auditable units of work (the
principled version of the “undo money” script).
The stories behind it: The Order That Got Stuck Forever, The Onboarding That Got Lost in If-Statements, and The Transfer That Needed Undoing.
Learn by building
The tutorials for this area, in order — each with a runnable sample.
015SagasA command changes one aggregate; reliable messaging lets services react to each other.
016State-Machine SagasArticle 015 authored a saga imperatively — handler methods that mutate state and call RequestTimeout/Complete.
017Routing Slips & CompensationA distributed process books a flight, a hotel, and a car across three services. The flight and hotel succeed; the car fails.
036Standalone Courier Activities017 showed compensation inside a saga: forward legs record undo-commands onto a durable itinerary, and a failure replays them in reverse as reliable, scheduled commands.