Outbox pattern
The outbox pattern is a producer-side reliability pattern for avoiding dual-write inconsistency.
Problem it solves
Without an outbox, a producer often does two separate operations:
- Commit application/domain state
- Publish a message
If one succeeds and the other fails, state and messaging drift apart.
Typical flow
- Write domain changes and outbox entries in the same transaction boundary
- Commit once
- A relay/processor reads pending outbox entries and publishes them
- Mark or delete delivered entries
Delivery model
- Usually at-least-once delivery
- Consumers must remain idempotent
- Ordering is typically scoped (for example per key/group), not global
Trade-offs
- Stronger reliability between state changes and message publication
- Extra storage and background processing complexity
- Potential additional delivery latency depending on polling/relay behavior