INBOX-PATTERN
Inbox pattern (Transactional Inbox) — the consumer-side counterpart of Outbox, an 'inbox' table indexed by event_id that guarantees idempotent processing of a received event.
Definition
The Inbox pattern guarantees that a consumed message is processed exactly once on the consumer side. Before processing: SELECT FROM inbox WHERE event_id = ? FOR UPDATE. If found → no-op. Otherwise INSERT INTO inbox + do business work in the same transaction.
Origin
Documented alongside Outbox on microservices.io. Widely used in CQRS/event-sourcing in the .NET community (Wolverine, NServiceBus) since 2020.
Use
An EDI consumer receives an 'InvoiceReceived' event from Kafka. Code: (1) BEGIN TX, (2) try INSERT INTO inbox(event_id) → if unique violation = duplicate → COMMIT, return, (3) otherwise: apply business change (INSERT INTO invoice), COMMIT. Kafka duplicate: harmless.
Related terms
- Outbox pattern — outbound counterpart.
- Idempotency — targeted property.
- Kafka — events source.
- Event sourcing — family.