data-infra

Transactional Outbox

The transactional outbox is a pattern that solves a subtle but common bug: you update your database and publish an event, but those are two separate systems, so a crash between them leaves you with one and not the other. The fix is to write the event into an 'outbox' table inside the same database transaction as the business change. Either both commit or neither does. A separate process then reads unpublished rows from the outbox and delivers them to your message queue or event stream, marking each as sent. Change-data-capture tools reading the write-ahead log are a common way to do this step efficiently. For SaaS builders, this is how you get reliable, atomic 'update-and-notify' without distributed transactions — critical when an order must always emit its 'order.created' event. Practical note: consumers must be idempotent, because the outbox guarantees at-least-once delivery, and the same event can arrive twice after a retry.

Related terms

More Data & Infra terms