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