This directory contains a set of demo around reactive in Quarkus with Kafka. It demonstrates the elasticity and resilience of the system.
mvn clean package
Install Kafka locally for the Kafka tools e.g.
brew install kafka
Run Kafka with:
docker-compose up
In case of previous run, you can clean the state with
docker-compose down
docker-compose rm
Then, create the orders
topic with ./create-topics.sh
You need to run:
- the coffee shop service
- the HTTP barista
- the Kafka barista
Im 3 terminals:
cd coffeeshop-service
mvn compile quarkus:dev
cd barista-http
java -jar target/barista-http-1.0-SNAPSHOT-runner.jar
cd barista-kafka
mvn compile quarkus:dev
The first part of the demo shows HTTP interactions:
- Barista code:
me.escoffier.quarkus.coffeeshop.BaristaResource
- CoffeeShop code:
me.escoffier.quarkus.coffeeshop.CoffeeShopResource.http
- Generated client:
me.escoffier.quarkus.coffeeshop.http.BaristaService
Order coffees by opening http://localhost:8080
. Select the HTTP method.
Stop the HTTP Barista, you can't order coffee anymore.
-
Barista code:
me.escoffier.quarkus.coffeeshop.KafkaBarista
: Read fromorders
, write toqueue
-
Bridge in the CoffeeShop:
me.escoffier.quarkus.coffeeshop.messaging.CoffeeShopResource#messaging
just enqueue the orders in a single thread (one counter) -
Get prepared beverages on
me.escoffier.quarkus.coffeeshop.dashboard.BoardResource
and send to SSE -
Open browser to http://localhost:8080/
-
Order coffee with Order coffees by opening
http://localhost:8080
. Select the HTTP method. Select the messaging method.
- Stop the Kafka barista
- Continue to enqueue order
- On the dashboard, the orders are in the "IN QUEUE" state
- Restart the barista
- They are processed
- Start a second barista with:
./barista-kafka/target/barista-kafka-1.0-SNAPSHOT-runner -Dquarkus.http.port=9999
- Order more coffee
The dashboard shows that the load is dispatched among the baristas.