OUTBOX-PATTERN
Outbox pattern (Transactional Outbox) — a dedicated 'outbox' table in the same DB as business data, atomically written, then polled and published to a message bus by an external publisher to guarantee atomicity.
Definition
The Outbox pattern solves the dual-write problem: you want to commit a business change AND publish a corresponding event. Outbox writes both in the same DB transaction; a poller (Debezium CDC or custom job) reads the outbox table and publishes to Kafka/RabbitMQ.
Origin
Pattern documented by Chris Richardson on microservices.io (2017). Massively implemented with Debezium (Outbox Event Router transform) since 2019.
Use
An EDI reception runs: INSERT INTO invoice(...); INSERT INTO outbox(event_type='InvoiceReceived', payload=...). A Debezium job reads the outbox table and publishes to Kafka. On crash, the transaction is atomic; otherwise, retried for sure.
Related terms
- Inbox pattern — inbound counterpart.
- Event sourcing — family.
- Idempotency — required property.
- Kafka — target publication.