When an operation depends on several services, successful individual requests do not necessarily mean the entire workflow has succeeded. Two steps may complete before a third fails, or a service may perform its work while its response never reaches the caller.
For example, an insurance workflow might involve creating a claim, transferring documents, and recording an assessment. We will use this illustrative scenario to explain the problem. The same challenges appear in order processing, travel reservations, and many other workflows.
Managing these operations requires understanding each step's effects, the evidence of its success, and what recovery is safe after failure. This article examines how orchestration, sagas, the outbox pattern, MassTransit, and RabbitMQ contribute to that design.
Why Sequential API Calls Are Not Enough
The successful path can look straightforward:
Create a claim → Transfer documents → Record an assessment
But if the final step fails, should everything start again? Repeating the first step may create another claim.
A timeout is harder to interpret. The registration may have succeeded while its response was lost. A missing response does not prove that an operation did not happen. Retrying without an idempotency guarantee can create duplicate effects. AWS guidance on safe retries
The design must therefore account for partial completion and unknown outcomes alongside execution order.
What Do Orchestration and Sagas Do?
With orchestration, a coordinator manages the workflow: it selects the next step, receives outcomes, and decides whether to continue, stop, or recover. The service responsible for a step still owns that step's business rules.
A saga coordinates a sequence of local transactions. Each step commits its own changes, and the design defines how to continue or compensate when later steps fail. Orchestration is one implementation approach; another is choreography, where services advance the flow by reacting to events. Microsoft's saga pattern documentation
Having a coordinator does not automatically provide compensation. The design must establish which changes can be compensated and which steps require safe forward recovery.
In our insurance example, if document transfer fails after a claim is created, resuming the transfer after recovery may be preferable to deleting the claim. Business rules determine that choice.
Workflow State Must Survive Interruptions
If progress exists only in application memory, a process failure can remove the information needed to resume.
A recoverable design should persist at least the current step, confirmed results from earlier steps, and information needed to investigate failures. It also needs an operation identifier to correlate requests and messages belonging to the same workflow.
After a step succeeds, its result and the workflow's progress are recorded in one local transaction. This persisted boundary is a checkpoint: confirmed steps do not need to be repeated when execution resumes.
A checkpoint does not eliminate every failure window. An external service may succeed while saving its result locally fails. That situation must be handled as an unknown outcome.
Choose Recovery Based on the Failure
Three situations require different responses:
| Situation | Appropriate response |
|---|---|
| A temporary failure, where repetition is safe | Bounded retries with suitable delays |
| Invalid input or a business rule rejection | Correct the input or make a business decision; repeating unchanged input is insufficient |
| An unknown outcome from an operation with side effects | Query, reconcile, or investigate before repeating the request |
For unknown outcomes, the API contract is especially important. If the provider supports an idempotency key, attempts belonging to one operation should reuse that key. If the provider supports querying the result, that capability can help reconcile state.
Generating an identifier locally is insufficient: the receiving service must honor its meaning in the API contract and execution. Without those capabilities, some situations may require manual review. AWS explains request identifiers and idempotency
Concurrent processing also needs coordination. A lock or lease can help establish ownership, but an expired lease does not prove that a previous external request did not take effect.
What Gap Does the Outbox Address?
A service may need to change local data and publish an event. If it saves the data and then stops before publishing, other services may never learn about the change.
A transactional outbox records the local change and outgoing message in one database transaction. A separate process later delivers the message to the broker. AWS documentation on the Transactional Outbox pattern
This manages the gap between the local commit and message publication. It does not automatically include an external HTTP call in the same transaction.
If delivery succeeds but recording delivery completion fails, the message may be published again. Consumers must still handle repetition safely, for example by recognizing duplicate requests or using operations that do not create additional effects when repeated.
An outbox does not replace idempotency.
Where Do MassTransit and RabbitMQ Fit?
These components have different responsibilities:
| Component | Responsibility |
|---|---|
| Orchestrator | Manage the workflow and decide the next step |
| Outbox | Persist outgoing messages alongside local changes for later delivery |
| MassTransit | Provide .NET messaging facilities, retries, redelivery, and saga state machines |
| RabbitMQ | Route and deliver messages between producers and consumers |
With MassTransit, it is important to distinguish an in-memory outbox from a transactional outbox. The in-memory version buffers outgoing messages until processing succeeds, but its buffer is lost if the process stops. A transactional outbox persists messages so delivery can resume after interruption.
Configuring these features does not define compensation rules or make external side effects safe on our behalf. MassTransit outbox documentation
In RabbitMQ, publisher confirms acknowledge the broker's acceptance of messages according to its guarantees; they do not establish that a consumer finished its work. Consumer acknowledgements cover the processing boundary of individual deliveries. Neither independently reports the success of an entire business workflow. RabbitMQ documentation on acknowledgements and confirms
Compensation Is Different from Database Rollback
Within a local transaction, rollback can discard changes that have not committed. In a saga, earlier steps may already have committed. Compensation is a new operation governed by its own business rules.
Cancelling a reservation or releasing an allocation can be a compensating action. Sending a message to a user or performing some external changes cannot be precisely undone.
Compensation can also fail, so its progress needs tracking and recovery. It must account for legitimate concurrent changes rather than blindly restoring an earlier snapshot. Microsoft's Compensating Transaction pattern
Before choosing a saga, establish which steps are compensable and where the workflow becomes irreversible.
What Does Success Mean to the User?
Accepting a request, delivering a message, and completing an operation are different events.
An asynchronous workflow can acknowledge acceptance after persisting the request and expose its final status separately.
In our insurance example, claim registration might be complete while some documents are still being transferred. The system should communicate which part of the workflow each success message refers to.
The design also needs monitoring. Stalled operations, failed attempts, and unknown outcomes must be discoverable. A shared operation identifier across logs and messages makes the workflow easier to trace.
These recovery patterns also have an architectural context. Data coupling across microservices can increase the number of steps that need coordination. When the workflow updates a separate read model, CQRS and its consistency trade-offs help explain why a successful write may not appear in a query immediately.
How Much of the Problem Do These Patterns Solve?
Orchestration and durable state help locate a workflow and guide recovery. The outbox addresses message publication failures after local changes. Where valid compensating actions exist, a saga provides a framework for recovering changes across services.
This design does not create a global ACID transaction or the isolation of a single transaction. Intermediate states may be visible, and eventual convergence depends on dependency recovery and correct continuation or compensation rules.
The cost is additional states, messages, and failure paths. Testing only the successful path is insufficient. Tests should also examine lost responses, duplicate deliveries, process failure after an external change, competing workers, and failed compensation.
For each step, ask three questions: What effect does it have? What evidence establishes success? How can we recover if the outcome is unknown? Those answers determine the coordination and guarantees the system can actually provide.