class AcmMessageProcessorNotificationListener implements MessageProcessorNotificationListener<MessageProcessorNotification> {

    @Override
    public void onNotification(MessageProcessorNotification notification)
    {
        log.trace("Mule message processor notification listener called");

        MuleEvent event = notification.getSource();

        if (notification.getAction() == MessageProcessorNotification.MESSAGE_PROCESSOR_PRE_INVOKE)
        {
            if ((event.getSessionVariable(MDCConstants.EVENT_MDC_REQUEST_ID_KEY) == null)
                    && (event.getMessage().getInboundProperty(MDCConstants.EVENT_MDC_REQUEST_ID_KEY) != null))
            {
                // set session variables if missing
                event.setSessionVariable(MDCConstants.EVENT_MDC_REQUEST_ID_KEY,
                        event.getMessage().getInboundProperty(MDCConstants.EVENT_MDC_REQUEST_ID_KEY));
                event.setSessionVariable(MDCConstants.EVENT_MDC_REQUEST_REMOTE_ADDRESS_KEY,
                        event.getMessage().getInboundProperty(MDCConstants.EVENT_MDC_REQUEST_REMOTE_ADDRESS_KEY));
                event.setSessionVariable(MDCConstants.EVENT_MDC_REQUEST_USER_ID_KEY,
                        event.getMessage().getInboundProperty(MDCConstants.EVENT_MDC_REQUEST_USER_ID_KEY));
                event.setSessionVariable(MDCConstants.EVENT_MDC_REQUEST_ALFRESCO_USER_ID_KEY,
                        event.getMessage().getInboundProperty(MDCConstants.EVENT_MDC_REQUEST_ALFRESCO_USER_ID_KEY));
            }

            // set MDC variables from message session properties
            MDC.put(MDCConstants.EVENT_MDC_REQUEST_ID_KEY, event.getSessionVariable(MDCConstants.EVENT_MDC_REQUEST_ID_KEY));
            MDC.put(MDCConstants.EVENT_MDC_REQUEST_REMOTE_ADDRESS_KEY,
                    event.getSessionVariable(MDCConstants.EVENT_MDC_REQUEST_REMOTE_ADDRESS_KEY));
            MDC.put(MDCConstants.EVENT_MDC_REQUEST_USER_ID_KEY, event.getSessionVariable(MDCConstants.EVENT_MDC_REQUEST_USER_ID_KEY));
            MDC.put(MDCConstants.EVENT_MDC_REQUEST_ALFRESCO_USER_ID_KEY,
                    event.getSessionVariable(MDCConstants.EVENT_MDC_REQUEST_ALFRESCO_USER_ID_KEY));
        }

        if (notification.getAction() == MessageProcessorNotification.MESSAGE_PROCESSOR_POST_INVOKE)
        {
            if (isAuditable(notification))
            {
                audit(notification);
            }
        }
    }

}