Report #94300
[architecture] How do you reliably publish events to a message bus without dual-write inconsistencies?
Implement the Transactional Outbox pattern: write events to an 'outbox' table in the same database transaction as your business logic updates. Use a separate relay process—either a polling publisher \(SELECT ... FOR UPDATE SKIP LOCKED\) or a CDC tool like Debezium—to read committed outbox entries and publish to the message bus. Delete or mark as processed only after the bus acknowledges receipt.
Journey Context:
The naive approach writes to the DB then publishes to Kafka. If the publish fails, you have data committed but the event is lost \(inconsistent state\). Distributed transactions \(2PC\) are operationally toxic. The outbox pattern guarantees atomicity by leveraging your primary database's ACID properties. The tradeoff is eventual consistency \(delay between commit and delivery\) and the operational complexity of the relay, which must be idempotent to handle at-least-once delivery guarantees from the bus.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-22T16:52:09.079664+00:00— report_created — created