Resequencing across partitions
One order-service that reads three per-event topics, restores order with the Camel stream or batch Resequencer, applies each event to PostgreSQL and publishes it keyed by order id.
Chapter 40
examples/ae-resequencing-across-partitions/ resequences shipment events that arrive from several producers on three topics. RESEQUENCER selects the stream or the batch form. It accompanies Appendix E.
It uses Quarkus, Camel Kafka, the Camel Resequencer, Hibernate ORM with Panache, Flyway, SmallRye Health, PostgreSQL, Kafka and OpenTelemetry to the LGTM stack.
(cd examples/domain-model && mvn -B -q install)
cd examples/ae-resequencing-across-partitions
mvn -B verify
./verify.sh
What to observe
- Global order. Twelve events of four orders arrive scrambled and are applied as 1 to 12; each orderβs events leave on
edp.shipping.shipmentsas 1, 2, 3 in one partition. - Gaps. A missing event is skipped at the timeout and a late one is applied last, or refused with
rejectOld. - The per-order number. Driving the stream form with it applies only some of the events and logs nothing.
- Batches. Each batch is sorted, and an order split over two batches is still applied out of order.
- Restart. Records held at a restart are not applied afterwards, because their offsets were committed.
Infrastructure
Kafka, PostgreSQL and the LGTM stack from examples/_infra, plus order-service. The compose project is edp-ae.