This project is part of a microservice architecture, specifically handling the email sending functionality triggered by user creation in the associated user creation microservice.
When the user creation microservice triggers a message dispatch, this microservice, through its consumer (also known as listener), picks up the message from the RabbitMQ queue and sends an email based on the configuration in the application.properties file.
- Consumes messages from RabbitMQ queue
- Sends emails using JavaMailSender
- Error handling using Enum
- Shares database with user creation microservice, but uses a separate table
- Consumer: Responsible for retrieving and consuming messages from the RabbitMQ queue.
- EmailService: Handles the email sending process using JavaMailSender. It uses setters to populate email details from the EmailModel.
- EmailModel: Represents the email entity and is responsible for creating and manipulating the "emails" table in the database.
- Repository: Manages the persistence of the EmailModel entity.
- Enum: Handles error states and successful email sending status.
- Config: Contains configuration for connecting to the RabbitMQ queue as a consumer.
- DTO: Data Transfer Object for email, shared with the user creation microservice.
The project follows a structure similar to the user creation microservice:
configs
: RabbitMQ consumer configurationconsumer
: Handles message consumption from RabbitMQdtos
: Contains EmailDTO shared with the user creation microserviceenums
: Defines email status (e.g., SENT, ERROR)models
: Defines EmailModel for the "emails" tablerepositories
: Manages data persistence for the EmailModelservices
: Contains EmailService for sending emails
- Spring Boot
- PostgreSQL (shared with user creation microservice)
- RabbitMQ
- JavaMailSender
- The consumer listens for messages on the RabbitMQ queue.
- When a message is received, it's processed by the EmailService.
- The EmailService uses JavaMailSender to send an email based on the received message.
- The result of the email sending process (success or failure) is stored in the database.
(Add instructions on how to set up and run the project locally, including any necessary environment variables or application.properties settings)
This project relies on the JavaMailSender dependency, which was added through the Spring Initializr.
Errors are captured and managed using an Enum, allowing for standardized error reporting and handling.