Overview

Basics

This application can be run locally or deployed to Kubernetes/OpenShift. Running the demo locally requires Docker and Java

Running Locally (on your laptop)

NOTE: Docker and Java are required to run the demo locally

To run locally:

Step 1: Clone the Repositories

To run the complete coffeeshop demo locally you will need to clone:

git clone https://github.com/quarkuscoffeeshop/quarkuscoffeeshop-support.git
git clone https://github.com/quarkuscoffeeshop/quarkuscoffeeshop-counter.git
git clone https://github.com/quarkuscoffeeshop/quarkuscoffeeshop-barista.git
git clone https://github.com/quarkuscoffeeshop/quarkuscoffeeshop-kitchen.git
git clone https://github.com/quarkuscoffeeshop/quarkuscoffeeshop-web.git

Step 2: Fire up Kafka and PostgreSQL (with Docker Compose)

quarkuscoffeeshop-support contains a Docker Compose file that will spin up Kafka and PostgreSQL. This will need to be started before the microservices

From inside the quarkuscoffeeshop-support directory run:

docker compose up

Step 3: Start the Microservices

Once the environment variables are set the services can be started with:

./mvnw clean compile quarkus:dev

This command will have to be run from within each directory.

NOTE: If you want to step debug through the code you will need to tell each service to listen on a different port. Since 5005 is the default you will have to increment this number for each service:

./mvnw clean compile quarkus:dev -Ddebug=5006
./mvnw clean compile quarkus:dev -Ddebug=5007

You should be up and running!

Running in OpenShift

The application can be deployed to OpenShift with Ansible. Please see DevOps for instructions.

There is no need to build the microservices locally to run them in OpenShift because they are already deployed to Red Hat Quay.

What’s in the Demo

This demo models an individual coffeeshop where users can order drinks and food and view the status of their order.

The demo illustrates the general concepts of Event Driven Architecture, Domain Driven Design, and Event Sourcing. The demo also specifically illustrates using Kafka with Quarkus and Debezium with Quarkus.

If you are running locally:

  1. Open http://localhost:8080
  2. Choose a beverage and/or baked goods
  3. Watch as your order status is updated

What happens behind the scenes

Web Microservice

  1. The web page posts your order as JSON to a REST endpoint
  2. The REST endpoint creates a PlaceOrderCommand object and sends that object in JSON format to a Kafka topic named “orders-in”
  3. The application listens to a Kafka topic, “web-updates,” and when a message is received it is marshalled into JSON and sent to the web front end using server sent events

Counter Microservice

  1. The counter microservice listens on the Kafka topic, “orders-in,” and receives the order from the web
  2. The counter microservice creates value objects for the barista and kitchen microservices and sends them to the appropriate Kafka topics
  3. The counter microservice persists the Order to the PostgreSQL database
  4. The counter microservice persists an OrderCreatedEvent
  5. The counter microservice lists on the “orders-up” topic, and receives messages from the barista and kitchen microservices
  6. The counter microservices updates and persists the Order
  7. The counter microservice creates and persists an OrderUpdatedEvent and OrderCompletedEvent (when all of the orders’ line items are fulfilled)
  8. The counter microservice creates a web update value object and places it on the “web-updates” Kafka topic

Barista and Kitchen Microservices

  1. The barista and kitchen microservices listen to the “barista-in” and “kitchen-in” Kafka topics
  2. When an order comes in they apply the logic for making an order
  3. When the order is ready they send an update to the “orders-up” Kafka topic