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.
- REST endpoint for
EMAIL,SMS, andPUSHevent 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.
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.
- Java 21
- Spring Boot 3.5
- Spring Web
- Spring Validation
- Lombok
- JUnit 5
- Mockito
- Docker
- Maven
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 |
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"
}./mvnw clean test
./mvnw spring-boot:runSubmit 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"
}
}'./mvnw clean package
docker compose up --buildThe API is available at http://localhost:8080/api/events.
./mvnw testCurrent 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.
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