GithubHelp home page GithubHelp logo

lholmquist / reactive-coffeeshop-demo Goto Github PK

View Code? Open in Web Editor NEW

This project forked from cescoffier/reactive-coffeeshop-demo

0.0 2.0 0.0 214 KB

Quarkus, Kafka and Reactive are ordering coffee

License: Apache License 2.0

Java 59.87% HTML 21.43% Shell 8.34% JavaScript 10.36%

reactive-coffeeshop-demo's Introduction

Coffeeshop Demo with Quarkus

This directory contains a set of demo around reactive in Quarkus with Kafka. It demonstrates the elasticity and resilience of the system.

Build

Install java dependencies (java 11 and Maven are required)

mvn clean package

Install node.js dependencies (node.js is required)

cd barista-node-kafka/ && npm install

Prerequisites

Install Docker.

If you are not using a desktop system, install Docker Compose.

Install Kafka locally for the Kafka tools e.g.

brew install kafka

or on Linux

  • install recent kafka from kafka binaries and ensure the bin directory is in your path.

  • edit create-topics.sh and replace all instances of kafka-topics with kafka-topics.sh

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

Run the demo

You need to run:

  • the coffee shop service
  • one or more of the the HTTP, Quarkus Kafka or Node.js Kafka baristas

In 3 or more terminals:

cd coffeeshop-service
mvn compile quarkus:dev

HTTP barista

cd barista-quarkus-http
java -jar target/barista-http-1.0-SNAPSHOT-runner.jar

Quarkus Barista

cd barista-quarkus-kafka
mvn compile quarkus:dev

Node.js Barista

cd barista-node-kafka
npm start

Execute with HTTP

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.

Execute with Kafka

  • Barista code: me.escoffier.quarkus.coffeeshop.KafkaBarista: Read from orders, write to queue

  • 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 messaging method.

Baristas do breaks

  1. Stop the Kafka barista(s)
  2. Continue to enqueue order
  3. On the dashboard, the orders are in the "IN QUEUE" state
  4. Restart the barista
  5. They are processed

2 or more baristas are better

Quarkus

  1. Build barista-quarkus-kafka with native image:
    mvn package -Pnative
  2. Start a second barista with:
    ./barista-quarkus-kafka/target/barista-kafka-1.0-SNAPSHOT-runner -Dquarkus.http.port=9999
  3. Order more coffee

Node.js

  1. Open a new terminal and run npm start again.

The dashboard shows that the load is dispatched among the baristas.

reactive-coffeeshop-demo's People

Contributors

cescoffier avatar kenfinnigan avatar aalykiot avatar emmanuelbernard avatar tqvarnst avatar dependabot[bot] avatar xstefank avatar mhdawson avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.