← Back to projects
NOTIFICATION API preview
Open SourcePersonal Project

NOTIFICATION API

Event-driven notification service

Spring BootRabbitMQPostgreSQLDocker

An event-driven, asynchronous notification processing system built with Spring Boot, PostgreSQL, and Docker. Designed to decouple notification delivery from the services that trigger it — the calling service returns instantly, and failures don't cascade.

Features

  • Asynchronous notification processing using RabbitMQ
  • Supports multiple channels: Email, SMS, Push notifications
  • Retry mechanism with configurable attempts
  • Dead Letter Queue (DLQ) for failed messages
  • Persistent storage using PostgreSQL
  • Clean architecture with service separation
  • Strategy pattern for channel-based processing
  • Structured logging instead of System.out.println
  • Fully containerized with Docker & Docker Compose

System Architecture

Client Request
      ↓
Spring Boot REST API
      ↓
PostgreSQL (store notification)
      ↓
RabbitMQ (message queue)
      ↓
Consumer Service
      ↓
Channel Processor (Email / SMS / Push)
      ↓
Success → Update DB
Failure → Retry Queue → (max retries)
      ↓
     DLQ

Tech Stack

  • Java 21+
  • Spring Boot · Spring Data JPA
  • RabbitMQ
  • PostgreSQL
  • Docker & Docker Compose
  • Maven

How It Works

  1. A request is sent to the API to create a notification
  2. The notification is stored in PostgreSQL
  3. A message is published to RabbitMQ
  4. Consumer picks up the message
  5. Based on channel type:
    • EMAIL → EmailProcessor
    • SMS → SMSProcessor
    • PUSH → PushProcessor
  6. If processing fails: retry up to 3 times, then send to Dead Letter Queue (DLQ)

API Usage

Create Notification

POST /notifications

Request Body:

{
  "userId": 123,
  "channel": "EMAIL",
  "message": "Hello, this is a test notification",
  "priority": "HIGH"
}

Response:

{
  "notificationId": "60e9af48-ac2e-4903-bbac-1d8eff55c39d",
  "status": "QUEUED"
}

Running the Project

# Build the project
./mvnw clean package

# Start everything (App + RabbitMQ + PostgreSQL)
docker compose up --build

Monitoring

Key Design Patterns

  • Strategy Pattern → Channel-based processors (Email/SMS/Push)
  • Factory Pattern → Selecting correct processor
  • Consumer-Producer Pattern → RabbitMQ messaging
  • Retry Pattern → Fault tolerance handling