-
1. Re: jboss JMX notification type
dimitris Apr 19, 2007 12:21 PM (in response to leonz11)There is no comprehensive list of notifications, although I tried to make start in the JMX FAQ.
-
2. Re: jboss JMX notification type
leonz11 Apr 20, 2007 7:07 AM (in response to leonz11)thanx, dimitris.
I tried to subscribe the "org.jboss.system.server.stopped" in a simple MBean as the following sample code; but could not get this event notification when I shut down the server with control-C on windows.
--------------------------------------------------------
package notificationMbean;
import javax.management.Notification;
import javax.management.ObjectName;
import org.jboss.system.ListenerServiceMBeanSupport;
public class NotificationListener
extends ListenerServiceMBeanSupport
implements NotificationListenerMBean
{
// Constructors --------------------------------------------------
/**
* CTOR
**/
public NotificationListener()
{
// empty
}
// NotificationListenerMBean implementation ----------------------
// No attributes or operations in this example to implement!
// Lifecycle control (ServiceMBeanSupport) -----------------------
/**
* Start
**/
public void startService()
throws Exception
{
// subscribe for notification, true=dynamic
super.subscribe(true); // listener is me!
}
/**
* Stop
**/
public void stopService()
throws Exception
{
// unsubscribe for notifications
super.unsubscribe();
}
// ListenerServiceMBeanSupport override ------------------------
/**
* Overriden to add handling!
**/
public void handleNotification2(Notification notification, Object handback)
{
System.out.println("Got notification2: " + notification + ", handback: " + handback);
}
public void handleNotification(Notification notification, Object handback)
{
System.out.println("Got notification1: " + notification + ", handback: " + handback);
}
}
-----------------------------------------
service xml
-----------------------------------------
<subscription-list>
</subscription-list>
-------------------------------------------
can you see why I could not get the notification?
Thanx -
3. Re: jboss JMX notification type
leonz11 Apr 20, 2007 7:08 AM (in response to leonz11)service.xml:
<subscription-list>
<!--
-->
</subscription-list>
<!--
<subscription-list>
</subscription-list>
--> -
4. Re: jboss JMX notification type
leonz11 Apr 20, 2007 7:12 AM (in response to leonz11)<server> <mbean code="notificationMbean.NotificationListener" name="notificationMbean:name=NotificationListener"> <attribute name="SubscriptionList"> <subscription-list> <mbean name="jboss.system:type=Server"> <!-- <filter factory="NotificationFilterSupportFactory"> <enable type="org.jboss.system.server.stopped"/> </filter> --> <notification type="org.jboss.system.server.stopped"/> </mbean> </subscription-list> <!-- <subscription-list> <mbean name="*:service=invoker,*" handback="anObject"/> <mbean name="jboss.monitor:*"/> <notification type="JBOSS_MONITOR_NOTIFICATION"/> <mbean name="JMImplementation:type=MBeanServerDelegate"> <notification type="JMX.mbean.registered"/> </mbean> </subscription-list> --> </attribute> </mbean> </server>
-
5. Re: jboss JMX notification type
dimitris Apr 20, 2007 9:31 AM (in response to leonz11)What jboss version you are using? If I remember, there was a problem as to when this notification is produced, by I think I've fixed that recently.
Another thing, don't override handleNotification() because dynamic subscriptions do not work then. -
6. Re: jboss JMX notification type
leonz11 Apr 20, 2007 10:39 AM (in response to leonz11)I tested JBoss 4.0.2.
-
7. Re: jboss JMX notification type
dimitris Apr 20, 2007 10:43 AM (in response to leonz11)Try 4.0.4+
-
8. Re: jboss JMX notification type
leonz11 Apr 20, 2007 4:13 PM (in response to leonz11)yeap, it works on 4.0.4
one more question, dimtris:
when I override the method "handleNotification", this event is captured by this method; however, as you suggested I comment out this method, the event then is captured by "handleNotification2".
Can you tell how those "handleNotification" methods are used in JBoss JMX?
thanks,
LZ -
9. Re: jboss JMX notification type
dimitris Apr 21, 2007 9:38 AM (in response to leonz11)Simple:
According to the JMX spec, handleNotification(..) is the method that should be implemented by NotificationListeners.
The ListenerServiceMBeanSupport base class however, in order to implement the "dynamic" notification subscription feature (when doing subscribe(true)), it needs to monitor the registration/unregistration of mbeans in the mbean server and apply the subscription criteria.
So it overrides the handleNotification() method in the baseclass to intercept, act upon, and remove, those notifications, before passing on the call to the handleNotification2() method, that you are supposed to implement.
It just occurred to me I could have probably implemented it differently, by forking a seperate notification listener, but thats history now :) -
10. Re: jboss JMX notification type
leonz11 Apr 21, 2007 11:02 AM (in response to leonz11)ic.
Thanks,
LZ