This project demonstrates a clean microservices architecture using Spring Boot with asynchronous communication powered by RabbitMQ. The system simulates registering employees and sending automatic email notifications when new employees are created.
The solution contains two independent services:
- Exposes REST endpoints to manage employees.
- Saves employee data to its own database.
- Publishes events to RabbitMQ every time a new employee is created.
- Listens to messages coming from RabbitMQ.
- Processes the received event.
- Saves a record simulating an email delivery.
- Java 21
- Spring Boot
- RabbitMQ
- PostgreSQL
- Maven
microservices
├── employee-service
│ ├── config
│ ├── controller
│ ├── infra
│ ├── model
│ ├── producer
│ ├── repository
│ ├── representation
│ ├── service
└── email-service
├── consumer
├── model
├── dto
├── repository
├── service
└── config
Each service is completely isolated and follows clean separation of responsibility.
If using Docker:
docker run -d \
--hostname rabbit \
--name rabbitmq \
-p 5672:5672 \
-p 15672:15672 \
rabbitmq:3-managementAccess management console:
http://localhost:15672
Default login:
user: guest
pass: guest
Enter each project folder and run:
mvn spring-boot:runOr run via your IDE.
POST http://localhost:8080/employees
Content-Type: application/json
{
"nome": "Mateus",
"email": "mateus@exapmple.com",
"tipo": "Efetivo",
"salario": 2000
}Expected result:
- Employee is saved.
- Message is published to RabbitMQ.
- Email Service consumes the message.
- Email is logged as "sent".
Some planned enhancements:
-
API Gateway (Spring Cloud Gateway / Kong)
-
Distributed monitoring (Grafana + Prometheus)
-
Distributed tracing (Zipkin / Sleuth)
-
Dead-Letter Queues for failed events
-
Testing strategies:
- Unit tests
- Integration tests
- Contract tests
Project built for educational purposes, demonstrating message-driven microservices with Spring Boot and RabbitMQ.