Implement the Transactional Outbox

atomic write plus relay

Challenge 5 of Async & MessagingIntermediate~50 min

Never lose an event, never write a lie. The outbox pattern solves the dual-write problem: instead of writing to your database and then publishing to a message broker (two systems that can disagree when one fails), you write the business row and the event to the same database in one transaction, then a relay ships the events out. Build the atomic write, the polling relay, and an idempotent consumer that makes at-least-once delivery safe.

4 steps

  1. 1The Atomic Write
  2. 2The Relay
  3. 3The Idempotent Consumer
  4. 4Surviving a Crash
Start step 1