Override a Notification Type Handler

The Notification Framework allows you to override a notification type handler for a specific message.

To override the handler for a specific message, create a new bean. For example, create a new bean to override the handler for MtxOfferPurchaseNotification in the mtx_notifier_camel.xml configuration file.

<bean id="offerPurchaseNotificationHandler" class="com.matrixx.camelNotifier.misc.OfferPurchaseNotificationHandlerTest" scope="prototype"/>

The following code shows a class that adds an additional value to the body map.

Sample Class

///=============================================================================
///
/// Copyright 2019, MATRIXX Software, Inc. All rights reserved.
///
///-----------------------------------------------------------------------------
///
/// @file
/// @author     original: Developer Engineer
/// @author     last modified by: $Author: adam.myers $
/// @date       $Date: 2024-10-30 09:28:16 -0600 (Wed, 30 Oct 2024) $
///
/// $Id: 
///
///=============================================================================
 
package com.matrixx.camelNotifier.misc;

import java.util.Map;
import java.util.UUID;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.context.support.AbstractApplicationContext;

import com.matrixx.camelNotifier.configuration.NotifierConfiguration;
import com.matrixx.camelNotifier.gateway.RSGatewayService;
import com.matrixx.camelNotifier.handler.OfferPurchaseNotificationHandler;
import com.matrixx.datacontainer.mdc.MtxNotification;

/**
 * The Class OfferPurchaseNotificationHandler5100.
 */
public class OfferPurchaseNotificationHandlerTest extends OfferPurchaseNotificationHandler {
    public static final Logger LOG = LoggerFactory.getLogger(OfferPurchaseNotificationHandlerTest.class);
public OfferPurchaseNotificationHandlerTest(MtxNotification notification, NotifierConfiguration configuration,
            AbstractApplicationContext context, RSGatewayService m_rsGatewaySvc)
    {
        super(notification, configuration, context, m_rsGatewaySvc);

        LOG.info("> OVERRIDE BEAN - Handler");
    }

    @Override
    public Map<String, Object> getNotificationData()
    {
        Map<String, Object> map = super.getNotificationData();
        
        String key = "testCustomizedKey";
        String value = UUID.randomUUID().toString();

        LOG.info("> OVERRIDE BEAN - Handler, adding key=" + key + ", value=" + value);
        
        map.put(key, value);
        
        return map;
    }

}

Use the following to access the new map value in the template:

...
TEST body.testCustomizedKey=${body.testCustomizedKey}
...

The message format now includes:

TEST body.testCustomizedKey=1d62c3b6-ffd4-4018-bc88-c1fb0bceea77

Hi Subscriber A,

You have purchased On Demand Daily Asset plan. Your offer is valid from Wednesday, January 16, 2019, 04:11 PM (PST).
Catalog item name is On Demand Daily Asset.