GithubHelp home page GithubHelp logo

sunxboy / scalable-coffee-shop Goto Github PK

View Code? Open in Web Editor NEW

This project forked from sdaschner/scalable-coffee-shop

0.0 2.0 0.0 144 KB

scalable-coffee-shop是基于JavaEE容器下结合Kafka的事件驱动实现项目,巧妙地利用了JavaEE容器的异步机制与Kafka的发布订阅模式相结合,通过Kafka的消息事务机制实现了精确一致性的消息传递,可靠地在各个模块或微服务之间实现了事件传递和业务流程的实现。 scalable-coffee-shop分为订单模块,咖啡豆模块和制作模块

License: Apache License 2.0

Dockerfile 0.20% Shell 0.41% Java 99.39%

scalable-coffee-shop's Introduction

Scalable, event-driven coffee shop

How to use event sourcing in several services with an event-driven architecture, Apache Kafka and Java EE.

Run

  1. Start Apache Kafka brokers, e.g. using Docker compose: wurstmeister/kafka-docker. Configure the KAFKA_ADVERTISED_HOST_NAME to your corresponding IP address.

  2. Configure each of the kafka.properties files with bootstrap.servers=<your-IP>:9092.

  3. Build and run the individual instances. On each of the orders/, beans/ and barista/ directories, execute build-run-local.sh. This builds the Gradle project, builds the Docker image and starts a new instance of the given service.

Usage

The following will demonstrate the usage of the HTTP endpoints and example responses.

  1. In order to create coffee orders you have to add beans to the beans storage first:

$> curl http://localhost:8002/beans/resources/beans -i -XPOST \
  -H 'content-type: application/json' \
  -d '{"beanOrigin": "Colombia", "amount": 10}'

HTTP/1.1 204 No Content
X-Powered-By: Undertow/1
Server: WildFly/10
Date: Fri, 17 Nov 2017 20:49:26 GMT
  1. Check the creation of the beans:

$> curl http://localhost:8002/beans/resources/beans

{"Colombia":10}
  1. Create a new coffee order:

$> curl http://localhost:8001/orders/resources/orders/ -i -XPOST \
  -H 'Content-type: application/json' \
  -d '{"beanOrigin": "Colombia", "coffeeType": "Espresso"}'

HTTP/1.1 202 Accepted
Connection: keep-alive
X-Powered-By: Undertow/1
Server: WildFly/10
Location: http://localhost:8001/orders/resources/orders/c099c158-b748-4115-bed3-7b5dfff70771
Content-Length: 0
Date: Fri, 17 Nov 2017 20:51:16 GMT
  1. Check the creation of the coffee order using your Location header, for example:

$> curl http://localhost:8001/orders/resources/orders/c099c158-b748-4115-bed3-7b5dfff70771

{"status":"started","type":"espresso","beanOrigin":"Colombia"}

scalable-coffee-shop's People

Contributors

sdaschner avatar aalmiray 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.