Every chapter, in order.
Parts 0 to 5 run on Docker Compose and Part 6 runs on minikube with Strimzi. Read top to bottom the first time; each pattern chapter also stands on its own.
Part 0 Getting started
The shipping domain, the local stack and a first event through Quarkus, Camel, Kafka and the LGTM observability stack.
- 0 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.
- 1 Events, commands and documents Three message types and one storage decision: update an order row in place, or append what happened and rebuild the state from the history.
Part 1 Events between services
Event notification, event-carried state transfer, and the channel and message design that lets services stay independent.
- 2 Event notification An event that says only that an order was placed: how the consumer fetches the facts back from the source, what that costs when the source is down, and why it reads current state.
- 3 Event-carried state transfer and claim check Put the whole order in the event so consumers keep a local copy and answer without the source, then keep the large part out of the event with a claim check.
- 4 Ordering and partitioning Kafka orders records only within a partition. Key an order's events by the order id, and hold events in a per-order buffer when the key cannot change.
- 5 Optimizing publishers How the Kafka producer batches, compresses and acknowledges records, which settings change throughput, and how to measure a publisher from Camel.
- 6 Optimizing subscribers How a Kafka consumer fetches, polls and shares partitions, which settings change drain time and duplicates, and how to measure a subscriber from Camel.
- 7 Queues for Kafka A consumer group gives each partition to one worker, so one slow job holds back the jobs behind it. A share group lets any worker take any record and acknowledge it one at a time.
Part 2 Getting events out reliably
The transactional outbox, Debezium change data capture, idempotent consumers and delivery guarantees.
- 8 Transactional outbox An order and the event that announces it are two writes to two systems. The outbox turns them into one transaction in the database and lets the transaction log carry the event to Kafka.
- 9 Log tailing with Debezium Reading a database's transaction log turns every committed change into an event without touching the application: slots, snapshots, replica identity, tombstones, heartbeats and the embedded engine.
- 10 Managing connector offsets A source connector remembers its place in the database log. Stopping it, reading that place, moving it forward, resetting it and recovering a lost replication slot, with what PostgreSQL does to each.
- 11 Idempotent consumer and inbox Kafka delivers an event at least once, and a decrement is not safe to repeat. The inbox records the event id in the same transaction as the effect, so a duplicate record and a redelivery after a crash change nothing.
- 12 Exactly-once with Kafka transactions A service that reads a record, processes it and writes a result can crash between the write and the offset commit. A Kafka transaction holds the output records and the input offsets together, and a read_committed reader never sees half of it.
- 13 Retry and dead letter A consumer meets three kinds of bad record: one that never parses, one that is never valid and one that fails only while a row is locked. Retry the third, dead-letter the first two, and keep their original bytes.
Part 3 Event sourcing
Events as the system of record: append-only stores, projections, CQRS read models, snapshots and schema evolution.
- 14 Aggregate root and the event store An order is the stream of its own events. One object owns every rule about it, appends at the version it loaded, decides again when it loses a race, and publishes only the events that are public.
- 15 Snapshots A stream that grows without bound makes every load slower. A snapshot is a cache of the fold at one version: load it, replay only the events after it, and rebuild it from the events whenever it is wrong.
- 16 CQRS and projections A reader asks questions the write model was not built for. A projection applies the public events to a table shaped for those questions, moves only forward, and tells the reader how current it is.
- 17 Aggregate replay or CQRS projection Operations asks a question the model was not built for: orders shipped per carrier per day. Replay every aggregate on request, or build a projection from the whole history and keep it current. What each costs, and why a checkpoint must not trust commit order.
- 18 Schema evolution and upcasting Customers can ask for express delivery, and OrderPlaced gains a field. Stored events keep the shape they were written in and are upcast when read; published events change only in ways the schema registry accepts against every earlier version.
Part 4 Processing and coordinating streams
Stateful stream processing, windows and joins, and sagas that coordinate work across services.
- 19 Enrich A shipment event names a carrier and nothing about it, and the customer needs the mode and the tracking link. A Camel Content Enricher asks the owner for every record; a Kafka Streams join reads a local copy of the owner's topic. They differ when the reference changes and when the owner is down.
- 20 Join shipping-service books a carrier only when stock is reserved and payment is taken, two facts on two topics that arrive in either order. A windowed join pairs them by event time; a Camel aggregator pairs them by arrival, and the two disagree.
- 21 Aggregate A carrier collects parcels in pickup slots, and the warehouse needs one list per carrier per slot. Kafka Streams closes a window of event time and emits one final list; the Camel Aggregator closes a batch by size or quiet time in arrival order.
- 22 Saga An order touches three databases and no transaction spans them. A saga is a chain of local transactions, each publishing the event that starts the next, and a failure is undone by new events. Order, stock and payment are choreographed with no coordinator, and the saga handles a declined payment, a service that does not answer and a late reply.
- 23 Orchestrated sagas: Camel Saga and Quarkus Flow An orchestrator holds the sequence of an order saga in one place. The Camel Saga EIP hands the saga to an LRA coordinator that calls each participant's registered compensation; a Quarkus Flow workflow keeps the sequence and its state itself and compensates with tasks.
- 24 Decisions on events A carrier reports an undelivered parcel in a sentence its driver typed, and shipping-service must ship again or refund. A local model turns the sentence into one reason from a closed set; a Drools rule unit decides from the recorded reason; a replay decides again from the record with no model call.
Part 5 Observing event flows
Traces, metrics and logs that follow an event across topics and services, with OpenTelemetry and Grafana LGTM.
- 25 Tracing across async hops An order crosses a commit, a log reader and a topic, and none of them is an HTTP request. The trace context travels in the outbox row and the record header, Connect adds its own spans, and the consumer either continues the trace as a child or starts a new one with a link.
- 26 Metrics for event flows Every service reports healthy while orders wait in a paused relay or behind a stopped consumer. Four signals are read where the work waits: the outbox backlog in the replication slot, group lag at the broker, the age of an event from the time stamped when it happened, and dead letters as a rate. One provisioned alert watches the signal that grows while the flow is stuck.
- 27 Correlated logs and traces An operator holds an order id, and the tools hold trace ids and log lines. The order id goes on every span and in the log context of every handler, the trace id goes on every log line, and a trace that a timer starts links to the trace it continues, so one question finds everything about one order.
Part 6 Running on Kubernetes with Strimzi
Kafka on Kubernetes with the Strimzi operator: the same services deployed to minikube, then monitoring, Cruise Control, MirrorMaker 2 and Kafka Connect as declared resources.
- 28 Strimzi and KRaft A Kafka broker on Kubernetes needs a stable node id, its own volume, addresses that resolve and a controller quorum. Strimzi runs Kafka from a Kafka resource and two node pools, one for controllers and one for brokers, and the order and notification services run against it with only their addresses changed.
- 29 Unidirectional Topic Operator A broker that creates topics on first use turns a typo into a new topic and leaves partitions and retention to whatever the defaults were. Every topic of the event catalog is declared as a KafkaTopic, auto-creation is off, and the Topic Operator reconciles in one direction only: from the resource to Kafka.
- 30 Server-side apply Two tools write the same Deployment and a client-side apply silently keeps the last one. Server-side apply records an owner for every field, refuses a second writer until it forces the change, and installs manifests whose CRDs are too large for an annotation. Strimzi applies its own resources the same way, so a foreign annotation stays and an owned field returns.
- 31 Security context and pod security A cluster admits any pod unless a rule says otherwise. Labelling a namespace with the restricted Pod Security Standard makes the API server refuse pods that can escalate privileges or run as root. The applications carry the four required fields, Strimzi gets the restricted pod security provider, CloudNativePG is admitted as published, and otel-lgtm stays in a namespace of its own.
- 32 Monitoring Strimzi A Kafka cluster that an operator runs hides its JVMs behind resources. Brokers and controllers report through the Strimzi Metrics Reporter, the operator reports its own reconciliations, kube-state-metrics turns the status of each resource into a series, and one collector feeds them all to the Prometheus that already holds the application telemetry.
- 33 Cruise Control: rebalancing Kafka places a partition when it is created and never moves it, so a broker added to a busy cluster stays empty and a broker that holds replicas cannot be removed. Cruise Control computes a plan from the load, a KafkaRebalance holds it until it is approved, and autoRebalance lets the operator ask and approve when a node pool grows or shrinks.
- 34 MirrorMaker 2 A second cluster with the same topics is of no use to a consumer that does not know where to resume. MirrorMaker 2 copies the topics under their own names and translates each consumer group's committed offsets into the second cluster, so a consumer fails over by changing its bootstrap address.
- 35 Debezium and Connect on Strimzi On a plain Docker setup a connector is a JSON file somebody PUTs to a REST API, its plugin is whatever the running image holds and an offset change is a curl. On Strimzi the Connect image is built from a resource, each connector is a resource and an offset operation is an annotation on it.
Appendices Appendices
Testing, compose to Kubernetes, querying streams, a pattern map and glossary, resequencing in depth, deploying event-driven services, a write-forward cache, an outbox on OpenShift Local, and batch processing with Kueue.
- A Appendix A: Testing event-driven code Event-driven code fails by doing too much, too little or in the wrong order, and a test that only waits for the first record sees none of that. Real brokers from Dev Services, a check proved by breaking the code it guards, topic assertions that wait out the window, ordering and concurrency tests, Camel route tests with AdviceWith, registry contracts and end-to-end checks.
- B Appendix B: Compose to Kubernetes A compose file and a set of Kubernetes resources describe the same Kafka and PostgreSQL in two vocabularies, and the settings a service silently relied on can be lost in the move. Where each setting lives in the Kafka resource and the CloudNativePG Cluster, and how a comparison of the running systems finds what differs.
- C Appendix C: Querying streams without ksqlDB Operations wants deliveries per carrier per minute of event time. Three open source engines answer it from one topic: an interactive query on a Kafka Streams window store, a Flink SQL job that writes closed windows to a topic, and RisingWave materialized views read with psql.
- D Appendix D: Pattern map, glossary and EIP Camel cross-reference Every pattern of the book on one map by part, the terms the chapters use in a short glossary, and where Enterprise Integration Patterns with Camel covers the same pattern, by chapter and by event.
- E Appendix E: Resequencing across partitions in depth A per-order buffer in PostgreSQL works because an order's events share a key and a database row. When several producers and topics carry one order, only a sequence that spans all of them can restore order, and the Camel Resequencer holds its records in memory.
- F Appendix F: Deploying event-driven services on minikube A deployment stops consumers that own partitions. A stop and restart delays records, a rolling update repeats some, a breaking schema change loses them silently, and a blue-green cut-over needs the old group's offsets. Each is run on minikube under a producer that numbers every record.
- G Appendix G: Write-forward cache with an outbox and CDC A cache that the request writes cannot commit with the database. A cache that only the events write can lag but never invent an order. The order and its event commit together, Debezium carries the event out, and a route applies it to Redis behind a version guard.
- H Appendix H: OpenShift Local The outbox order-service, Strimzi and CloudNativePG on a single-node OpenShift cluster on the workstation. The code is the code from Docker Compose and minikube; what changes is how operators arrive, how the image gets in and who the pod runs as.
- I Appendix I: Batch processing with Kueue A batch has an input that ends and a moment when it is done. Each step runs as a Kubernetes Job, the partition is the unit of parallel work, a failed partition is replayed alone, and Kueue decides which Jobs may start. Run on minikube with a Process Manager in Quarkus and Camel.
- J Appendix J: Operating and testing an AI step A model call is expensive and its answer is not guaranteed the same twice. Memoize each answer in a committed row keyed by the note so a redelivery reuses it, keep CI deterministic with a mocked model on Dev Services while a live harness exercises the real one, and re-derive recorded analyses when the model pin or prompt version changes without replaying the corpus through the model.