Typically run as a cron job to ensure that an e-mail is sent (and re-tried) asynchronously, in case of potential down time of an e-mail provider.
This application sends an HTTP request to a configured endpoint. This configured API endpoint should contain the e-mail delivery logic. More info on what the configured endpoint should do is described here.
This application expects e-mails that failed to be sent, to be persisted as Custom Objects in the commercetools Platform.
This application supports multi-tenant configurations. In other words, it can be used for multiple applications, each with their own commercetools project for persistence.
The configuration can be passed via environment variables or via a configuration file, as follows:
Please set the following environment variable:
export CTP_PROJECT_CONFIG="{\"tenants\": [{\"projectKey\": \"<ctp project key>\",\"clientId\": \"<ctp project ID>\", \"clientSecret\": \"<ctp project client secret>\", \"endpointUrl\": \"<endpoint url>\", \"encryptionKey\" : \"<blowfish encryptionkey>\", \"processAll\" : <true|false>}]}"
Please pass the path to the configuration file as argument to the "main" method
The configuration file should contain the following "JSON-SNIPPET".
{
"tenants": [
{
"projectKey": "<ctp project key>",
"clientId": "<ctp project ID>",
"clientSecret": "<ctp project client secret>",
"endpointUrl": "<endpoint url>",
"encryptionKey" : "<blowfish encryptionkey, which is used to encrypt the email object id before passing it the post request>",
"processAll" : true|false <if true, all email objects (pending/error) are processed, otherwise only "pending" email objects will be processed (Default: false).>
}
]
}
Build the application and run tests
./gradlew clean build
First, package the JAR
./gradlew clean shadowJar
Then run the JAR
java -jar build/libs/email-processor.jar
The API endpoint should cover the following steps:
200
pending
503
error
400
This module is deployed as docker image to dockerhub.
The build and deployment of the docker are done using github actions.
On each push to the remote github repository, the github action ci is triggered, which builds the project and executes it`s tests.
The github action cd is used to create the docker-image and deploy it to dockerhub. This action is triggered when a git release tag is created.
There are two ways to create the release-tag:
git tag -a v1.0.1 -m "Minor text adjustments."
via Github UI