The Outbox Pattern Fixes a Very Specific Failure
A typical service writes a database row and publishes an event. What happens if the write commits but the publish fails? Retrying the request may duplicate the business operation. Ignoring the publish leaves downstream systems unaware of it.
The transactional outbox solves this local dual-write problem. Record the business change and an outgoing event in the same database transaction. A separate publisher delivers the outbox rows and marks progress after acknowledgement.
HTTP command
|
v
DB transaction
|-- business record
|-- outbox record
|
v
Publisher --> message broker --> consumers
This is not exactly-once processing. The publisher can crash after sending a message but before recording success. Consumers still need deduplication or idempotent behavior. Outbox cleanup, ordering, dead-letter handling, and monitoring become part of the system.
Use the outbox when a database commit and an outbound event must stay logically coupled. Do not introduce it merely because your application has a queue. A periodic export with weak timeliness requirements might need something simpler.
The pattern is valuable precisely because it admits a truth: we cannot atomically commit an ordinary database transaction and an unrelated network publish by wishing hard enough.
Top comments (0)