Transactional outbox
An order and its event in one transaction, carried to Kafka by Debezium, with the dual write and a crash after the commit as comparisons.
Chapter 8
examples/08-transactional-outbox/ stores each order and its OrderPlaced event in one PostgreSQL transaction and publishes the event to edp.orders.placed through Debezium Connect. It accompanies Transactional outbox.
It uses Quarkus, Hibernate ORM with Panache, Flyway, the Debezium Outbox extension, Camel Kafka for the comparison routes, PostgreSQL, Debezium Connect and OpenTelemetry to the LGTM stack.
(cd examples/domain-model && mvn -B -q install)
cd examples/08-transactional-outbox
mvn -B verify
./verify.sh
What to observe
- One order, one record. The record is keyed by the order id and carries
idandeventTypeheaders. - A refused order is silent. A duplicate id gets a 409, and no record and no row follow.
- A crash after the commit loses nothing. The order placed through the outbox has its event after the restart.
- The dual write loses it. The commit-first route leaves the order without an event, and publish-first announces an order twice.
- Connect can be down. Orders are accepted, and their events arrive in commit order once Connect is back.
Infrastructure
Kafka, PostgreSQL, Connect and the LGTM stack from examples/_infra, a one-shot container that creates the order topic with one partition, and order-service. The compose project is edp-08.