Java version of the Customers and Orders event sourcing example from my presentations
Switch branches/tags
Nothing to show
Clone or download
Permalink
Failed to load latest commit information.
.circleci Fixed CircleCI config Apr 10, 2018
buildSrc/src/main/groovy Removed old CDC dependency from services Apr 13, 2018
common-contracts CircleCI2 config Dec 6, 2017
common-swagger Improved instructions, upgraded to latest client, fixed Swagger misco… Sep 17, 2016
common-test Increased timeout Apr 13, 2018
common Improved unit tests Jun 27, 2017
customers-common Significant improvements to tests including Spring Cloud Contract-bas… Jun 29, 2017
customers-service Removed old CDC dependency from services Apr 13, 2018
e2e-test cleaned up tests Apr 13, 2018
gradle/wrapper Significant improvements to tests including Spring Cloud Contract-bas… Jun 29, 2017
orders-common Improved unit tests Jun 27, 2017
orders-history-common Improved unit tests Jun 27, 2017
orders-history-view-service Increased timeout Apr 13, 2018
orders-service Removed old CDC dependency from services Apr 13, 2018
.gitignore More tests, Upgraded to latest Eventuate version Oct 14, 2017
README.md Revised README to specify MySQL binlog vs. Postgres WAL Apr 16, 2018
_build-and-test-all.sh Removed old CDC dependency from services Apr 13, 2018
build-and-test-all-eventuate-local-mysql.sh Adding polling and postgre wal support. Apr 9, 2018
build-and-test-all-eventuate-local-postgres-polling.sh Adding polling and postgre wal support. Apr 9, 2018
build-and-test-all-eventuate-local-postgres-wal.sh Adding polling and postgre wal support. Apr 9, 2018
build-and-test-all.sh Significant improvements to tests including Spring Cloud Contract-bas… Jun 29, 2017
build-and-test-docker-stacks.sh Upgraded docker-compose-*.yml files and added support for Docker Stac… Jul 31, 2017
build-and-test-everything.sh Refactoring. Apr 9, 2018
build.gradle cleaned up tests Apr 13, 2018
compile-contracts.sh Revised CircleCI config Apr 10, 2018
docker-compose-eventuate-local-mysql.yml Removed old CDC dependency from services Apr 13, 2018
docker-compose-eventuate-local-postgres-polling.yml Refactoring. Apr 9, 2018
docker-compose-eventuate-local-postgres-wal.yml Refactoring. Apr 9, 2018
docker-compose.yml Upgraded docker-compose-*.yml files and added support for Docker Stac… Jul 31, 2017
docker-stack-eventuate-local.yml Updating docker images. Mar 6, 2018
docker-stack.yml Upgraded docker-compose-*.yml files and added support for Docker Stac… Jul 31, 2017
gradle.properties Adding polling and postgre wal support. Apr 9, 2018
gradlew Initial version Jun 23, 2016
gradlew.bat Initial version Jun 23, 2016
mongodb-cli.sh cleaned up tests Apr 13, 2018
mysql-cli.sh cleaned up tests Apr 13, 2018
set-env-eventuate-local-mysql.sh Adding polling and postgre wal support. Apr 9, 2018
set-env-eventuate-local-postgres-polling.sh Adding polling and postgre wal support. Apr 9, 2018
set-env-eventuate-local-postgres-wal.sh Adding polling and postgre wal support. Apr 9, 2018
set-env.sh Significant improvements to tests including Spring Cloud Contract-bas… Jun 29, 2017
setenv-circle-ci.sh Fixed CircleCI config Apr 10, 2018
settings.gradle Significant improvements to tests including Spring Cloud Contract-bas… Jun 29, 2017
show-urls.sh Added show-urls.sh script Dec 6, 2017
wait-for-services.sh Fixed bug in ./wait-for-services.sh Jan 1, 2017

README.md

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-<db-type>.yml up -d

Where db-type is one of:

  • mysql - use MySQL with Binlog-based event publishing
  • postgres-wal - use Postgres with Postgres WAL-based event publishing
  • postgres-polling - use Postgres with generic JDBC polling-based event publishing

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)

The script ./show-urls.sh will display the URLs.

Deploying using Docker Stack/Swarm

You can also deploy the application using Docker Stack/Swarm mode.

Eventuate SaaS version:

./gradlew assemble
docker-compose build
docker stack deploy -c docker-stack.yml customers-and-orders

Eventuate Local version:

./gradlew assemble -P eventuateDriver=local
docker-compose -f docker-compose-eventuate-local.yml build
docker stack deploy -c docker-stack-eventuate-local-<db-type>.yml customers-and-orders