Skip to main content

Transactional Outbox and CQRS

Learn Transactional Outbox and CQRS (Phase 7 · Database and Transactions (Core), Microservices) with worked examples, diagrams and interview questions. Free on JavaSchoolLab.

The dual-write problem and the transactional outbox • A service must update its database and publish an event. Doing both separately is a dual write : if the DB commit succeeds but the broker publish fails (or vice versa) the system becomes inconsistent. You cannot make a DB and a broker atomic with a simple transaction. • Transactional outbox : in the same local database transaction save the business change and insert the event into an outbox table. A separate relay reads unpublished rows and publishes them to the broker, then marks them published ( at-least-once : consumers must be...

More lessons in Phase 7 · Database and Transactions (Core)