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-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org

Reply via email to