/cqrs-event-driven-architecture

This project is (my TFG), an implementation of the Command Query Responsibility Segregation (CQRS) design pattern in combination with an Event Driven Architecture (EDA), to learn about the benefits and advantages of using both in distributed software applications with significant overhead.

Primary LanguageJava

CQRS pattern over Event Driven Architecture

Technologies:

  • Apache Zookeeper
  • Apache Kafka
  • Mysql
  • MongoDB
  • Docker
  • Docker compose
  • Java 17
  • Spring Boot
  • Maven
  • JUnit
  • Cucumber
  • Jmeter

Maven 3.8.1 JDK 17 Spring Boot Domingo Pérez License MIT

The main propose of this project is test CQRS pattern over Event Sourcing Architecture (EDA). This project consists in two spring boot microservices (device-command, device-query), one to command and other to query operations. Additionally, to run all pieces of project it´s necessary deploy and run docker containers for two MySql and MongoDB databases, Apache Zookeeper and Apache Kafka message broker.

In the next diagram you can look how this project was designed:

diagram

These are all the use cases available to users:

use-case

Requirements 📋

To run this project you need install next requirements:

Installation 🔧

To generate jar files run the following command in root path:

mvn clean package

Run in containers 🐳

Run containers of Zookeeper, Apache Kafka, MySql, MongoDB, Device-command, Device-query.

docker-compose up -d

If you prefer you can stop containers for device-command and query-command then you can launch the Spring Boot microservices with the followings instructions:

Microservice device-command 🚀

Run in terminal the following command:

java -jar device-command/target/device-command-0.0.1-SNAPSHOT.jar.original

Microservice device-query 🚀

In other terminal run the following command:

java -jar device-query/target/device-query-0.0.1-SNAPSHOT.jar.original

OpenAPI definition

device-command

device-query

Swagger UI

device-command

device-command

Running manual test ⚙️

Once all microservice started you can test this service using the postman collection. with name tfg-postman-collection.json in resources folder:

Running unit test 🧪

Then in terminal run:

mvn test

Running performance test 🎯

Previously do you need run the system:

docker-compose up -d

Then in terminal over performance-test path run:

  • first time
mvn clean verify
  • followings:
mvn jmeter:jmeter

Running integration test 🔒

Previously do you need run the system:

docker-compose up -d

Then in terminal over device-command / device-query path run:

mvn clean verify -Dskip.integration.tests=false