Log tailing with Debezium
A legacy inventory table captured from the PostgreSQL log by Debezium on Kafka Connect and embedded in the service, published as InventoryItem documents.
examples/09-log-tailing-with-debezium/ captures a legacy inventory_item table from the write-ahead log and publishes each row as an InventoryItem document on edp.inventory.items. It accompanies Log tailing with Debezium.
It uses Quarkus, Camel Kafka, the Camel Debezium PostgreSQL component, Kafka Connect with Debezium, PostgreSQL and OpenTelemetry to the LGTM stack. verify.sh needs jq on the host.
(cd examples/domain-model && mvn -B -q install)
cd examples/09-log-tailing-with-debezium
mvn -B verify
./verify.sh
What to observe
- The snapshot. Five
revents and five documents, one per SKU, before anything changes. - One change, one document. An update arrives as a
uevent and as a document with the domain’s names, keyed by SKU. beforedepends on the table. Under the default replica identity a delete carries the key and not the old row; underFULLit carries the whole row.- One tombstone. Debezium follows a delete with its own tombstone. The route drops it, so the documents topic gets exactly one.
- Order. Three updates of one row in one transaction arrive in commit order with increasing LSNs.
- A quiet slot. A burst on a table nobody captures stays in the log with only a heartbeat interval, and is released when the heartbeat writes to a captured table.
- Incremental snapshot. A row in the signal table re-emits the table’s rows while changes keep streaming.
- Embedded. The same documents from Debezium inside the service, with its own slot and an offset file.
Infrastructure
Kafka, PostgreSQL, Kafka Connect with the published Debezium image and the LGTM stack from examples/_infra, a one-shot container that creates the two topics (the documents topic is compacted), and inventory-service. The compose project is edp-09.