Skip to content

The notifications microservice is an independently deployable component intended for sending various types of notifications.

License

Notifications You must be signed in to change notification settings

sflpro/notifier

Folders and files

NameName
Last commit message
Last commit date

Latest commit

0b62c9c · Jun 14, 2022
May 13, 2019
Jun 14, 2022
Jun 14, 2022
Jun 14, 2022
Jun 14, 2022
Jun 14, 2022
Jun 14, 2022
Sep 20, 2019
Jun 14, 2022
Jan 25, 2018
Jul 9, 2019
Jul 9, 2021
Sep 6, 2019
Jan 26, 2017
Oct 19, 2021
Jun 14, 2022
Feb 10, 2021

Repository files navigation

Build Status Quality Gate Status Maven Central License: APACHE

Notifications Microservice

The notifications microservice is an independently deployable component intended for sending various types of notifications. It provides a common abstraction layer on top of the various notification types and actual sending, tracking routines.

Supported notification types

Notifier supports the most common notification types and platforms. The project aims to enable the user to only rely on notifier for client messaging/communication. Below are the supported notification types and implementations.

Email Notifications

The microservice supports sending regular emails. The supported transports are:

SMS Notifications

The microservice supports sending SMS notifications. The supported transports are:

Push Notifications

Push notifications to mobile devices are supported. As of now, only one provider is available:

Integration

You can call the notifier's REST API directly or use the provided Java client library. To use the client library add the following maven dependency:

<dependency>
    <groupId>com.sflpro.notifier</groupId>
    <artifactId>api-client-library</artifactId>
    <version>1.10.1</version>
</dependency>

The API is documented using OpenAPI Specification(Swagger) and the documentation JSON is available under /swagger.json once the notifier microservice has been started.

Deployment

Notifier is dockerized and is easy to deploy as a docker container. For more details, see the images on docker hub:
https://hub.docker.com/r/sflpro/notifier-api & https://hub.docker.com/r/sflpro/notifier-worker

Running the application locally

1. Configure POSTGRES datasource

The postgres has official images in docker hub.

docker run --name notifier-postgres -e POSTGRES_PASSWORD=notifier -e POSTGRES_USER=notifier -e POSTGRES_DB=notifier -p 5432:5432 -d postgres:11

2. Configure RabbitMQ queue engine

RabbitMQ has official images in docker hub. Running RabbitMQ with management plugin enabled

docker run -d --hostname notifier-rabbit --name some-rabbit -p 5671:5671 -p 5672:5672 -p 15672:15672 rabbitmq:3-management

3. Prepare properties file for notifier images

# Postgres
spring.datasource.url=jdbc:postgresql://{HOST_IP}:5432/POSTGRES_DB
spring.datasource.username=POSTGRES_USER
spring.datasource.password=POSTGRES_PASSWORD

# Notifier queue engine
notifier.queue.engine=rabbit

# RabbitMQ
spring.rabbitmq.host={HOST_IP}
spring.rabbitmq.username=guest

# Container port
server.port=8080

4. Run notifier-api

Running Notifier-API docker images.

docker run -p 8080:8080 -v {NOTIFIER_-_PROPERTIES_PATH}:/etc/notifier/notifier.properties sflpro/notifier-api:1.7.0 --spring.config.additional-location=etc/notifier/notifier.properties

Running Notifier-Worker docker images

docker run -p 8081:8080 -v {NOTIFIER_-_PROPERTIES_PATH}:/etc/notifier/notifier.properties sflpro/notifier-worker:1.7.0 --spring.config.additional-location=etc/notifier/notifier.properties

5. Testing setup

curl -X POST "localhost:8080/notification/email/create"  -H "accept: application/json" -H "Content-Type: application/json" -d "{\"recipientEmail\":\"recipient-email@example.com\",\"senderEmail\":\"sender-email@example.com\",\"subject\":\"testing-subject\",\"templateName\":\"Email template name\"}"

Additional configurations

To externalized application properties add the following command as a program argument

--spring.config.additional-location=/your/location/properties-file.properties

Configure kafka to use SASL_SSL security protocol

kafka.ssl.endpoint.identification.algorithm=https
kafka.sasl.mechanism=PLAIN
kafka.sasl.jaas.config=org.apache.kafka.common.security.plain.PlainLoginModule required username="<API_KEY>" password="<API_SECRET>";
kafka.security.protocol=SASL_SSL