Skip to content

roni2668/Notifcation_service

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

3 Commits
Β 
Β 
Β 
Β 

Repository files navigation

πŸ“¬ Notification Service

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.


πŸš€ Features

  • Send notifications via POST request
  • Retrieve notifications by user ID
  • Queue integration using RabbitMQ
  • Dockerized setup for easy local development

🐳 Running the Project with Docker

1. Start RabbitMQ using Docker

docker run -d --hostname rabbit-host --name rabbitmq \
  -p 5672:5672 -p 15672:15672 rabbitmq:3-management

RabbitMQ Management UI: http://localhost:15672

Username: guest

Password: guest

2. Start Spring Boot Application

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:8080

πŸ” REST API Endpoints

βœ… POST /notifications

Send 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!"
}
p_email
Copy
Edit
{
  "userId": 102,
  "type": "SMS",
  "message": "Welcome to My Notification_server System through sms!"
}
p_sms
Copy
Edit
{
  "userId": 103,
  "type": "In_APP",
  "message": "Welcome to My Notification_server System through IN_App!"
}
p_inapp

πŸ“© GET /users/{userId}/notifications

Fetch all notifications for a specific user.

URL: http://localhost:8080/users/{userId}/notifications

Method: GET URL: http://localhost:8080/users/101/notifications

g_email

URL: http://localhost:8080/users/102/notifications

g_sms

URL: http://localhost:8080/users/103/notifications

g_inapp

πŸ” RabbitMQ Integration

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

πŸ›  Tech Stack

Java 17+

Spring Boot 3.x

RabbitMQ --

WE firstly set up a run RabbitMq as-

run_n_queue

You should see the following queues listed (or similar, based on your configuration):

emailQueue:

rabbitmq_email

smsQueue:

rabbitmq_sms

inAppQueue:

rabbitmq_inapp

FINAL OVERVIEW:

rabbitmq_overview

Maven

Docker START:

docker
sudo systemctl start docker
docker start rabbitmq

Postman

🧼 Stopping Docker RabbitMQ To stop and remove the RabbitMQ container:

Copy
Edit
docker stop rabbitmq
docker rm rabbitmq

About

A Spring Boot-based Notification Service with RESTful GET and POST endpoints. Supports sending and retrieving user notifications. Integrates RabbitMQ for message queuing and asynchronous processing. Ideal for microservice-based notification systems.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages