Last Minute Notes
  • Github
  • Docs
  • Learn
    @sayanstwt
Lessons
0/37 done
  • Queues & Streams
  • Real-Time Updates
  • REST, gRPC & GraphQL
  • Events & the Outbox
Learn/System Design/Communication

Events & the Outbox

8 min Advanced 6 steps

Publish events reliably without dual writes.

DB write
pending
Event
pending
Result
-
DatabaseShippingOrder serviceBrokerEmailtwo writes to two systems
request response data
In this lessonStep 1 of 6
  1. The problem
  2. Outbox
  3. Relay
  4. Idempotent
  5. CQRS & CDC
  6. Recap
Step 1 / 6problem

Two writes, one can fail

The order service saves an order, then publishes an OrderPlaced event. Those are writes to two different systems.

If the service crashes between them, the order exists but nobody hears about it.

Key idea

This is the dual write problem. No retry logic fully fixes it, because the crash can erase the memory of what to retry.

←→ step·R replay·Space pause

You'll learn

  • Why "update DB and publish" is a dual-write bug
  • How the transactional outbox fixes it
  • Why consumers must be idempotent
  • CQRS, event sourcing and CDC in one picture
Read the full notesDistributed Systems, 11