Skip to content

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.

Notifications You must be signed in to change notification settings

coundia/spring-microservices-starter

Repository files navigation

Spring Axon RabbitMQ Webflux Postgres(EventStore and Db) Starter

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.


Table of Contents


Overview

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

Architecture

  • See

architecture.md

architecture_system.png

Image created by draw.io

docker.md

Prerequisites

Before running the application, ensure you have installed:


Installation and Execution

1. Clone the Repository

git clone https://github.com/coundia/spring-microservices-starter.git

2. Start PostgreSQL and RabbitMQ

Run the following command to start the Docker containers:

docker compose -f docker/main.yml up -d

or

task serve

3. Start the Spring Boot Applications

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 &

Eureka Server

The Eureka server dashboard is available at:
http://localhost:8761/

Example dashboard:

Eureka Dashboard


API Requests via Gateway

Through Gateway

Query Products

  • Method: GET
  • URL: http://127.0.0.1:8080/api/v1/queries/products

Create a Product

  • 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.


Project Structure

.
├── 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

Stopping the Servers

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

Notes

  • 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.

License

This project is licensed under the CC-BY-NC-SA-4.0 license.

About

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.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published