Assume a message can arrive more than once
An outbox consumer updates inventory or a projection, but the sender can replay the same event after losing an acknowledgment. A transactional inbox commits received identity and its local business effect together, preventing duplicate delivery from repeating that effect. Read outbox and idempotency first. It does not make the transport deliver once; it creates a receiver boundary that tolerates repeated delivery.
For event-7, atomically record identity and decrement inventory from ten to nine. A replay finds the identity, avoids a second effect and can acknowledge again. The condition is that identity and effect fit within one transaction-capable local store. A separately invoked payment API is outside that database boundary. Adopting an inbox name does not establish once-only behavior across every external side effect. State exactly which update is protected and which additional operation still needs its own recovery contract.
Trace the gaps in separately committed steps
Committing identity first can leave processed identity without an effect after a stop, causing replay to be discarded incorrectly. Committing the effect first can leave an unrecorded effect that replay repeats. Reordering separate commits trades one gap for another. A shared transaction gives a clear boundary: before commit neither is final; after commit both exist for recovery.
Acknowledge only after that boundary. Acknowledging before commit can let the sender discard work whose receiving effect later disappears. Stopping after commit but before acknowledgment can duplicate delivery, handled through stable identity. Keep transport acknowledgment and business commit separate in the trace. The chosen database's actual durability semantics also belong to the meaning of the acknowledgment. A response label alone cannot guarantee persistence not supplied by the store and configuration.
| Commit arrangement | State after an intervening stop |
|---|---|
| Identity then effect separately | Identity without effect |
| Effect then identity separately | Effect without identity |
| One transaction | Both committed or neither |
Use database uniqueness for concurrent receipt
Two workers can both observe no existing ID before either writes. A pre-check alone is not exclusion. Use database uniqueness and transaction-aware conflict handling so only the successful new claimant creates the effect. The competing path checks stored content and result. Verify whether the chosen database waits, fails one statement or leaves the transaction aborted on a conflict; those details affect correct implementation.
Store the business scope, event type and any required payload fingerprint or result with identity. Reusing an ID for another quantity must not receive unconditional old success. Fingerprints require canonicalization and collision assumptions. Select information needed for matching and audit rather than copying entire sensitive payloads unnecessarily. If IDs are unique only within senders, use the sender-and-ID scope. Correct deduplication depends on identity meaning as well as a syntactically unique column.
Align retention with replay and rebuild scope
Deleting inbox IDs after one day while the sender can replay three-day-old events permits old effects to be treated as new. Align retention with retry, outage recovery, archived replay and backup restoration. Permanent retention also has capacity and deletion costs, so define the promised old-event behavior rather than assuming forever is always correct. Natural business uniqueness or per-aggregate sequence positions can be alternatives under explicit conditions.
A new projection rebuild has a different scope. Reusing an old inbox that marks every historical event processed can prevent populating a new empty projection. Include consumer or projection generation where its meaning changes. Reapplying a business effect differs from reconstructing a separate derived view. Deleting all IDs and replaying indiscriminately can repeat external effects. Identify replay source and destination so rebuild correctness does not silently bypass the protection intended for live operations.
Retain failures with a recoverable meaning
Recording an invalid event as successfully processed can suppress a later corrected retry. Distinguish retryable failure, quarantine and final business rejection. Infinite retry can block later work, so operational resolution also needs an explicit state. Decide which identity marks successful completion and where failed-attempt records belong. An ID field alone does not choose that policy.
Observe deliveries, new identities, duplicates, conflicts, effects, retention age and backlog separately. Two deliveries with one effect can be intended behavior, not an error to conceal. The restart lab verifies this boundary using actual local consumer and relay processes. Its sequential SQLite result does not prove arbitrary concurrent or production behavior. In simpler applications, an existing business uniqueness constraint may supply the needed protection without a separate elaborate inbox. Compare the actual effect contract before introducing another table and lifecycle.
Separate repeated delivery from another business fact
Creation event-7 and cancellation event-8 can concern the same order without being duplicate facts. Using only order ID as the inbox unique key can wrongly discard cancellation. Select identity for the event effect this consumer must apply once, distinguishing order, business operation and transport attempt. A retry retains event identity while a different committed fact receives another identity under the sender's contract. Validate that correspondence with both a duplicate delivery and two distinct events for one order. A uniqueness constraint can enforce the wrong scope perfectly, so schema success alone does not prove correct business deduplication.
Solve the old-replay exercise
An event from three days ago is replayed after its identity was deleted at one day. The receiver can treat it as new. Align retention, old-event admission or natural business uniqueness with the promised contract. An operator remembering previous processing does not give the database information it no longer stores. Put sender replay duration and receiver retention in the same review.
One identity with zero effects is not automatically successful deduplication. It can reveal an identity-only commit. Inspect effect correspondence and trace acknowledgment, identity commit and effect commit separately. The pattern is understood when deliveries, new identities and business effects remain distinct counts, with concurrency and retention assumptions stated alongside them.