Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Event Notification System

Spring Boot service for accepting notification events, routing them to per-channel FIFO queues, processing them asynchronously, and posting callback results to the caller.

The project is intentionally small, but it demonstrates the backend mechanics that matter in real services: input validation, queue isolation, per-channel workers, callback boundaries, Docker packaging, and focused controller/service/client tests.

What It Covers

  • REST endpoint for EMAIL, SMS, and PUSH event submission.
  • Separate FIFO queue and single worker thread per event type.
  • Channel-specific processing delays to model different downstream latencies.
  • Callback POST after processing succeeds or fails.
  • Jakarta Bean Validation for required request fields.
  • Dockerfile and Docker Compose setup for local execution.
  • JUnit 5 / Spring MVC / Mockito coverage for controller, service, and callback paths.

Architecture

Client
  |
  | POST /api/events
  v
EventController
  |
  v
EventService
  |
  v
EventProcessorManager
  |-- EMAIL queue -> single worker -> callback
  |-- SMS queue   -> single worker -> callback
  |-- PUSH queue  -> single worker -> callback

Each channel has its own queue and executor, so a slow SMS workload does not block EMAIL or PUSH processing. Ordering is preserved within a channel because each queue is consumed by one worker.

Stack

  • Java 21
  • Spring Boot 3.5
  • Spring Web
  • Spring Validation
  • Lombok
  • JUnit 5
  • Mockito
  • Docker
  • Maven

API

Submit Event

POST /api/events
Content-Type: application/json
{
  "eventType": "EMAIL",
  "callbackUrl": "http://localhost:8081/callback",
  "payload": {
    "recipient": "user@example.com",
    "message": "Welcome to our service"
  }
}

Successful response:

{
  "eventId": "e123",
  "message": "Event accepted for processing."
}

Validation failures return 400 Bad Request.

Supported event types:

Type Simulated delay Expected payload shape
EMAIL 5 seconds recipient, message
SMS 3 seconds phoneNumber, message
PUSH 2 seconds deviceId, message

Callback Contract

On completion, the service posts a callback payload to callbackUrl.

Success:

{
  "eventId": "e123",
  "status": "COMPLETED",
  "eventType": "EMAIL",
  "processedAt": "2025-07-01T12:34:56Z"
}

Failure:

{
  "eventId": "e123",
  "status": "FAILED",
  "eventType": "EMAIL",
  "errorMessage": "Simulated processing failure",
  "processedAt": "2025-07-01T12:34:56Z"
}

Run Locally

./mvnw clean test
./mvnw spring-boot:run

Submit a sample event:

curl -X POST http://localhost:8080/api/events \
  -H "Content-Type: application/json" \
  -d '{
    "eventType": "EMAIL",
    "callbackUrl": "http://localhost:8081/callback",
    "payload": {
      "recipient": "user@example.com",
      "message": "Welcome to our service"
    }
  }'

Run With Docker

./mvnw clean package
docker compose up --build

The API is available at http://localhost:8080/api/events.

Tests

./mvnw test

Current coverage focuses on:

  • Valid event submission.
  • Missing payload and invalid event type validation.
  • Event ID generation and enqueue handoff.
  • Callback client behavior when the callback endpoint is unavailable.

Project Layout

src/main/java/com/notification/eventsystem
|-- client/        Callback HTTP client
|-- controller/    REST API entrypoint
|-- dto/           Request and response payloads
|-- model/         Event domain objects
|-- processor/     Queue workers and channel routing
|-- Implementation Event service implementation
|-- Interface      Event service contract

About

Spring Boot notification service with per-channel FIFO queues, callbacks, graceful shutdown, Docker, and JUnit coverage

Topics

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages