Systems & Backend

Outbox Pattern

also: transactional outbox

Write the event in the same DB transaction as the data; publish it afterwards — no lost, no phantom events.

“Update the database and publish to Kafka” cannot be atomic across two systems — one can succeed while the other fails. The outbox pattern writes the event to an outbox table inside the same local transaction as the business data; a relay (poller or CDC) then publishes it. At-least-once delivery with no phantoms, so consumers stay idempotent.