Patterns · Transactional Messaging
Patterns to guarantee that messages and events are published reliably as part of a database transaction. These solve the dual-write problem — the need to atomically update state and publish a notification.
Guarantees atomicity between a database update and message publishing by writing to an outbox table in the same transaction. A separate relay then delivers the messages.
A background process periodically polls the outbox table for unpublished messages and publishes them to the message broker. Simple and database-agnostic.
Uses Change Data Capture (CDC) to read the database transaction log and publish events in near real-time. More efficient than polling at high throughput.