1
2
3
4
5
6
7
8
9
10
11 package org.mule.transport.sftp.notification;
12
13 import org.mule.api.MuleMessage;
14 import org.mule.api.context.notification.EndpointMessageNotificationListener;
15 import org.mule.api.context.notification.ServerNotification;
16 import org.mule.context.notification.EndpointMessageNotification;
17
18 import java.util.Date;
19
20 import org.slf4j.Logger;
21 import org.slf4j.LoggerFactory;
22
23 public class EndpointMessageNotificationTestListener implements EndpointMessageNotificationListener
24 {
25 private final Logger logger = LoggerFactory.getLogger(getClass());
26
27 @Override
28 public void onNotification(ServerNotification notification)
29 {
30
31 EndpointMessageNotification endpointNotification;
32 if (notification instanceof EndpointMessageNotification)
33 {
34 endpointNotification = (EndpointMessageNotification) notification;
35 }
36 else
37 {
38 logger.debug(
39 "*** EndpointMessageNotificationTestListener RECEIVED UNKNOWN NOTIFICATION OF TYPE {}",
40 notification.getClass().getName());
41 return;
42 }
43
44 MuleMessage message = endpointNotification.getSource();
45 String msgType = message.getPayload().getClass().getName();
46 String correlationId = (String) message.getProperty("MULE_CORRELATION_ID", "?");
47
48
49 String endpointName = endpointNotification.getEndpoint();
50 String action = notification.getActionName();
51 String resourceId = notification.getResourceIdentifier();
52 String timestamp = new Date(notification.getTimestamp()).toString();
53
54 if (logger.isDebugEnabled())
55 {
56 logger.debug("OnNotification: " + notification.EVENT_NAME + "\nTimestamp=" + timestamp
57 + "\nMsgType=" + msgType + "\nAction=" + action + "\nResourceId=" + resourceId
58 + "\nEndpointName=" + endpointName +
59
60 "\nCorrelationId=" + correlationId + "");
61 }
62 }
63 }