Most event-driven architectures look convincing on a whiteboard. An order enters the system, a broker carries the event, a set of services reacts, and the customer receives a result. The arrows are clean. The difficult part begins after one of those arrows succeeds only halfway.
At fulfillment scale, a message can be delivered correctly while the business workflow still ends in the wrong state. Inventory may be reserved but not acknowledged. A carrier request may time out after the carrier has accepted it. A retry may create a second side effect. An event may arrive late, technically valid but no longer safe to apply. None of these problems is solved by adding another queue.
I have worked on fulfillment platforms that coordinate more than 100 million messages a day across markets and operational boundaries. At that volume, reliability is not mainly about keeping brokers online. It is about preserving business intent while the surrounding systems are slow, duplicated, out of order, or temporarily unavailable.
This article describes the architecture I use to reason about that problem. The central idea is simple: recovery is part of the execution model, not a support procedure added after production incidents begin.
Delivery is not completion
A broker can tell us that a consumer acknowledged a message. It cannot tell us that the customer promise was honored. That distinction sounds obvious, but it is regularly lost in system design because transport metrics are easier to collect than business-state metrics.
Consider a simplified fulfillment step:
- The orchestration service asks an inventory service to reserve ten units.
- Inventory commits the reservation.
- The response is lost during a network interruption.
- The orchestration service times out and retries.
The transport layer sees a timeout followed by another request. The business has already changed state. If the second request is treated as new work, the system can reserve twenty units. If it is rejected without returning the first result, the workflow may remain stuck even though the original action succeeded.
“At least once” delivery is therefore not a reliability guarantee. It is a condition the application must be designed to survive. The useful question is not, “Did we process this message?” It is, “What durable business decision did we make, and can we return the same decision when the request is seen again?”
Every externally visible side effect needs a stable business key, a durable outcome, and a safe answer for a repeated request.
Start with invariants, not services
Architecture discussions often begin by drawing services. I prefer to begin with the statements that must remain true. Those statements survive changes in service boundaries, storage engines, and messaging technology.
For a fulfillment workflow, representative invariants might include:
- An order line cannot be assigned beyond the quantity the customer purchased.
- A unit cannot be simultaneously committed to two fulfillment outcomes.
- A cancellation cannot silently reverse an item that has already crossed an irreversible handoff.
- A completed side effect cannot be repeated merely because its acknowledgement was lost.
- A tenant or market cannot read, mutate, or replay another tenant’s workflow.
- Every manual correction must leave an auditable record of who changed what and why.
These are business properties, not implementation details. Once they are explicit, service boundaries become easier to evaluate. A service that cannot enforce the invariant it owns is probably the wrong decision boundary.
There is also a useful distinction between a local invariant and a workflow invariant. A local invariant can be enforced within one database transaction: a reservation count cannot become negative, for example. A workflow invariant spans services and time: an order should not be released to shipping until payment and inventory are both in an acceptable state. Trying to enforce the second kind with distributed transactions usually makes the system more fragile. It needs an explicit state machine instead.
Give the workflow an owner
Pure choreography is attractive when a domain is small. Each service subscribes to events, performs its work, and publishes another event. The coupling is indirect, and teams can move independently.
The weakness appears when nobody owns the whole outcome. After eight services have reacted to one another, where does an operator look to answer a basic question: “Why is this order still waiting?” If the answer requires reconstructing intent from several topics and databases, the architecture has transferred complexity from code to operations.
For long-running fulfillment, I use a hybrid model:
- Domain services own their local data and local rules.
- Events remain the integration mechanism.
- A workflow owner holds the cross-service state machine and decides the next valid action.
- The workflow owner records progress before issuing the next command.
- Services return stable outcomes for repeated commands.
This is orchestration without turning the orchestrator into a business-logic monopoly. It knows the sequence and the overall state. Inventory still decides whether inventory can be reserved. Payment still owns payment decisions. Fulfillment still owns execution within a node.
Only one component advances a workflow from one business state to the next.
Each domain service validates and records its own durable outcome.
The current state and the next permitted actions are queryable without replaying an entire topic.
Reversal is modeled only where the original action can actually be undone.
Compensation deserves special care. “Undo” is rarely a universal operation. Releasing an inventory reservation may be reversible. Recalling a parcel already handed to a carrier may not be. The state machine should distinguish reversible steps, compensatable steps, and irreversible steps. Treating all three the same creates recovery logic that looks complete but fails under real operational constraints.
Make events replayable by design
Replay is often introduced as an emergency tool. It should be treated as a normal consumer behavior. A consumer can see the same event again because of a retry, a rebalance, a restored checkpoint, a disaster-recovery exercise, or a deliberate backfill.
A useful event envelope carries more than a payload:
{
"eventId": "evt-01JY...",
"eventType": "FulfillmentAllocationRequested",
"eventVersion": 3,
"occurredAt": "2026-12-02T17:02:41Z",
"tenantId": "market-us",
"aggregateType": "Order",
"aggregateId": "order-84291",
"aggregateVersion": 17,
"workflowId": "wf-55120",
"causationId": "cmd-33810",
"correlationId": "order-84291",
"idempotencyKey": "order-84291:allocate:attempt-1",
"traceparent": "00-4bf92f3577b34da6a3ce929d0e0e4736-00f067aa0ba902b7-01",
"payload": {
"orderLineId": "line-4",
"quantity": 2,
"candidateNodeIds": ["node-17", "node-42"]
}
}
Several identifiers serve different purposes:
-
eventIdidentifies this immutable fact. -
idempotencyKeyidentifies the business operation that must have one stable outcome. -
aggregateVersionlets a consumer detect gaps and stale updates. -
causationIdpoints to the command or event that triggered this event. -
correlationIdgroups the wider business journey. -
workflowIdlocates the state machine that owns progress. -
tenantIdis part of authorization and partitioning, not merely reporting metadata.
Using one ID for all of these concerns usually works until replay or partial recovery begins. Then the missing distinctions become production ambiguity.
The event contract should also state its compatibility rules. Adding an optional field is usually safe. Reinterpreting an existing field is not. If an event’s meaning changes, publish a new version and keep the translation at the boundary. Consumers should not need to guess which interpretation the producer intended.
Record enough context to recover
The most useful recovery record is not a generic error row. It is a compact history of business progress: what the workflow intended to do, which side effects completed, which response was observed, and who currently owns the next decision.
I typically separate four records:
- Workflow state. The current business state, its version, and the next permitted transitions.
- Inbox record. The consumer’s durable proof that a particular message was accepted and what result it produced.
- Outbox record. The producer’s durable intent to publish an event after committing its local state.
- Recovery ledger. Operational context for work that cannot proceed automatically: failure class, attempts, last known side effects, ownership, and disposition.
The inbox and outbox close the common gaps between a database transaction and message publication. They do not make the whole distributed workflow atomic, nor should they. They make each local decision durable and observable so the workflow can continue from facts instead of inference.
A consumer handler then follows a predictable shape:
Outcome handle(Command command) {
return transaction(() -> {
Outcome prior = inbox.findOutcome(command.idempotencyKey());
if (prior != null) {
return prior;
}
Aggregate current = repository.lock(command.aggregateId());
Decision decision = domain.decide(current, command);
repository.save(decision.updatedAggregate());
outbox.append(decision.events());
inbox.record(command.idempotencyKey(), decision.outcome());
return decision.outcome();
});
}
The important line is not the duplicate check by itself. It is the storage of the original outcome in the same local transaction as the state change. A repeated command should receive the same answer, not merely a “duplicate ignored” acknowledgement that leaves its caller uncertain.
Classify failures before choosing a retry
Retries are useful only when the failure is likely to change. A retry policy without a failure taxonomy converts errors into traffic.
| Failure class | Example | Safe response |
|---|---|---|
| Transient dependency failure | Short database failover or temporary network loss | Retry with bounded exponential backoff and jitter |
| Duplicate delivery | Consumer sees an already completed command | Return the stored outcome without repeating the side effect |
| Out-of-order event | Version 19 arrives before version 18 | Hold briefly, fetch missing state, or route for ordered reconciliation |
| Poison message | Schema is valid but the payload violates a domain rule | Stop retrying; quarantine with the reason and owning team |
| Ambiguous side effect | Carrier call timed out after the request may have succeeded | Query by idempotency key before attempting the action again |
| Sustained brownout | Dependency responds slowly for several minutes | Reduce concurrency, open the circuit, and preserve capacity for recovery |
| Invalid authorization boundary | Tenant or market does not match the resource | Reject permanently and raise a security signal |
The retry budget should belong to the business operation, not to each technical hop. If a command passes through three services and each retries five times, one customer action can produce 125 downstream attempts. That multiplication is easy to miss during normal traffic and destructive during an outage.
I prefer a deadline carried with the workflow. Each component can spend part of the remaining budget, but it cannot quietly reset the clock. Once the deadline expires, ownership moves to a recovery path with explicit policy: wait, compensate, request operator input, or end in a well-defined terminal state.
Dead-letter queues are useful transport isolation. They are not a recovery strategy. A queue full of failed messages says where the bytes went; it does not say whether inventory was reserved, whether a refund was issued, or whether replay is safe. That context belongs in the recovery ledger.
Control flow before overload
Peak events expose a second class of failure: every component is healthy, but the system as a whole is accepting work faster than a constrained dependency can complete it.
Queue depth alone is a weak signal. A million small, recent messages may be manageable. Fifty thousand old messages tied to expiring customer promises may be urgent. I monitor both lag and age, then relate them to the business deadline.
Flow control should be deliberate at each boundary:
- Set consumer concurrency from measured downstream capacity, not broker partition count alone.
- Bound in-memory work so a slow dependency cannot exhaust the consumer.
- Use admission control before the system reaches the point where every request times out.
- Reserve capacity for recovery and cancellation traffic; fresh orders should not consume every worker.
- Partition fairly across tenants, markets, or fulfillment nodes so one hot partition cannot monopolize the fleet.
- Shed optional enrichment before dropping workflow-critical actions.
Multi-tenancy makes fairness part of correctness. A shared platform may be technically available while one tenant is effectively starved. Per-tenant concurrency limits, weighted queues, and isolated recovery budgets prevent a large workload from turning a shared incident into a universal one.
Backpressure also needs to travel upstream. If the fulfillment boundary can safely process 20,000 operations per minute, accepting 80,000 and hiding the difference in a queue does not create capacity. It creates older work and a more difficult recovery. The upstream system needs a truthful signal early enough to change behavior.
Operate the business state, not only the infrastructure
Infrastructure telemetry still matters. We need broker availability, partition health, consumer lag, database saturation, and error rates. But those signals do not answer the questions an operations team faces during a fulfillment incident.
The dashboard I want beside the infrastructure view includes:
- Workflows by business state and age.
- The oldest item waiting in each state.
- Promise deadlines at risk within the next operating window.
- Duplicate commands and the outcomes returned for them.
- Compensation requests, grouped by reason and reversibility.
- Recovery records without a current owner.
- Replay volume and replay success rate.
- Tenant, market, and node skew.
- Time spent in each transition, including dependency wait time.
Trace context should connect the message path, but a trace is not the system of record. Sampling may omit the one workflow an operator needs. Retention may be too short. Business state and recovery ownership must remain queryable independently of tracing infrastructure.
Operational tools also need guardrails. “Replay message” is too blunt for a production control. A safe recovery action should show the current workflow state, the original side effects, the expected transition, the tenant boundary, and the exact scope of the replay. High-impact actions should require a reason and produce an audit entry.
Test the recovery paths before they are needed
The happy path is a small part of the test surface. I expect a fulfillment platform to demonstrate these behaviors before a major peak:
- Reprocess the same command repeatedly and prove that the side effect occurs once.
- Deliver events out of order and verify that stale state cannot overwrite newer state.
- Interrupt execution after the domain commit but before event publication.
- Interrupt execution after a remote side effect but before its response is stored.
- Restore a consumer from an older checkpoint and replay a realistic window.
- Slow one tenant or node and verify fairness for the others.
- Change a schema version while old and new consumers run together.
- Remove an operator midway through a manual recovery and prove that ownership is not lost.
These tests are more valuable when expressed as invariants. Instead of asserting that a particular sequence of calls occurred, assert that allocated quantity never exceeded ordered quantity, that each business key has one durable outcome, and that every nonterminal workflow has a next owner. That keeps the tests useful as the implementation evolves.
Roll out the model in slices
Retrofitting recoverability across an established platform does not require a single migration. Start with one workflow that creates meaningful operational pain. Make its state explicit. Add a stable idempotency key at the first side-effect boundary. Store the original outcome. Introduce the outbox where state and publication can diverge. Then build an operator view around the recovery ledger.
Run the new path in observation mode before giving it authority. Compare the state it would have chosen with the existing outcome. Reconcile differences. When the model is trustworthy, move one transition at a time.
The architecture is complete only when ownership is clear. Product and operations need to agree on terminal states and customer consequences. Domain teams need to own their idempotency contracts. Platform teams need to own transport, replay tooling, and shared guardrails. On-call engineers need a recovery procedure that does not require them to reverse-engineer the workflow at 2 a.m.
The standard is correct recovery
A dependable event-driven system does not promise that messages will never be duplicated, delayed, or delivered during a dependency failure. It assumes those conditions will occur and preserves the information required to make the next correct decision.
That changes the architecture in practical ways. Business invariants shape service boundaries. A workflow owner makes progress visible. Idempotency returns the original outcome. Inbox and outbox records close local consistency gaps. Recovery data carries business context. Flow control protects the work already accepted. Operations can see and act on workflow state instead of guessing from infrastructure symptoms.
The broker remains important, but it is no longer mistaken for the system’s reliability model. Delivery moves data. Ownership, durable decisions, and controlled recovery move the business forward.