A Spring Boot microservice for sending SMS notifications via Amazon SNS based on RabbitMQ message queue events.
The Notification App is a Java Spring Boot application that consumes proposal-related events from RabbitMQ queues and sends SMS notifications to users via AWS SNS. It is designed to handle two primary notification types:
- Pending proposal notifications
- Completed proposal notifications
- Message consumption from RabbitMQ queues
- SMS notification delivery via Amazon SNS
- Error handling and fallback mechanisms
- Customizable notification messages
- Comprehensive logging
- Containerized deployment
- Health monitoring via Spring Actuator
- Java 21
- Spring Boot 3.4.5
- Spring AMQP (RabbitMQ)
- AWS SDK for SNS
- Docker & Docker Compose
- Lombok
- JUnit 5 & Mockito for testing
- Java 21 or higher
- Maven
- RabbitMQ server (or Docker)
- AWS account with SNS permissions
- Docker & Docker Compose (for containerized deployment)
The application can be configured using environment variables or a .env
file. Key configuration parameters include:
RABBITMQ_HOST=localhost
RABBITMQ_PORT=5672
RABBITMQ_USERNAME=guest
RABBITMQ_PASSWORD=guest
AWS_ACCESS_KEY=your_aws_access_key
AWS_SECRET_KEY=your_aws_secret_key
AWS_REGION=us-east-1
DEFAULT_PHONE=your_default_fallback_phone_number
- Clone the repository
- Create a
.env
file with your configuration (see template in Configuration section) - Run the application using Maven:
./mvnw spring-boot:run
- Build the Docker image:
docker build -t notification-app .
- Run using Docker Compose:
docker-compose up -d
The application expects proposal messages with the following structure:
{
"id": 123,
"proposalValue": 5000.0,
"approved": true,
"integrated": true,
"observation": "Optional custom message",
"user": {
"id": 456,
"name": "John",
"lastName": "Doe",
"tellPhone": "+1234567890"
}
}
Run the tests using Maven:
./mvnw test
Or use the VS Code test task:
# Run all tests
mvn -B test
The application exposes health endpoints through Spring Actuator:
- Health:
/actuator/health
- Information:
/actuator/info
- Metrics:
/actuator/metrics
Spring Actuator provides detailed metrics for monitoring. The Docker setup includes health checks to ensure the application is running correctly.
- Leonardo Meireles