This project is a maven module project with Spring Boot application that leverages Axon Framework, RabbitMQ, and PostgreSQL. It is built following Domain-Driven Design (DDD) and Command Query Responsibility Segregation (CQRS) principles, with PostgreSQL serving as the event store.
- Overview
- Prerequisites
- Installation and Execution
- Eureka Server
- API Requests via Gateway
- Project Structure
- Stopping the Servers
- Notes
- License
The Spring Axon RabbitMQ Starter project demonstrates a microservices architecture by combining:
- Axon Framework for CQRS and Event Sourcing
- RabbitMQ for event-driven messaging
- PostgreSQL as both the primary database and the event store
- Eureka for service discovery
- Spring Cloud Config Server for centralized configuration
- Spring Cloud Gateway for API routing
- See
Image created by draw.io
Before running the application, ensure you have installed:
git clone https://github.com/coundia/spring-microservices-starter.git
Run the following command to start the Docker containers:
docker compose -f docker/main.yml up -d
or
task serve
You can start all applications using the provided Taskfile:
task start
Alternatively, start each service manually:
cd cloud-config-server && mvn spring-boot:run > ../cloud-config-server.log 2>&1 &
cd eureka && mvn spring-boot:run > ../eureka.log 2>&1 &
cd gateway-server && mvn spring-boot:run > ../gateway-server.log 2>&1 &
cd products-command && mvn spring-boot:run > ../products-command.log 2>&1 &
cd products-query && mvn spring-boot:run > ../products-query.log 2>&1 &
The Eureka server dashboard is available at:
http://localhost:8761/
Example dashboard:
- Method: GET
- URL:
http://127.0.0.1:8080/api/v1/queries/products
-
Method: POST
-
URL:
http://127.0.0.1:8080/api/v1/commands/products
-
Headers:
Content-Type: application/json
-
Body:
{ "price": 999, "name": "Product 1" }
You can also import the provided Postman collection:
microservices-starter.postman_collection.json
For example HTTP requests, see the resquest.http file.
.
├── Dockerfile
├── README.md
├── Taskfile.yml
├── cloud-config-server
├── cloud-config-server.log
├── config-repo
├── docker
├── docs
├── eureka
├── eureka.log
├── gateway-server
├── gateway-server.log
├── kill.ports.sh
├── pom.xml
├── products-command
├── products-command.log
├── products-query
├── products-query.log
└── selenium
To stop all running services, use:
task stop
Or run the script with the relevant ports:
sh kill.ports.sh 8761 8080 8081 8090 8091
- The application implements the CQRS pattern, separating command and query responsibilities.
- RabbitMQ is used as the messaging broker for event-driven communication.
- PostgreSQL is the primary database and serves as the event store.
- Ensure version compatibility between Spring Boot, Spring Cloud, and Axon Framework.
- Check your configuration files in the
config-repo
to ensure that each microservice (e.g.,gateway-server.properties
) is correctly defined.
This project is licensed under the CC-BY-NC-SA-4.0 license.