An outbox stores an event record atomically with the local business change. A separate publisher sends it, bridging database commit and messaging without promising exactly-once delivery.
Before you start
You should understand HTTP, database transactions and the difference between one process and independently failing services. Draw the participants and message direction before choosing a pattern. Include timeout, duplicate delivery and recovery in the model instead of considering only successful requests.
The practical goal is to reason through this situation: An order and its created-event entry commit in one database transaction. Read the walkthrough first, then try the interview exercise before opening its answer. The important part is explaining the decision and its consequences, rather than remembering a definition alone.
Step-by-step walkthrough
Step 1: Commit local intent
Store the order and event record in one transaction.
Step 2: Publish asynchronously
A publisher delivers committed outbox rows and tracks progress.
Step 3: Expect redelivery
Use stable event IDs and idempotent consumers when acknowledgment is uncertain.
Worked scenario
An order and its created-event entry commit in one database transaction.
The publisher sends event E then crashes before marking it published. On restart it sends E again. This is compatible with the outbox’s guarantee: the business change has durable event intent, but delivery is not automatically exactly once. Deduplication at the consumer prevents repeated logical effects.
Common mistake
Publishing first or committing first without coordination can leave missing or phantom events.
Verify the behavior
Crash before commit, after commit and after send; verify no committed event is lost.
Interview exercise
Handle duplicate publication.
Answer and reasoning
Use stable event IDs and idempotent consumers; track publishing progress while allowing safe retries.
Continue learning
Compare the scenario with the Microservices interview questions and test your understanding with the Microservices MCQs. For terminology and implementation details, consult the reference material.