You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Simon Kulessa <ku...@flexsecure.de> on 2016/03/31 11:20:29 UTC
JMX - Adding NotificationListener for existing MBean
Hi,
Tomcat (7.0.54) publishes certain information about itself into JMX so I
would like to add a NotificationListener
to some of these beans in case some specific values are changing.
To be more specific I would like to get a notification if the number of
current threads (currentThreadCount) in the ThreadPool
related to a connector is changing.
The Object name would be like this:
Catalina:type=ThreadPool,name="http-bio-8080"
I tried to do the following within a webapp, but the listener does not
seem to be invoked.
--
MBeanServer mBeanServer = ManagementFactory.getPlatformMBeanServer();
ObjectName name = new
ObjectName("Catalina:type=ThreadPool,name=\"http-bio-8080\"")
NotificationListener listener = new NotificationListener() {
@Override
public void handleNotification(Notification notification, Object
handback) {
System.out.println("Notification: " + notification);
}
});
mBeanServer.addNotificationListener(name, listener, null, null); // no
filter yet, so I assume that I should get every change on the object
--
I checked the class that is related to the published MBean
(org.apache.tomcat.util.modeler.BaseModelMBean) and it seems
to implement the proper interfaces for NotificationSupport.
I also found a method 'addAttributeChangeNotificationListener' (or
'addNotificationListener') in this class.
Do I need to invoke this method directly so a listener can be correctly
attached?
(It seems only then the BaseNotificationBroadcaster object is actually
created)
If so, how do I get access to it from within a webapp?
I hope somebody can help me out here.
Regards,
Simon
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org