Examples

One runnable project per pattern.

Every example is a Quarkus application with Camel routes, its own compose file, a Containerfile on UBI 10 and a verify.sh that proves the behaviour against the real stack. Start the stack from the repository root and run an example from its directory.

./scripts/setup-stack.sh up
cd examples/00-stack-check
./verify.sh
  1. 0 Stack check A Quarkus and Camel service that publishes an Order to Kafka and sends traces, metrics and logs to LGTM, with a script that checks every service in the stack.
  2. 1 CRUD versus events One ChangeOrderStatus command applied as a row update and as an appended event, with replay, history and an append-only guard.
  3. 2 Event notification OrderPlaced names the order; notification-service fetches the facts from order-service, survives its absence and reads current state.
  4. 3 Event-carried state transfer and claim check OrderPlaced and OrderCancelled carry the whole Order, notification-service keeps a local copy, and a large attachment travels as a claim.
  5. 4 Ordering and partitioning One order's shipment events keyed three ways, a paused consumer replica, and a per-order buffer that restores the lifecycle.
  6. 5 Optimizing publishers Three Camel publish routes with different producer settings, a flash-sale load driver and Kafka client metrics in Prometheus.
  7. 6 Optimizing subscribers A notification service draining a seeded backlog under different Kafka consumer settings, with client metrics, lag and rebalances observed.
  8. 7 Queues for Kafka Thirty notification jobs, one slow email, four workers: delivered through a share group and through a consumer group.
  9. 8 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.
  10. 9 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.
  11. 10 Managing connector offsets One Debezium connector on a legacy inventory table: stopped, altered forward and backward, reset, and recovered from a dropped and a lost replication slot.
  12. 11 Idempotent consumer and inbox Stock reserved once per event id: an inbox row in the effect's transaction, with a duplicate record, a crash before the acknowledgement and Camel's Idempotent Consumer as comparisons.
  13. 12 Exactly-once with Kafka transactions A read-process-write loop whose output records and input offsets commit in one Kafka transaction, with a crash in the middle of a batch and a Camel transacted route as comparisons.
  14. 13 Retry and dead letter A consumer that retries a locked row, dead-letters records that can never succeed with their original bytes, and the same inputs through a Camel route.
  15. 14 Aggregate root and the event store An order kept only as its own event stream: one aggregate that decides every command, appends at the version it loaded, decides again when it loses a race, and publishes OrderPlaced and OrderCancelled through the outbox.
  16. 15 Snapshots A stock ledger of 100,000 events loaded from a snapshot plus the events after it, written in the command's transaction, and the same snapshots taken by a Camel route on a timer.
  17. 16 CQRS and projections An order-status read model built from six public topics: one guarded upsert per event, a view that says how current it is, a paused topic that leaves it visibly stale, and the same view built by a Camel route.
  18. 17 Aggregate replay or CQRS projection Orders shipped per carrier per day answered two ways from one event store: a replay of every aggregate, and a projection with a checkpoint that waits for open transactions.
  19. 18 Schema evolution and upcasting An order event store that upcasts rows of an earlier shape when it reads them, an Avro OrderPlaced published through the outbox under a registry compatibility rule, and a notification consumer that reads every release through SmallRye and Camel.
  20. 19 Enrich ShipmentScheduled enriched with the carrier's mode and tracking link twice over: a Camel Content Enricher that calls shipping-service per record, and a Kafka Streams left join against a local copy of a compacted topic.
  21. 20 Join Two events joined by order id two ways on the same input: a Kafka Streams windowed left join in event time and a Camel aggregator in arrival time, with two crafted pairs where they disagree, an unpaid reservation, and state that survives a recreate.
  22. 21 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.
  23. 22 Saga An order choreographed over Kafka by three services with no coordinator: the saga state in order-service, a compensation that is idempotent and commutative, a sweeper for silent participants, and a semantic lock that refuses a late payment.
  24. 23 Orchestrated sagas: Camel Saga and Quarkus Flow One order-service that runs the same order saga under a Camel Saga with an LRA coordinator and under a Quarkus Flow workflow, over the same inventory and payment participants, with a payment service that stops answering.
  25. 24 Decisions on events One shipping-service that reads a carrier's free-text delivery-exception note, has a local model return a reason from a closed set, decides RESHIP or REFUND with a Drools rule unit, records both results, and replays the decisions from the record with no model call.
  26. 25 Tracing across async hops One order as one trace from POST /orders through the outbox, Debezium in Connect and a SmallRye consumer, with a span-link form beside it and a search by order id in Tempo.
  27. 26 Metrics for event flows An order service and an inventory service on one topic, with the outbox backlog, group lag at the broker, event age and dead letters measured where each can be seen, a provisioned Grafana dashboard and one provisioned alert.
  28. 27 Correlated logs and traces An order saga over three services with the order id on every span and in the log context of every handler, the trace id on every log line, and the sweeper's trace for a timed-out order linked to the trace that placed it, followed through Tempo and Loki.
  29. 28 Strimzi and KRaft Kafka as two KRaft node pools under the Strimzi operator on minikube, with the order, notification, event-carried-state and ordering services run against it one set after another, unchanged.
  30. 29 Unidirectional Topic Operator The nine topics of the event catalog as KafkaTopic resources on a Kafka cluster with auto-creation off, with the Topic Operator's reconciliation of drift, deletion, unmanaged topics and topics created outside Kubernetes checked against the cluster.
  31. 30 Server-side apply The `order-service` and `notification-service` deployed by one field manager and patched by a second, the CloudNativePG install applied both ways, and a foreign annotation on a Strimzi Service, with every owner read back from managedFields.
  32. 31 Security context and pod security Two namespaces that enforce the restricted Pod Security Standard, with the `order-service` and `notification-service` carrying an explicit security context, Strimzi on its restricted provider, CloudNativePG as published and otel-lgtm outside the rule.
  33. 32 Monitoring Strimzi Kafka on Strimzi with the Metrics Reporter on brokers and controllers, the operator's own metrics and kube-state-metrics for resource state, all scraped by the otel-lgtm collector, with a provisioned dashboard and checks that read each signal from Prometheus.
  34. 33 Cruise Control: rebalancing A Kafka cluster of two brokers with Cruise Control, grown to three nodes and rebalanced by an approved KafkaRebalance, then grown to four and shrunk back with autoRebalance, with the replica placement read back from Kafka at every step.
  35. 34 MirrorMaker 2 A second Kafka cluster beside the first, a MirrorMaker 2 that copies the event catalog's topics and the consumer group offsets from one to the other, and a consumer that fails over by changing its bootstrap address and resumes from the translated offset.
  36. 35 Debezium and Connect on Strimzi A Connect image built from a KafkaConnect resource into a registry inside the cluster, the outbox and inventory connectors as KafkaConnector resources on CloudNativePG, and the inventory connector's offsets listed, refused, altered and resumed through the resource.
  37. 36 Appendix A: Testing event-driven code One notification route tested against a real Kafka from Dev Services, with its HTTP source stubbed by the test application, an AdviceWith route test, first-match and drain assertions, and a harness that proves each guard by running altered copies.
  38. 37 Appendix B: Compose to Kubernetes The effective settings of Kafka and PostgreSQL read from a fresh compose stack and from fresh Kubernetes namespaces, compared against a list of expected differences.
  39. 38 Appendix C: Querying streams without ksqlDB Deliveries per carrier per minute of event time from one topic, answered by Kafka Streams interactive queries, a Flink SQL job and RisingWave materialized views, with one lateness bound in all three.
  40. 40 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.
  41. 41 Deploying event-driven services on minikube The event notification service and the order service, unchanged, replaced by a stop and restart, a rolling update, a schema change and a blue-green cut-over under a producer that numbers every record.
  42. 42 Appendix G: Write-forward cache An order and its full-state event in one transaction, carried to Kafka by Debezium and applied to Redis by a Camel route behind a version guard, with the dual write and a guardless replay as comparisons.
  43. 43 Appendix H: OpenShift Local The outbox order-service, Strimzi and CloudNativePG on OpenShift Local: operators at pinned versions, an image built with buildah and copied with skopeo, an order that reaches Kafka through a verified Route, and a teardown that leaves nothing behind.
  44. 44 Batch processing with Kueue An end-of-day delivery reconciliation per carrier, run as three Kubernetes Jobs admitted by Kueue, with a failed partition replayed alone and a low-priority run preempted by a high-priority one.

Source for every example: examples/ on GitHub โ†—