[jboss-user] [Management, JMX/JBoss] - How can I receive notification when Servlet stats change ?

francis1970 do-not-reply at jboss.com
Wed Jun 18 03:07:24 EDT 2008


Hi all !
I'd need to add a notification listener that warns me when Servlet stats change. Until now I have been using successfully this code for my MBeans notifications

   NotificationListener notificationListener = new NotificationListener() {
  |     public void handleNotification(Notification notification, Object handback) {
  |         System.out.println("Notification received!");
  |         System.out.println("UserObject: " + notification.getUserData());
  |     }
  | };
  | try {
  | 
  |         ArrayList servers = MBeanServerFactory.findMBeanServer(null);
  |         if (servers == null)
  |           throw new Exception("No MBeanServer found.");
  |         MBeanServer server = (MBeanServer)servers.get(0);
  |         
  |     // find the local MBeanServer
  |     ObjectName objectName = new ObjectName("jboss.management.local:J2EEApplication=null,J2EEServer=Local,WebModule=stats.war,j2eeType=Servlet,name=ControllerServlet");
  |     server.addNotificationListener(objectName, notificationListener, null, null);
  |     
  |     Thread.sleep(20000);
  | } catch (MalformedObjectNameException ex) {
  |     // manage
  | } catch (InstanceNotFoundException ex) {
  |     // manage
  | }   

Anyway once I have registered to my Servlet nothing happens, even if the stats change (because I invoke my Servlet).
How can I get notification when my Servlet "ControllerServlet" is invoked ?

Thanks a lot
Francesco

View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4158892#4158892

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4158892



More information about the jboss-user mailing list