jackeybill / eventuate-examples-java-customers-and-orders

Java version of the Customers and Orders event sourcing example from my presentations

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

This is the Java version of the customers and orders example that I've used in numerous presentations on developing microservices with event sourcing and CQRS. The code is built using the Eventuate platform. It illustrates how to implement an eventually consistent credit limit check using event sourcing. For more information, see this presentation from Gluecon 2016

About Eventuateā„¢

The application is built using Eventuate, which is an application platform for writing transactional microservices. It provides a simple yet powerful event-driven programming model that is based on event sourcing and Command Query Responsibility Segregation (CQRS). Eventuate solves the distributed data management problems inherent in a microservice architecture. It consists of a scalable, distributed event store and client libraries for various languages and frameworks including Java, Scala, and the Spring framework.

There are two versions of Eventuate:

Building and running the application.

This is a Java 8, Gradle project. However, you do not need to install Gradle since it will be downloaded automatically. You just need to have Java 8 installed.

The details of how to build and run the services depend slightly on whether you are using Eventuate SaaS or Eventuate Local.

Building and running using Eventuate SaaS

First, must sign up to get your credentials in order to get free access to the SaaS version.

Next, build the application:

./gradlew assemble

Next, you can launch the application using Docker Compose

docker-compose up -d

Finally, you can use the Swagger UI provided by the services to create customers and orders, and view the order history:

  • http://${DOCKER_HOST_IP?}:8081/swagger-ui.html - Create a customer
  • http://${DOCKER_HOST_IP?}:8083/swagger-ui.html - Create an order
  • http://${DOCKER_HOST_IP?}:8082/swagger-ui.html - View the customer and the order

(Hint: best to open these URLs in separate tabs)

Note: DOCKER_HOST_IP is the IP address of the machine running the Docker daemon.

Building and running using Eventuate Local

First, build the application:

./gradlew assemble -P eventuateDriver=local

Next, you can launch the application using Docker Compose

export DOCKER_HOST_IP=...
docker-compose -f docker-compose-eventuate-local.yml up -d

Note: You need to set DOCKER_HOST_IP before running Docker Compose. DOCKER_HOST_IP is the IP address of the machine running the Docker daemon. It must be an IP address or resolvable hostname. It cannot be localhost. See this guide to setting DOCKER_HOST_IP for more information.

Finally, you can use the Swagger UI provided by the services to create customers and orders, and view the order history:

  • http://${DOCKER_HOST_IP?}:8081/swagger-ui.html - Create a customer
  • http://${DOCKER_HOST_IP?}:8083/swagger-ui.html - Create an order
  • http://${DOCKER_HOST_IP?}:8082/swagger-ui.html - View the customer and the order

(Hint: best to open these URLs in separate tabs)

About

Java version of the Customers and Orders event sourcing example from my presentations


Languages

Language:Java 88.3%Language:Shell 9.5%Language:Groovy 2.2%