← Back to microservices patterns map
📤
Microservices Pattern

Transactional Outbox

Write business data and outgoing event records in one local database transaction.

reliable events

Detailed Description

The outbox solves the dual-write problem: updating data and publishing a message cannot be atomic across DB and broker.

A relay or CDC process later publishes the outbox row to the broker.

Visual Diagram

Outbox Pattern Flow
  Begin Transaction:
    INSERT INTO orders  (order data)
    INSERT INTO outbox  (event data)  ← same tx
  Commit Transaction ✓

  [Outbox Poller / CDC]
    reads outbox table
    → publishes to Kafka/RabbitMQ
    → marks outbox record as sent

  Atomic: either both saved or neither

Tradeoffs

Pros

Reliable event publishing with local transaction

Cons

Outbox polling and cleanup required

Examples: Debezium outbox transform, custom outbox poller