01: package com.bostechcorp.cbesb.runtime.ccsl.jbi.messaging.notification;
02:
03: import java.util.concurrent.SynchronousQueue;
04:
05: import javax.management.Notification;
06: import javax.management.NotificationListener;
07:
08: import org.apache.commons.logging.Log;
09: import org.apache.commons.logging.LogFactory;
10:
11: import com.bostechcorp.cbesb.common.util.ErrorUtil;
12:
13: public class MessageNotificationListener implements
14: NotificationListener {
15: private static SynchronousQueue<Object> MessageNotificationQueue = new SynchronousQueue<Object>(
16: true);
17: protected final transient Log logger = LogFactory
18: .getLog(getClass());
19:
20: public void handleNotification(Notification notification,
21: Object handback) {
22:
23: if (notification instanceof MessageProcessNotification) {
24: MessageProcessNotification mpn = (MessageProcessNotification) notification;
25: logger.debug(" got one notification:" + mpn.endpointName);
26: logger.debug(" got one notification:"
27: + mpn.getSequenceNumber());
28: logger.debug(this );
29: // System.out.println("\tMessage: " + mpn.getMessage());
30: // System.out.println("\tSequence Num: " + mpn.getSequenceNumber());
31: // System.out.println("latency:"+mpn.getLatency());
32: try {
33: MessageNotificationQueue.put(mpn);
34: } catch (InterruptedException e) {
35: ErrorUtil.printError("put to queue error:", e);
36: }
37: // System.out.println("\tMessage Count:"+MessageNotificationQueue.size());
38: }
39: }
40:
41: public static SynchronousQueue<Object> getMessageNotificationQueue() {
42: return MessageNotificationQueue;
43: }
44:
45: }
|