Extending Notification Messages

You can extend notification messages by adding custom logic in Java classes defined in /opt/mtx/notifier_camel/classes. In general, notification messages are enhanced with additional information by querying RS Gateway.

Extending notification messages requires that you create the Java classes that query RS Gateway for additional information. Then, you must customize the notification message templates to include this information. It is helpful to have a good understanding of Apache Camel Framework terminology. See the Apache Camel website for more information.

Apache Camel Terms lists the Apache Camel terms used in the Purchase Offer Notification Sample.
Table 1. Apache Camel Terms
Term Description
Processor The Processor provides full access to the message being transferred including the message body, headers, and properties associated with the message. By creating a Processor you can modify any of these elements.
producerTemplate A template for working with Camel and sending Message instances in an Exchange to an endpoint.
Exchange An exchange is a message container which holds information during the entire routing of a Message received by a consumer.

The Purchase Offer Notification Sample example uses the subscriberID from the MtxOfferPurchaseNotification MDC to query RS Gateway to include additional information related to the subscriber's parent group in a notification sent to an SMTP endpoint.

The sample demonstrates the following.
  • Create a Java class to do the following:
    • Filter notification messages for the MtxOfferPurchaseNotification.
    • Get the subscriber's subscriberId from the notification message.
    • Query RS Gateway for the subscriber's information and get the parentGroupId.
    • Query RS Gateway for the parent group's information, including the balance quantity and unit.
    • Use a custom filter to exclude fields in the query response.
    • Get the group's balances and enhance the current exchange's bodyMap to include the group balance.
  • Update the mtxSubscriberOfferPurchaseNotification.ftl FreeMarker template to include the balance name, balance quantity, and balance quantity unit. This information will be included in the message delivered to the SMTP endpoint.
    MtxOfferPurchaseNotification Fields lists the MtxOfferPurchaseNotification MDC fields:
    Table 2. MtxOfferPurchaseNotification Fields
    Field Type Description
    ResourceId Long ResourceId of the purchased offer.
    StartTime MtxTimestamp The StartTime specified in the offer purchase operation.
    EndTime MtxTimestamp The EndTime specified in the offer purchase operation.
  • Modify the Notification Server workflow to route the message through the custom Java class.

To run the sample, you must make some minor modifications to the sample source files included with the Notification Server.