Inbox Pattern
ELI5 — The Vibe Check
The inbox pattern is the receiving side of the outbox pattern. When a message arrives, you write it to an inbox table first, then process it. If the message arrives again (duplicate), you check the inbox and skip it. It's deduplication with a paper trail.
Real Talk
The inbox pattern ensures idempotent message consumption by storing processed message IDs in an 'inbox' table. When a message arrives, the consumer checks if its ID exists in the inbox. If it does, the message is skipped (duplicate). If not, the message is processed and its ID is stored, both within the same transaction. This prevents duplicate processing in at-least-once delivery systems.
When You'll Hear This
"The inbox pattern deduplicates messages so we don't process the same order twice." / "Combine the outbox and inbox patterns for reliable end-to-end message delivery."
Related Terms
At-Least-Once Delivery
At-least-once delivery guarantees every message gets delivered... but maybe more than once. If the acknowledgment gets lost, the message gets sent again.
Idempotent
Idempotent means you can do the same thing multiple times and get the same result as doing it once.
Outbox Pattern
The outbox pattern solves the dual-write problem: how do you update a database AND send a message to a queue atomically?