public void addNotificationListener( ObjectName objName, NotificationListener listener, NotificationFilter filter, Object handback);where
If you have any resources with aliases, and you add listeners for notifications from both a resource and its aliases, you will receive multiple identical notifications. It is a good idea to ensure that object names passed as parameters to the addNotificationListener() method do not contain the property key-value pair "type=alias".
Having called this API, the user's listener will now be added to the broadcaster's table of listeners.
public void handleNotification ( Notification notification, Object handback);where:
public String getType(); // returns the notification type public Object getSource(); // returns the source of the notification public long getSequence(); // returns the sequence number of // the notification [1] public String getMessage(); // returns a text message associated with // the notification public Object getUserData(); // returns the handback object
The following example shows how the agent could set up listeners for certain MQe MBeans. In this example, the user is only interested in receiving notifications from MBeans representing application queues belonging to the local queue manager TestQueueManager:
/* find all the mbeans and set up listeners for them */ ObjectName scope = new ObjectName("com.ibm.MQe_TestQueueManager_ApplicationQueues:*"); Set results = mbeanServer.queryNames(scope,null); Iterator iter = results.iterator(); while(iter.hasNext()) { /* for each bean, check that it is not an alias MBean – * these beans have type=alias in the ObjectName */ ObjectName objName = (ObjectName)iter.next(); String type = objName.getKeyProperty("type"); if(type == null || !type.equals("alias")) { /* add a listener */ mbeanServer.addNotificationListener(objName,this,null,null); } }