Event notification
OrderPlaced names the order; notification-service fetches the facts from order-service, survives its absence and reads current state.
Chapter 2
examples/02-event-notification/ runs two services. order-service publishes OrderPlaced with only the order id. notification-service consumes it, fetches the order over HTTP and stores a Notification. It accompanies Event notification.
It uses Quarkus REST, Hibernate ORM with Panache, Flyway, PostgreSQL, Camel on Quarkus (Kafka and http) and OpenTelemetry to the LGTM stack.
(cd examples/domain-model && mvn -B -q install)
cd examples/02-event-notification
mvn -B verify
./verify.sh
What to observe
- The record carries only the id. The record on
edp.orders.placedhas the order id as its key andeventId,occurredAtandorderIdas its value. - The notification holds fetched facts.
GET /notifications?orderId=on port 8082 returns the customer, amount and status read from order-service. - One trace spans both services. Grafana at
http://localhost:3000shows one trace holding thePOST /ordersrequest in order-service and the consume and the fetch innotification-service. Metrics from both services reach Prometheus. - A missing source holds the record. With order-service stopped, no notification appears and the groupβs offset stays where it was. When order-service returns, the notification appears.
- The fetch reads current state. An order cancelled before notification-service reads the event shows CANCELLED in its notification.
Infrastructure
Kafka, PostgreSQL and the LGTM stack from examples/_infra, plus two application containers built from UBI 10 Containerfiles. The compose project is edp-02.