A financial platform needs state changes to reliably produce events. When is the transactional outbox the right choice and when is change data capture better?
Show the full answer Hide the answer
What both solve
The gap between a state change and its publication. Writing to the database and then publishing is two operations with no transaction between them, so a failure in between loses the event — silently, permanently, with nothing to detect it. Retrying does not help, because the retry has nothing to read.
The outbox
The state change and an outbox row commit in one local transaction; a relay publishes the row afterwards and marks it sent.
Choose it when the event is a designed contract. The outbox contains events you deliberately emit — "payment authorised", "card issued" — with a schema you own and a meaning you control. Consumers depend on that contract, not on your table structure.
This is the better default for financial systems, because the event's semantics matter and because a deliberate contract can be versioned.
Change data capture
The database's replication log is read and published as a stream of row changes.
Choose it when you need every change and cannot enumerate the events in advance — replicating to a warehouse, feeding a search index, building an audit stream. It requires no application change to add a consumer, which is the property that makes it scale organisationally.
Its cost is that it exposes your schema as a public interface. Downstream consumers become coupled to your table structure, and a column rename breaks consumers who never told you they depended on it. That is CDC's real cost and it is organisational rather than technical.
What neither solves
Consumers must be idempotent. Both are at-least-once: the relay may publish and crash before marking the row sent; CDC may replay after a failover. A consumer that is not idempotent turns a correct delivery guarantee into a correctness bug.
Neither provides ordering across entities — both preserve it per key at best — and neither removes the need for reconciliation, which is the only control that finds what the pipeline does not know it missed.
The combination that is common and correct
Outbox for the domain events that are a contract; CDC for the bulk replication that needs everything. They serve different consumers and the same system can reasonably run both.