A Spring Boot-based microservice for sending and retrieving user notifications.
Built with RabbitMQ integration for message queuing and asynchronous processing.
Provides RESTful GET and POST endpoints to interact via tools like Postman.
- Send notifications via POST request
- Retrieve notifications by user ID
- Queue integration using RabbitMQ
- Dockerized setup for easy local development
docker run -d --hostname rabbit-host --name rabbitmq \
-p 5672:5672 -p 15672:15672 rabbitmq:3-managementRabbitMQ Management UI: http://localhost:15672
Username: guest
Password: guest
Make sure you have Maven and Java 17+ installed.
Copy
Edit
./mvnw clean install
./mvnw spring-boot:run
Or if using regular Maven:Copy
Edit
mvn clean install
mvn spring-boot:run
The application will start on: http://localhost:8080Send a notification.
URL: http://localhost:8080/notifications
Method: POST
Headers: Content-Type: application/json
Body Example:
Copy
Edit
{
"userId": 101,
"type": "EMAIL",
"message": "Welcome to My Notification_server System through email!"
}
Copy
Edit
{
"userId": 102,
"type": "SMS",
"message": "Welcome to My Notification_server System through sms!"
}
Copy
Edit
{
"userId": 103,
"type": "In_APP",
"message": "Welcome to My Notification_server System through IN_App!"
}
Fetch all notifications for a specific user.
URL: http://localhost:8080/users/{userId}/notifications
Method: GET URL: http://localhost:8080/users/101/notifications
URL: http://localhost:8080/users/102/notifications
URL: http://localhost:8080/users/103/notifications
Spring Boot connects to RabbitMQ using spring.rabbitmq.host=localhost
Queue name should be defined consistently in RabbitMQConfig.java
Messages sent through /notifications are pushed to the queue
Consumers can listen to the same queue and process them asynchronously
##π¬ Postman Testing You can test both APIs using Postman:
POST http://localhost:8080/notifications
Send JSON body with userId, type (EMAIL, SMS, IN_APP), and message.
GET http://localhost:8080/users/{userId}/notifications
Replace {userId} with a valid ID (e.g., 123).
Java 17+
Spring Boot 3.x
RabbitMQ --
WE firstly set up a run RabbitMq as-
You should see the following queues listed (or similar, based on your configuration):
emailQueue:
smsQueue:
inAppQueue:
FINAL OVERVIEW:
Maven
Docker START:
sudo systemctl start docker
docker start rabbitmqPostman
π§Ό Stopping Docker RabbitMQ To stop and remove the RabbitMQ container:
Copy
Edit
docker stop rabbitmq
docker rm rabbitmq