Prerequisites and stacks
The tools, versions and local stack every example runs on, and a first Order sent through Quarkus, Camel, Kafka and the LGTM observability stack.
Every example in the book runs on one local stack: a Kafka broker, a PostgreSQL database, a schema registry, Kafka Connect with Debezium, and a Grafana LGTM container that receives traces, metrics and logs. An example is a small Quarkus service, usually with Camel routes, plus a script that starts the stack, exercises the service and checks what happened.
Learning objectives
- Install the pinned JDK, Maven and Docker Engine toolchain.
- Start the shared compose stack and confirm every service is healthy.
- Send a valid Order through the stack-check service onto Kafka.
- Locate the trace, metric and log for one request in Grafana.
- Tear down the stack and recognize when a second stack cannot start.
Why this matters
When a prerequisite is missed or a second stack is left running, the failure shows up as a port conflict or a missing container instead of a clear error, and chasing that confusion costs more time than the setup itself would have. The chapters that follow all depend on one working stack, so skipping a clean baseline wastes hours on symptoms that have nothing to do with the pattern under study. A shared host running two stacks also starves every service on it of memory.
What you need
A Fedora or RHEL host with Docker Engine and the docker compose plugin, JDK 25, Maven, git and curl. The compose examples never need more than that. Install Docker Engine from Docker’s repository for your distribution and add your user to the docker group so no command needs sudo.
Install JDK and Maven with SDKMAN, which installs under $HOME/.sdkman by default:
for t in git curl zip unzip docker; do command -v "$t" >/dev/null || echo "missing: $t"; done
docker compose version
curl -s "https://get.sdkman.io" | bash
source "$HOME/.sdkman/bin/sdkman-init.sh"
sdk install java 25.0.5-tem
sdk install maven 3.9.16
java -version && mvn -version
If the first line prints missing:, install that tool with your package manager before continuing. SDKMAN lists bash, zip, unzip and curl as its basic toolset.
Versions
Every version in the book is an exact pin, chosen as the newest stable release that works with the rest. Nothing needs a licence or a subscription.
| Component | Version | Why this one |
|---|---|---|
| JDK | Temurin 25.0.5 | Long-term-support line, the minimum for every example |
| Maven | 3.9.16 | Maven 3.10 is released, but Quarkus has an open issue against it |
| Quarkus platform | 3.40.1.2 | Long-term-support stream; includes Camel Quarkus 3.40.0 |
| Apache Camel | 4.22.2 | Long-term-support patch, imported through camel-bom ahead of the platform’s 4.22.1 |
| Apache Kafka | 4.3.2 | Newest version the latest Strimzi supports, so compose and Kubernetes match |
| PostgreSQL | 18.6 | CloudNativePG operand image on compose, same minor for Dev Services |
| Apicurio Registry | 3.3.4 | Schema registry |
| Debezium Connect | 3.7.1.Final | Published image, includes the PostgreSQL connector and the outbox EventRouter |
| Grafana LGTM | 0.41.0 | Loki, Grafana, Tempo and Prometheus behind one OTLP endpoint |
| UBI 10 OpenJDK | 1.24-20 | Build and runtime images for every packaged service |
| Docker Engine, Compose plugin | 29.9.3, 5.7.0 | Recorded from the reference host |
Each service image is pinned by tag in examples/_infra. Examples that trace through Kafka Connect add the OpenTelemetry Java agent (2.33.1, Apache-2.0): an init container copies it from Maven Central into a volume that docker compose down -v removes, so each fresh start downloads it again.
The local-model example needs the model. Pull it once into its own Docker volume, which survives every docker compose down -v; the examples mount it read-only and never download it themselves:
scripts/ollama-model.sh pull # once
scripts/ollama-model.sh check # confirms the pinned model digest
The stack
examples/_infra holds one compose file per service. An example includes the files it needs and adds its own services on the shared edp network.
| Service | Host port | Role |
|---|---|---|
| Kafka (KRaft, one node) | 9092 | The log every pattern publishes to and reads from. Containers use kafka:9094 |
PostgreSQL, wal_level=logical |
5432 | State, outbox tables and the event store. Logical decoding lets Debezium read changes |
| Apicurio Registry | 8081, health 19000 | Schemas for the schema-evolution examples. In memory, empty after a restart |
| Kafka Connect with Debezium | 8083 | Log tailing and the outbox router |
| Grafana LGTM | 3000, 4317, 4318, 19090, 3200, 3100 | Grafana, OTLP gRPC and HTTP, Prometheus, Tempo, Loki |
Cockpit, often enabled on Fedora and RHEL, listens on 9090, so Prometheus is published on 19090. Every service has a memory limit and a health check; the limits add up to about 7 GB if every container fills its allowance.
One stack at a time
Run one stack. The services publish fixed host ports, so a second copy fails to bind them, and a Kubernetes cluster needs the memory the compose stack uses. Every verify.sh begins with scripts/stack-guard.sh, which refuses to start while containers from another compose project or a minikube node are running. It never stops anything for you. Stop an example’s stack with docker compose down -v in its directory, or let verify.sh do it.
The running example
Every example in the book is a piece of one business: an online shop that sells and ships physical goods. A customer orders an item. The shop records the order, reserves stock, takes payment, books a carrier and delivers the parcel, and tells the customer after each step. Five services each own one of those steps. They share no tables and react to events on Kafka. Two patterns call the order service by design: event notification fetches the current order back, and a claim check fetches a stored attachment.
| Service | Owns | Reacts to | Emits |
|---|---|---|---|
| order-service | Order and its lifecycle |
InventoryInsufficient, PaymentProcessed, PaymentFailed, ShipmentScheduled, ShipmentDelivered | OrderPlaced, OrderCancelled |
| inventory-service | InventoryItem stock |
OrderPlaced, OrderCancelled, PaymentFailed | InventoryReserved, InventoryInsufficient |
| payment-service | Payment |
InventoryReserved | PaymentProcessed, PaymentFailed |
| shipping-service | Shipment, carrier choice |
PaymentProcessed | ShipmentScheduled, ShipmentInTransit, ShipmentDelivered |
| notification-service | Notification |
every event | nothing |
On the happy path the flow reads left to right in Figure 0.2. The order service publishes OrderPlaced. Inventory reserves stock and publishes InventoryReserved. Payment takes the money and publishes PaymentProcessed. Shipping books FASTLINE or AIRCO, then publishes ShipmentScheduled, ShipmentInTransit and ShipmentDelivered as the parcel moves. Order reacts to payment and shipment events to advance its status, and notification reads every topic to tell the customer. Apart from those fetches, no service calls another: each knows only the topics it reads and the topics it writes.
Each service keeps its tables in its own schema of the edp database: orders, inventory, payments, shipping and notifications. The order table is named orders because order is a reserved word.
Nine events carry the flow. A topic name is edp.<domain>.<event>, with dots and hyphens only.
| Event | Producer | Consumers | Topic |
|---|---|---|---|
| OrderPlaced | order | inventory, notification | edp.orders.placed |
| OrderCancelled | order | inventory, notification | edp.orders.cancelled |
| InventoryReserved | inventory | payment, notification | edp.inventory.reserved |
| InventoryInsufficient | inventory | order, notification | edp.inventory.insufficient |
| PaymentProcessed | payment | shipping, order, notification | edp.payments.processed |
| PaymentFailed | payment | inventory, order, notification | edp.payments.failed |
| ShipmentScheduled | shipping | order, notification | edp.shipping.scheduled |
| ShipmentInTransit | shipping | notification | edp.shipping.in-transit |
| ShipmentDelivered | shipping | order, notification | edp.shipping.delivered |
The records live in examples/domain-model: Order, InventoryItem, Payment, Shipment, Notification, their status enums and a Topics class that holds the names above, so no example types a topic by hand. Each record validates itself in its constructor. The payload of an event is a separate record inside each example, because how much state an event carries is itself a design decision.
An order moves one step at a time: PLACED, PAID, SHIPPED, DELIVERED. It can become CANCELLED only from PLACED or PAID. DELIVERED and CANCELLED are final. A shipment moves PENDING, SCHEDULED, IN_TRANSIT, DELIVERED. Order ids are text such as O-1001, and amounts carry two decimals.
Two fictional carriers deliver the parcels: FASTLINE by road and AIRCO by air. No real carrier appears anywhere in the book.
The failure paths are part of the model:
- Out of stock: InventoryInsufficient cancels the order, and the customer is told.
- Payment declined: PaymentFailed releases the reserved stock and cancels the order, and the customer is told.
- Late delivery: no ShipmentDelivered arrives in time, so someone must be alerted.
- The same event delivered twice: a consumer must not apply it twice.
- A service down: its events wait in Kafka until it returns.
Where the signals land
The stack-check service sets service.name to stack-check and exports all three signals over OTLP with http/protobuf to lgtm:4318.
Open Grafana at http://localhost:3000. It needs no login. In Explore, pick a data source:
| Signal | Data source | First query |
|---|---|---|
| Traces | Tempo | Search with service.name = stack-check |
| Metrics | Prometheus | target_info{service_name="stack-check"}, then any metric with that service_name label |
| Logs | Loki | {service_name="stack-check"}; the consumer route logs each record it reads |
How every example is laid out
examples/NN-slug/
pom.xml src/ Quarkus and Camel project
compose.yaml includes ../_infra files and adds the service
Containerfile UBI 10 multi-stage build, context is examples/
verify.sh starts the stack, checks the observable effect, tears down
README.md
examples/domain-model holds the shared shipping records (Order, Shipment and the rest), installed into the local Maven repository or built inside the Containerfile. Every example runs two ways:
mvn -B verifyruns the tests. Quarkus Dev Services starts the containers a test needs, so no compose stack is required../verify.shbuilds the image, starts the compose stack and checks the behaviour end to end. It prints onePASSorFAILline per check, ends withN/N checks passedand exits non-zero on any failure.KEEP=1 ./verify.shleaves the stack running afterwards so you can inspect it.
Each verify.sh includes a negative witness: a check that fails when the pattern’s guard is removed. Without it, a script could still pass after the guard it checks has been removed.
The stack check service
The first example is the smallest service that touches every piece. POST /orders takes an Order, rejects an invalid one with 400 and publishes a valid one to the edp.orders.placed topic keyed by its id. A second route consumes the topic and logs each record.
from("platform-http:/orders?httpMethodRestrict=POST")
.routeId("order-intake")
.unmarshal().json(Order.class)
.setHeader(KafkaConstants.KEY, simple("${body.id}"))
.marshal().json()
.to("kafka:" + Topics.ORDERS_PLACED)
.setHeader(Exchange.HTTP_RESPONSE_CODE, constant(202))
.setBody(constant(""));
The Order record validates itself in its constructor, so a zero quantity or a blank customer fails during unmarshalling. An onException clause turns that failure into a 400 before the route reaches Kafka.
Telemetry comes from the framework. camel-quarkus-opentelemetry2 creates a span per route and processor; the older camel-quarkus-opentelemetry extension is deprecated. quarkus-micrometer-opentelemetry exports the Micrometer meters over OTLP, so metrics take the same path as traces and no Prometheus scrape is configured. The same extension turns on OpenTelemetry tracing, metrics and logs by default, so the log records reach Loki with no extra setting. SmallRye Health serves /q/health.
Build, run, observe
(cd examples/domain-model && mvn -B -q install)
cd examples/00-stack-check
mvn -B verify
./verify.sh
verify.sh starts the full stack and prints 17/17 checks passed. Watch an invalid Order get 400 while the record count on the topic stays unchanged.
Try one change and rerun:
- Remove the
onExceptionclause: an invalid Order gets 500 instead of 400. - Change
Topics.ORDERS_PLACEDin the intake route to"edp.orders.placed-v2": no record arrives onedp.orders.placedand the consumer route has nothing to log.
Kubernetes
The compose stack runs every example except the Kubernetes ones. Those move the same patterns to minikube with Strimzi for Kafka, CloudNativePG for PostgreSQL and the same LGTM image, with their own setup, tool versions and commands. No cluster is needed for the compose examples. Stop the compose stack before you start a cluster.
Common pitfalls
- Skipping the docker group step forces every compose command through sudo, which changes file ownership in mounted volumes and breaks later runs.
- Starting a second stack, or a minikube node, while the compose stack is still up fails to bind the fixed host ports, because stack-guard.sh refuses to start rather than letting anything crash.
- Forgetting to pull the local model before running its example leaves the service with no volume to mount, because the example never downloads it itself.
- Letting every container claim its full memory limit at once leaves too little headroom for Grafana and Kafka, so health checks fail even though every image pulled and started.