Skip to content
Commitwise
Menu

Transactional outbox

Also called: Outbox pattern

Saving an outgoing message in the same database transaction as the data change, and publishing it afterwards.

Definition

A database and a message broker can't share one transaction, so publishing an event directly can lose it or send it for a change that was rolled back. With an outbox, the event is inserted into an outbox table in the same transaction as the data. A separate relay reads unsent rows and publishes them, marking them as sent. Delivery is at least once, so consumers must handle duplicates.

In practice

Saving an order also inserts an OrderPlaced row into the outbox; a relay publishes it to Kafka a moment later, even if the app restarted in between.

Learn it in context

Lessons that use this term.

Related terms

Esc

Type to search the whole site.