This project demonstrates the integration of Spring Boot with RabbitMQ and Kafka for messaging. It consists of multiple microservices that communicate with each other using RabbitMQ and Kafka. The services include:
- Notification Service: Handles notifications and listens to messages from RabbitMQ and Kafka.
- Order Service: Manages orders and sends messages to RabbitMQ and Kafka.
- Messaging Logging Service: Logs messages received from RabbitMQ and Kafka.
The architecture consists of the following components:
- RabbitMQ: Used for message queuing.
- Kafka: Used for message streaming.
- PostgreSQL: Used as the database for storing data.
- Docker Compose: Used to orchestrate the services.
- RabbitMQConfig: Configures RabbitMQ.
- NotificationService: Listens to
notification\_queue
and processes messages. - NotificationController: Handles HTTP requests for notifications.
- RabbitMQConfig: Configures RabbitMQ.
- OrderService: Manages orders and sends messages to RabbitMQ and Kafka.
- RabbitMQConfig: Configures RabbitMQ.
- LogMessageService: Listens to
notification\_queue
andlog\_topic
and logs messages.
- Docker
- Docker Compose
- Java 17+
- Maven
-
Clone the repository:
git clone https://github.com/sogutemir/SpringKafka-RabbitMq.git cd SpringKafka-RabbitMq
-
Build the services:
mvn clean install
-
Start the services using Docker Compose:
docker-compose up --build
- Notification Service:
http://localhost:8084
- Order Service:
http://localhost:8083
- Messaging Logging Service:
http://localhost:8082
- RabbitMQ Management Console:
http://localhost:15672
(default username:guest
, password:guest
) - Kafka:
localhost:9092
- PostgreSQL:
localhost:5432
- PgAdmin:
http://localhost:5050
(default email:admin@admin.com
, password:admin
)
-
Create Notification:
- URL:
POST /api/notifications
- Body:
{ "userId": 1, "message": "This is a test notification" }
- URL:
-
Get All Notifications:
- URL:
GET /api/notifications
- URL:
-
Get Notification by ID:
- URL:
GET /api/notifications/{id}
- URL:
-
Delete Notification:
- URL:
DELETE /api/notifications/{id}
- URL:
- Queue Name:
notification\_queue
- Topics:
log\_topic
order\_topic
The docker-compose.yml
file configures the services, networks, and volumes. Key services include:
- PostgreSQL: Database service.
- Zookeeper: Kafka dependency.
- Kafka: Message broker.
- RabbitMQ: Message queue.
- Messaging Logging Service: Logs messages.
- Order Service: Manages orders.
- Notification Service: Manages notifications.
- PgAdmin: Database management tool.
This project demonstrates a microservices architecture using Spring Boot, RabbitMQ, and Kafka. It showcases how to set up and configure messaging between services and provides a foundation for building scalable and resilient applications.