Broadleaf Microservices
  • v1.0.0-latest-prod

Key Notification Service Components

NotificationService

The NotificationService maintains a list of NotificationHandler implementations as an ordered collection. It loops through the registered handlers and determines which one can process a given NotificationRequest.

Handlers are registered with the service by configuring a bean of type NotificationHandler (see examples).

NotificationHandler

A NotificationHandler is responsible for building and sending the message. For example, a typical use case is for the NotificationHandler to use a MessageBuilder to convert the NotificationRequest.data to a Notification.messageBody.

Each handler must implement four methods. canHandleDeliveryType(…​) returns true if this Handler should be used for the passed in delivery type which is normally EMAIL or SMS.

canHandle(…​) returns true if this Handler should be used for the provided NotificationRequest and ContexInfo. This method allows handlers to be applied only to certain message types or context information. For example, an application might use different email providers for different types of messages.

populateNotification(…​) is used to update properties on the Notification to prepare it for for delivery, typically using a MessageBuilder. For example, the ThymeleafMessageBuilder locates an appropriate template and builds the messageBody using the template along with the data from the Notification.

sendNotification(…​) sends the Notification to a MessageSender.

MessageBuilder

A MessageBuilder is intended for use with NotificationHandlers to construct the message contents. A ThymeleafMessageBuilder is provided that uses Thymeleaf templates to build rich messages.

MessageSender

The MessageSender is responsible for the delivery of the message. Broadleaf provides several examples of MessageSender implementations including JavaMail based implementations that can be used with AWS and Google. See providers in the service project root for a list of examples for 3rd parties. Implementations can introduce additional MessageSender implementations by implementing this interface and configuring as part of a MessageHandler configuration.

Sandboxing Configuration

At the time of this writing, there’s no sandboxable entities in this service. If a sandboxable entity is introduced in this service, the following configurations should be added:

spring:
  cloud:
    stream:
      bindings:
        persistenceOutput:
            triggeredJobEventInputPurgeSandbox:
              group: notification-purge-sandbox
              destination: triggeredJobEvent
broadleaf:
   transitionrequest:
     enabled: true
   changesummary:
     notification:
       active: true
   tracking:
     sandbox:
       purge:
         enabled: true

See Sandboxing In Detail for more details.

Note
These configurations typically only affect the Granular Deployment model. For Min and Balanced deployements, these configurations are likely already added at the flexpackage-level configuration.