1
0
Fork 0
mirror of https://github.com/IRS-Public/direct-file.git synced 2025-08-14 00:30:53 +00:00
direct-file/direct-file/email-service
2025-06-05 15:58:51 -04:00
..
.mvn/wrapper initial commit 2025-06-05 15:58:51 -04:00
docker/db/postgres/init initial commit 2025-06-05 15:58:51 -04:00
src initial commit 2025-06-05 15:58:51 -04:00
.dockerignore initial commit 2025-06-05 15:58:51 -04:00
.gitignore initial commit 2025-06-05 15:58:51 -04:00
.liquibase.properties initial commit 2025-06-05 15:58:51 -04:00
Dockerfile-local initial commit 2025-06-05 15:58:51 -04:00
mvnw initial commit 2025-06-05 15:58:51 -04:00
mvnw.cmd initial commit 2025-06-05 15:58:51 -04:00
pom.xml initial commit 2025-06-05 15:58:51 -04:00
README.md initial commit 2025-06-05 15:58:51 -04:00

Direct File Email Service

This service is responsible for reading from a queue, generating emails, and sending mail to a SMTP relay.

Quick Start

Local Development

  1. This project relies on locally installed Maven packages in order to build; therefore, you can run the direct-file/scripts/build-project.sh script, which will install the shared dependencies.

    INSTALL_MEF=0 ../scripts/build-project.sh
    

Docker

To build and run the Email Service, run the following from /direct-file

docker compose up -d email-service

Testing by adding a message to the queue

A sample message that can be used for these tests is:

{
   "accepted": [
      {
         "to": "accept1@example.com",
         "languageCode": "en"
      },
      {
         "to": "accept2@example.com",
         "languageCode": "en"
      }
   ],
   "rejected": [
      {
         "to": "reject1@example.com",
         "languageCode": "en"
      },
      {
         "to": "reject2@example.com",
         "languageCode": "en"
      }
   ]
}

Locally with localstack

By default, the service is configured to use a black hole email service which writes a log message instead of actually sending email. Update the SPRING_PROFILES_ACTIVE in docker-compose.yaml if you need to verify/test with one of the other ISendService implementations.

docker compose up -d --build
# in one shell
docker compose logs --follow email-service
# in another
awslocal sqs send-message \
    --queue-url http://sqs.us-west-2.localstack:4566/000000000000/send-mail \
    --message-body file://./email_message.json

Upon handling, log messages will be printed to the console. Note the use of BlackholeSendService.

direct-file-email-service  | 2023-11-28T18:34:16.992Z  INFO 1 --- [hedulerThread-1] g.i.d.e.l.SendEmailMessageQueueListener  : Received a send mail request for test@example.com
direct-file-email-service  | 2023-11-28T18:34:16.993Z  INFO 1 --- [hedulerThread-1] g.i.d.e.services.BlackholeSendService    : email sent to test@example.com

Locally with Spring Boot Maven plugin

Configuration

Active Profiles:

Instructions

  1. Start LocalStack
docker compose up -d localstack
  1. Start email-service
./mvnw spring-boot-:run

or use the following to specify different active profiles

./mvnw spring-boot:run -Dspring-boot.run.profiles=<?debug>,<blackhole|send-email>

Debugging

application-debug.yaml

Tips

Disable/rename /src/main/resources/logback.xml to reenable Spring Boot console log formatting

Spot Bugs

For notes and usage on spotbugs see the Backend API README Spot Bugs section