Prerequisites
The plugin is available as a docker image.
It has the following dependencies:
  • a mongodb database
  • needs to be able to connect to the Kafka instance used by the engine
  • a redis instance for caching notification templates
  • in case you need to also attach documents to the sent notifications, the plugin will need to be able to acces your chosen storage solution. It can use an S3 compatible file storage solution (we have successfully used Min.io)
The plugin comes with most of the needed configuration properties filled in, but there are a few that need to be set up using some custom environment variables.

Dependencies

Mongo database

Basic mongo configuration - helm values.yaml
1
notification-mdb:
2
existingSecret: {{secretName}}
3
mongodbDatabase: {{NotificationDatabaseName}}
4
mongodbUsername: {{NotificationDatabaseUser}}
5
persistence:
6
enabled: true
7
mountPath: /bitnami/mongodb
8
size: 4Gi
9
replicaSet:
10
enabled: true
11
name: rs0
12
pdb:
13
enabled: true
14
minAvailable:
15
arbiter: 1
16
secondary: 1
17
replicas:
18
arbiter: 1
19
secondary: 1
20
useHostnames: true
21
serviceAccount:
22
create: false
23
usePassword: true
Copied!

Redis server

The plugin can use the Redis component already deployed for the engine.

Document storage

You need to have an S3 compatible file storage solution deployed in your setup.

Configuration

Mongo DB Configuration

The only thing that needs to be configured is the DB access info, the rest will be handled by the plugin.
1
data:
2
mongodb:
3
uri: mongodb://${DB_USERNAME:default_username}:${DB_PASSWORD:password}@${DB_HOST:notification-mdb}:27017/${DB_NAME:notification}
4
datasource:
5
hikari:
6
maximum-pool-size: ${HIKKARI_MAX_POOL_SIZE:10}
Copied!
uri - links to the Mongo DB database with username, password and DB url and name

Redis Configuration

1
spring:
2
cache:
3
type: redis
4
redis:
5
key-prefix: "notification:"
6
time-to-live: ${REDIS_TTL:5000000} # milliseconds
7
8
redis:
9
host: ${REDIS_MASTER_HOST}
10
port: ${REDIS_MASTER_PORT}
11
password: ${REDIS_PASSWORD}
12
ttl: ${REDIS_TTL:5000000} # milliseconds
Copied!

Kafka Configuration

The following Kafka related configurations can be set by using environment variables:
1
spring:
2
kafka:
3
bootstrap-servers: KAFKA_BOOTSTRAP_SERVER
4
consumer:
5
group-id: KAFKA_CONSUMER_GROUP_ID
6
kafka:
7
consumerThreads: ${KAFKA_CONSUMER_THREADS_NO:1}
8
authorizationExceptionRetryInterval: ${KAFKA_AUTH_EXCEPTION_RETRY_INTERVAL:10}
Copied!
KAFKA_BOOTSTRAP_SERVER - address of the Kafka server
KAFKA_CONSUMER_GROUP_ID - group of consumers
KAFKA_MESSAGE_MAX_BYTES - this is the largest size of the message that can be received by the broker from a producer.
KAFKA_CONSUMER_THREADS_NO - the number of Kafka consumer threads
KAFKA_AUTH_EXCEPTION_RETRY_INTERVAL - the interval between retries after AuthorizationException is thrown by KafkaConsumer
Each action available in the plugin corresponds to a Kafka event. A separate Kafka topic must be configured for each use-case.
The Engine is listening for messages on topics with names of a certain pattern, make sure to use correct outgoing topic names when configuring the notifications plugin.

File storage configuration

Based on use case you can use directly a file system or an S3 compatible cloud storage solution (for example min.io).
A basic configuration for min.io, looks like this:
1
application:
2
file-storage:
3
type: minio # minio / fileSystem
4
minio:
5
server-url: MINIO_SERVER_URL
6
access-key: MINIO_ACCESS_KEY
7
secret-key: MINIO_SECRET_KEY
8
bucket-prefix: MINIO_BUCKET_PREFIX
Copied!

SMTP Setup

If you want to use a custom SMTP server:
1
simplejavamail:
2
smtp:
3
host: ${SMTP_HOST:smtp.gmail.com}
4
port: ${SMTP_PORT:587}
5
username: ${SPRING_MAIL_USERNAME:[email protected]}
6
password: ${SPRING_MAIL_PASSWORD:password}
Copied!
The email and name to be used as sender for emails sent by the plugin:
1
application:
2
mail:
3
from-email: ${MAIL_FROM}
4
from-name: ${NAME_FROM}
Copied!

Email attachments configuration

The maximum file size for files to be attached as email attachments can also be configured:
1
spring:
2
http:
3
multipart:
4
max-file-size: ${HTTP_MULTIPART_MAX_FILE_SIZE:15MB}
5
max-request-size: ${HTTP_MULTIPART_MAX_REQUEST_SIZE:15MB}
Copied!

Firebase push notifications configuration

We use Firebase Cloud Messaging for sending push notifications to mobile devices. If you want to use the feature of sending push notifications, it needs to be enabled:
1
application:
2
sendsFirebasePushNotifs: true
Copied!
Also, some setup is needed in your Firebase Console account:
  • create a new project
  • register each mobile app and download their respective config files and include them in the apps
  • you will need to configure a new service account in your firebase account and download the service account JSON file and add the path to it in the plugin configuration:
1
application:
2
firebase-config: ${FIREBASE_CONFIG:path_to_firebase_json_file}
Copied!

OTP Configuration

The desired character size and expiration time of the generated one-time-passwords can also be configured.
1
otpLength: ${OTP_LENGTH:4}
2
otpExpireTimeInSeconds: ${OTP_EXPIRE_TIME_IN_SECONDS:6000} #10 minutes
Copied!

Logging

The following environment variables could be set in order to control log levels:
LOGGING_ROOT_LOGLEVEL - root spring boot microservice logs
LOGGING_APP_LOGLEVEL - app level logs
LOGGING_MONGO_DRIVER_LOGLEVEL - mongo db driver logs
LOGGING_THYMELEAF_LOGLEVEL - thymeleaf logs, logs related to using notifications templates
LOGGING_FCM_CLIENT_LOGLEVEL - google api client logs, related to sending push notifications using Firebase
Last modified 2mo ago