Microservices Event-Driven System with Spring Boot, RabbitMQ, Kafka, PostgreSQL, Docker, and Kubernetes
This project demonstrates a simple event-driven microservices architecture where a User Service triggers events upon user registration. The events are consumed by the Email Service (via RabbitMQ) and the Analytics Service (via Kafka). The whole system is containerized using Docker and deployed with Kubernetes.
-
User Service (Spring Boot):
- Handles user registration and stores user data in PostgreSQL.
- Publishes events to RabbitMQ upon successful registration.
-
Email Service (Spring Boot):
- Listens to RabbitMQ for user registration events.
- Sends a welcome email upon receiving an event.
-
Analytics Service (Spring Boot):
- Listens to Kafka for user registration events.
- Logs or processes the event data for analytical purposes.
-
Infrastructure:
- RabbitMQ: For handling messaging between User Service and Email Service.
- Kafka: For streaming messages to the Analytics Service.
- PostgreSQL: For persisting user data.
- Docker & Kubernetes: For containerization and orchestration.
- Java 17
- Spring Boot (3.x)
- Spring Data JPA
- Spring AMQP (RabbitMQ)
- Spring Kafka
- PostgreSQL
- Docker
- Kubernetes (Minikube / Kind / Local Kubernetes Cluster)
βββ user-service
βββ email-service
βββ analytics-service
βββ docker-compose.yml
βββ k8s
β βββ user-service.yaml
β βββ email-service.yaml
β βββ analytics-service.yaml
β βββ rabbitmq.yaml
β βββ kafka.yaml
β βββ zookeeper.yaml
β βββ postgresql.yaml
βββ README.md
- Docker & Docker Compose
- Kubernetes (Minikube / Kind / Local Cluster)
- Java 17 & Maven
- Build the services:
mvn clean install -DskipTests- Start all services:
docker-compose up --build- Create Kubernetes resources:
kubectl apply -f k8s/- Verify pods are running:
kubectl get pods- Register a user by making a
POSTrequest to theUser Serviceendpoint:
POST /api/v1/users/register
Content-Type: application/json
{
"username": "johndoe",
"email": "johndoe@example.com",
"password": "password123"
}- Check the logs of the
Email ServiceandAnalytics Serviceto confirm they received and processed the event.
- Implement User Service (Spring Boot, PostgreSQL, RabbitMQ).
- Implement Email Service (Spring Boot, RabbitMQ).
- Implement Analytics Service (Spring Boot, Kafka).
- Set up Docker Compose and Kubernetes configuration.
- Test the complete workflow.