Aggregate
One shipping-service that builds pickup lists from ShipmentScheduled twice, with a Kafka Streams tumbling window that emits one final list per carrier per slot and a Camel Aggregator that closes batches by size or quiet time.
examples/21-aggregate/ groups the shipments scheduled for each carrier into pickup lists. shipping-service runs a Kafka Streams topology and a Camel route on the same edp.shipping.scheduled input, each writing its own topic. It accompanies Aggregate.
It uses Quarkus, Quarkus Kafka Streams, Camel Kafka and the Camel SQL aggregation repository, Flyway, SmallRye Health, PostgreSQL, Kafka and OpenTelemetry to the LGTM stack.
(cd examples/domain-model && mvn -B -q install)
cd examples/21-aggregate
mvn -B verify
./verify.sh
What to observe
- One final list per slot. After a later event time closes the 09:00 window, Kafka Streams has written exactly one list for each carrier, with the shipment that arrived out of order inside it.
- A late record has no list. The 09:05 shipment that arrives after the window closed is on no Kafka Streams list, the dropped-records counter reaches Prometheus, and the Camel route puts it in a batch of its own.
- Two grouping rules. The same shipments give a batch of five closed by size and a batch of two closed by timeout on the Camel side.
- State survives a recreate. An open window and an open batch are both restored, and a list or batch of five closes after two more shipments.
Infrastructure
Kafka, PostgreSQL and the LGTM stack from examples/_infra, plus shipping-service. The compose project is edp-21.