liveBook · Manning

Outbox pattern

As explained in Crack Any Codebase with AI

A transactional outbox is a technique that records a database change and its associated event in the same transaction before a separate process delivers the event.

The outbox pattern closes the reliability gap between a committed database change and asynchronous side effects. Write the core change and an outbox_event row in one transaction; a separate worker delivers the event after commit. section 8.4

Booking confirmation after a crash

A booking may commit successfully while the server crashes before creating its calendar event or sending a notification. With an outbox row written alongside the booking, a worker can drain the pending event after the API returns 201 Created. section 8.4

Use the pattern to investigate asynchronous fan-out:

  • Identify the core database transaction and its associated external side effects. section 8.4
  • Check whether a crash between COMMIT and the external call can silently drop work. section 8.4
  • Trace the worker that drains outbox events after the user-facing response. section 8.4
Figure 8.7 The outbox pattern prevents lost side effects. Without it, a crash after the COMMIT but before the webhook call drops the event silently. With the pattern, an outbox_event row is written in the same transaction as the booking. A separate worker drains the outbox after the commit, ensuring the webhook survives the crash.

Compare the failure path without an outbox against the transactional row and worker path that preserves the event. section 8.4

How Crack Any Codebase with AI covers it

How deep it goes
Explains the transaction boundary, crash window, outbox row, post-commit worker, and asynchronous delivery flow.
Examples
Uses bookings, calendar events, confirmation emails, webhooks, Slack alerts, and background jobs to expose lost side effects.
What you can do after
Diagnose whether asynchronous work can be silently dropped between database commit and external delivery.
How it connects
Connects database transactions with asynchronous fan-out, background workers, webhooks, notifications, and external service calls.

Also explained in

Compare how 4 books explain outbox pattern →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Crack Any Codebase with AI. The section links point to the parts of the book it draws on.