可扩展、事件驱动的咖啡店

可扩展、事件驱动和事件源 Java EE 应用程序。「A scalable, event-driven and event-sourced Java EE application」

Github星跟踪图

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"}

主要指标

概览
名称与所有者sdaschner/scalable-coffee-shop
主编程语言Java
编程语言Java (语言数: 2)
平台
许可证Apache License 2.0
所有者活动
创建于2017-01-31 18:52:45
推送于2021-05-29 16:16:51
最后一次提交2018-06-09 08:27:37
发布数0
用户参与
星数406
关注者数50
派生数187
提交数27
已启用问题?
问题数3
打开的问题数1
拉请求数1
打开的拉请求数3
关闭的拉请求数0
项目设置
已启用Wiki?
已存档?
是复刻?
已锁定?
是镜像?
是私有?