Class AbstractEmailNotificationMessageListener

java.lang.Object
com.broadleafcommerce.notification.service.messaging.AbstractEmailNotificationMessageListener
Direct Known Subclasses:
AbstractNotificationFulfillmentStatusChangeMessageListener, AbstractNotificationQuoteStatusChangedMessageListener, AccountInviteAcceptanceMessageListener, NotificationAccountInviteMessageListener, NotificationAuthenticationMessageListener, NotificationCartApprovalRequestListener, NotificationCartAwaitingPaymentResultsListener, NotificationCartPendingPaymentFailedListener, NotificationCartRejectionMessageListener, NotificationOrderConfirmationMessageListener, PaymentGatewayCustomerNotificationListener

@DataRouteByKey("notification") public abstract class AbstractEmailNotificationMessageListener extends Object
Abstract message listener to help create notifications when events are received.
  • Field Details

    • EMAIL_DELIVERY

      protected static final String EMAIL_DELIVERY
      See Also:
    • notificationService

      protected final NotificationService<Notification> notificationService
    • messages

      protected final org.springframework.context.MessageSource messages
    • userResolver

      protected UserResolver userResolver
    • typeFactory

      protected final com.broadleafcommerce.common.extension.TypeFactory typeFactory
    • tenantProvider

      protected TenantProvider tenantProvider
  • Constructor Details

    • AbstractEmailNotificationMessageListener

      public AbstractEmailNotificationMessageListener(com.broadleafcommerce.common.messaging.service.IdempotentMessageConsumptionService idempotentConsumptionService, NotificationService<Notification> notificationService, org.springframework.context.MessageSource messages, com.fasterxml.jackson.databind.ObjectMapper objectMapper, com.broadleafcommerce.common.extension.TypeFactory typeFactory)
  • Method Details

    • handleMessageInternal

      protected void handleMessageInternal(org.springframework.messaging.Message<String> message)
      Message listener entry point. Checks if the message has already been received and, if not, begins processing it.
      Parameters:
      message - the message payload
    • getClassName

      protected abstract String getClassName()
      Get the class name to identify this listener for handling message idempotency.
      Returns:
      the listener's class name
    • processMessage

      protected void processMessage(org.springframework.messaging.Message<String> message)
      Processes the received message by extracting fields relevant to sending an email notification.
      Parameters:
      message - the message payload
    • getPayload

      protected String getPayload(org.springframework.messaging.Message<String> message)
      Get the message payload and customize it if needed.
      Parameters:
      message - the message payload
      Returns:
      string version of the message payload
    • getDocumentContext

      protected com.jayway.jsonpath.DocumentContext getDocumentContext(@NonNull @NonNull String payload)
      Parses the message payload into a DocumentContext which allows for JsonPath parsing using Jackson providers.
      Parameters:
      payload - the message payload
      Returns:
      a DocumentContext` representation of the message payload
    • validateShouldSendNotification

      protected abstract boolean validateShouldSendNotification(com.jayway.jsonpath.DocumentContext jsonContext)
      Validate that the message state is valid to send the email.
      Parameters:
      jsonContext - the message payload
      Returns:
      whether the email should be sent
    • buildNotification

      @Deprecated(forRemoval=true, since="1.7.0") protected Notification buildNotification(String payload, com.jayway.jsonpath.DocumentContext jsonContext)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Build the Notification for the current message. This is deprecated in 1.7. Use buildNotification(DocumentContext jsonContext) instead. The payload String can be derived from the jsonContext with "jsonContext.jsonString()".
      Parameters:
      payload - string version of the message payload
      jsonContext - the message payload
      Returns:
      the Notification for the current message
      Since:
      1.7. Use buildNotification(DocumentContext jsonContext) instead.
    • buildNotification

      protected Notification buildNotification(com.jayway.jsonpath.DocumentContext jsonContext)
      Build the Notification for the current message.
      Parameters:
      jsonContext - the message payload
      Returns:
      the Notification for the current message
    • modifyNotification

      @Deprecated(forRemoval=true, since="1.8.0") protected void modifyNotification(Notification notification, com.broadleafcommerce.data.tracking.core.context.ContextInfo context)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Extension point to allow modifying the notification or context before sending to the notification service
      Parameters:
      notification - the Notification for the current message
      context - The context of the request
    • modifyNotification

      protected void modifyNotification(Notification notification, com.jayway.jsonpath.DocumentContext jsonContext, com.broadleafcommerce.data.tracking.core.context.ContextInfo context)
      Extension point to allow modifying the notification or context before sending to the notification service
      Parameters:
      notification - the Notification for the current message
      jsonContext - the message payload
      context - The context of the request
    • getMessageType

      protected abstract String getMessageType(com.jayway.jsonpath.DocumentContext jsonContext)
      Determine which message type should be sent.
      Parameters:
      jsonContext - the message payload
      Returns:
      the message type to send
    • getNotificationSubject

      protected abstract String getNotificationSubject(com.jayway.jsonpath.DocumentContext jsonContext)
      Determine the subject to use for the email notification.
      Parameters:
      jsonContext - the message payload
      Returns:
      the subject to use for the email notification
    • getRecipients

      protected abstract List<Recipient> getRecipients(com.jayway.jsonpath.DocumentContext jsonContext)
      Determine the recipients to use for the email notification.
      Parameters:
      jsonContext - the message payload
      Returns:
      the recipients to use for the email notification
    • buildNotificationContext

      protected abstract com.broadleafcommerce.data.tracking.core.context.ContextInfo buildNotificationContext(com.jayway.jsonpath.DocumentContext jsonContext)
      Build the ContextInfo for the current message
      Parameters:
      jsonContext - the payload of the message
      Returns:
      the NotificationContext for the current message
    • resolveApplicationById

      protected Optional<com.broadleafcommerce.data.tracking.core.tenant.domain.Application> resolveApplicationById(@NonNull @NonNull String applicationId)
      Resolves the application with the given application id.
      Parameters:
      applicationId - the application id
      Returns:
      an Optional of Application
    • getIdempotentConsumptionService

      protected com.broadleafcommerce.common.messaging.service.IdempotentMessageConsumptionService getIdempotentConsumptionService()
    • getNotificationService

      protected NotificationService<Notification> getNotificationService()
    • getMessages

      protected org.springframework.context.MessageSource getMessages()
    • getUserResolver

      protected UserResolver getUserResolver()
    • setUserResolver

      @Autowired public void setUserResolver(UserResolver userResolver)
    • getObjectMapper

      protected com.fasterxml.jackson.databind.ObjectMapper getObjectMapper()
    • getTypeFactory

      protected com.broadleafcommerce.common.extension.TypeFactory getTypeFactory()
    • getTenantProvider

      protected TenantProvider getTenantProvider()
    • setTenantProvider

      @Autowired public void setTenantProvider(TenantProvider tenantProvider)