Giter VIP home page Giter VIP logo

springbootcqrseventsourcingreference's Introduction

Cloud-Native Reference

This is a reference implementation for a cloud-native architecture. The microservice architectural style is used with the following design patterns:

  • Command Query Responsibility Separation (CQRS).
  • Event Sourcing
  • Gateway Router
  • Circuit-Breaker
  • External Configuration Service
  • Throttling

The following technologies are used:

  • Spring Cloud
  • Netflix OSS
  • Axon Framework

Prerequisites

This reference implementation can be run through a series of Docker containers. The following software is required to build and execute the code.

  • Java 8 SDK
  • Docker
  • Docker-Compose
  • Gradle

The code was developed and tested with the Spring Tool Suite IDE running on MacOS 10.12.6 Sierra. A machine with at least 8GB is required to run all the containers concurrently.

Running this Reference Implementation

1. Build the Docker Containers

Clone the Git repository to a directory

git clone https://github.com/drm317/cloud-native-reference.git

Then build the code and all the required Docker container images

cd cloud-native-reference
./gradlew clean image

2. Start the System

There are several Docker containers that compose the reference system.

  • mongodb - MongoDB NoSQL database service for the Axon Framework event store
  • rabbitmq - RabbitMQ service for Axon Framework event messaging
  • configuration-service - Spring Cloud external configuration service
  • service-registry - Spring Cloud service registry and discovery service
  • gateway-service - Spring Boot gateway service with a Netflix OSS Zuul router and Hystrix circuit breaker
  • order-service - Spring Boot CQRS command service for creating (domain) orders
  • order-query-service - Spring Boot CQRS query service for querying (domain) orders
  • admin-service - Spring Cloud Admin Service for service monitoring
  • hystrix-dashboard-service - Netflix OSS Hystrix dashboard service

Issue the following commands in order in separate terminal windows. Check that each service is started within its container before proceeding to the next container.

docker-compose up mongodb
docker-compose up rabbitmq
docker-compose up configuration-service
docker-compose up service-registry
docker-compose up gateway-service
docker-compose up order-service
docker-compose up order-query-service
docker-compose up admin-service
docker-compose up hystrix-dashboard-service

3. Execute the Integration Tests

The integration tests include an end-to-end test and system health check. They require the mongodb, rabbitmq, configuration-service, service-registry, gateway-service, order-service and order-query-service containers to be up and running.

Run the integration tests with the following:

./gradlew integration-test:integrationTest

The architecture makes use of a design pattern called 'Event Sourcing' with 'Eventual Consistency'. There is a delay between each test to allow for event messages to propagate from the command service to the query service. In addition, a demonstration throttling filter in the Gateway Service currently limits traffic to one request every 10 seconds.

4. Clean the Docker Containers

The Docker build artifacts will be stored locally. These can be cleaned up to save disk space

./clean-docker.sh

springbootcqrseventsourcingreference's People

Contributors

drm317 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

longnguyenxuan

springbootcqrseventsourcingreference's Issues

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.