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.
Chapter 3
examples/03-event-carried-state-transfer/ has two services. order-service publishes the whole Order with each event; notification-service upserts notifications.order_copy and answers from it. It accompanies Event-carried state transfer and claim check.
It uses Quarkus REST, Hibernate ORM with Panache, Flyway, Camel Kafka and OpenTelemetry to the LGTM stack.
(cd examples/domain-model && mvn -B -q install)
cd examples/03-event-carried-state-transfer
mvn -B verify
./verify.sh
What to observe
- The copy answers on its own. Stop order-service;
GET /order-copies/{id}on port 8082 still returns 200 with every Order field. - A cancellation is state too. The copy of a cancelled order shows CANCELLED.
- Nobody asked the source. Prometheus has no
GET /orders/{id}series for order-service, and Tempo has no HTTP client span from notification-service. - A thin event gives nothing to copy. With
ORDER_EVENTS_CARRY_STATE=falsethe consumer logs the event as skipped and the copy answers 404. - A large attachment travels as a claim. The event is under 1 KB;
GET /order-copies/{id}/attachmentfetches the 100 KB content from order-service on demand. - The producer refuses an oversized event. With
ORDER_EVENTS_ATTACHMENT=inlinethe same attachment makes the POST return 502 and nothing reaches the topic.
Infrastructure
Kafka, PostgreSQL and the LGTM stack from examples/_infra, plus two application containers built from UBI 10 Containerfiles. The compose project is edp-03.