Selecting Notification Endpoints Based on Subscriber State

The Notification Framework can select different endpoints for delivering notification messages based on the state of a subscriber.

For example, if all data is exhausted for a subscriber account, the message can be delivered by way of SMS instead of by email. The subscriber's standard notification preference for delivery channel can be overridden as needed (for example, the notification framework can select email even if the notification preference is set to Push Notification or SMS).

When selecting notification endpoints based on subscriber state, the notification framework analyzes the notification message type and the subscriber state, and then calculates the best endpoint to deliver the notification message.

To enable the notification framework to dynamically select an endpoint in this way, you use the Notification Server overrideMtxRecipientList extension point available in the mtx_notifier_camel.xml configuration file.

The default implementation for overrideMtxRecipientList is com.matrixx.camelNotifier.route.OverrideMtxRecipientList:

<bean id="overrideMtxRecipientList" class="com.matrixx.camelNotifier.route.OverrideMtxRecipientList" />

To customize, you create a new bean extend class com.matrixx.camelNotifier.route.OverrideMtxRecipientList and override method

protected String getNewMtxRecipientList(Exchange exchange)

to return a route id such as direct:smtpRoute.

You must edit the mtx_notifier_camel.xml file to change the value of class= to the class name of the new bean. For example, if the new class name is com.customer.mtx.MyOverrideMtxRecipientList:

<bean id="overrideMtxRecipientList" class="com.customer.mtx.MyOverrideMtxRecipientList" />

Within this class, you can access the current notification:

MtxNotification mtxNotification = NotificationUtils.getMtxNotification(exchange);

The following shows a sample class.

Sample Class

package com.matrixx.camelNotifier.route;
 
import org.apache.camel.Exchange;
import org.apache.camel.Processor;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
 
/**
 * The Class OverrideMtxRecipientList.
 */
public class OverrideMtxRecipientList implements Processor {
 
    /** The Constant LOGGER. */
    private static final Logger LOGGER = LoggerFactory.getLogger(OverrideMtxRecipientList.class);
 
    /*
     * (non-Javadoc)
     *
     * @see org.apache.camel.Processor#process(org.apache.camel.Exchange)
     */
    @Override
    public void process(Exchange exchange) throws Exception
    {
        String currentValue = (String) exchange.getIn().getHeader("mtxRecipientList");
        String newValue = getNewMtxRecipientList(exchange);
        if (newValue != null) {
            if (LOGGER.isDebugEnabled()) {
                LOGGER.debug("OVERRIDE mtxRecipientList: currentValue=" + currentValue + ", newValue=" + newValue);
            }
            exchange.getIn().setHeader("mtxRecipientList", newValue);
        }
    }
 
    /**
     * Gets the new mtx recipient list.
     *
     * @param exchange
     *            the exchange
     * @return the new mtx recipient list
     */
    protected String getNewMtxRecipientList(Exchange exchange)
    {
        return null;
    }
 
}