← All patterns The problem An order commits, then its event publish fails. Other services never learn that the order exists.
When it fits A local database change must eventually cause a message, and the producer can persist an outbox record in the same transaction.
The whole architecture
Architecture diagram Download SVG Business state and an outbox record commit locally; a relay publishes retained events to a broker.
Blue arrows are writes; purple arrows are committed-event handoffs.
transactional outbox architecture Business state and an outbox record commit locally; a relay publishes retained events to a broker. Blue arrows are writes; purple arrows are committed-event handoffs. One local SQL transaction Consumer transaction domain producer → business: state write producer → outbox: event record outbox → relay: committed entries relay → broker: publish broker → consumer: deliver consumer → consumer-sql: commit effect + ID state write event record committed entries publish deliver commit effect + ID The producer commits its state and event record in one SQL transaction. Producer API Business operation These tables share the transaction boundary with the outbox. Business tables Authoritative state Only committed outbox entries are eligible for publication. Outbox table Stable event identity A crash after publish can cause the same event to be sent again. Outbox relay Poll or committed feed Publication acknowledgment is distinct from a consumer effect. Message broker Retained event delivery The handler must handle duplicate event delivery. Consumer Idempotent handler Persist the effect and deduplication record atomically where that local contract is supported. Consumer SQL Effect + processed ID API / data call Event / job flowSelect a component, or focus it and press Enter, to read its role.
The atomic producer transaction does not include the later broker publish. At-least-once relay behavior still requires consumer duplicate handling. Walk through the design
Follow one operation Core flow Failure & recovery
Select a step to highlight its participants. This conceptual walkthrough is separate from challenge scoring.
Arrows show the conceptual relationships used by this walkthrough.
1 Write one local transaction2 Relay committed events3 Record delivery progressStep 1 of 3 Write one local transaction App writes the order and its event record in the same SQL transaction.
← Previous Restart Next step →
Trade-offs to make explicit The atomic boundary covers business state and the outbox record, not the later broker publish. A relay adds delivery lag, cleanup and monitoring. Consumers still need duplicate handling and ordering rules. Failure modes to plan for A relay crash after publishing but before marking delivery can publish the same event again. An unmonitored relay can leave committed events waiting indefinitely. Track oldest undelivered age. Before you build Explain your decision How would a consumer deduplicate an event without losing its effect if it crashes midway?
Use Plan & estimate inside practice to record your assumptions and trade-offs.
These links open the original challenges. Existing round unlocks, completions and points apply.
Rebuild search while writes continue Related practice in committed change capture and replay. It models CDC recovery, not a complete transactional-outbox protocol.
Open challenge → One transfer, two attempts Practice stable identities and atomic deduplication within one SQL domain.
Open challenge → Further reading AWS · Transactional outbox ↗
Original PractiseGrid explanations and conceptual diagrams, with primary references for further study. Dedicated scored exercises can be added as coverage grows.