1 Reply Latest reply on Apr 23, 2008 3:40 AM by Benjamin Cuthbert

    Remote RMI JMX listner

    Benjamin Cuthbert Newbie

      All

      Is there any example code on setting up a remote JMX RMI Adaptor and registering for events on a listner ?

      I did try the first section of this doc

      http://wiki.jboss.org/wiki/HowDoIAddANotificationListenerToARemoteMBeanServer

      but i got loads of errors running it.

        • 1. Re: Remote RMI JMX listner
          Benjamin Cuthbert Newbie

          By using the following

          MBeanServerConnection mbsc = (MBeanServerConnection) ctx.lookup("jmx/invoker/RMIAdaptor");
          //

          ObjectName serverInfo = new ObjectName("jboss.system:type=ServerInfo");
          mbsc.addNotificationListener(serverInfo, this, null, null);

          And then placing the following listner in my class

           public void handleNotification(Notification notification, Object handback) {
          
           System.out.println("\nReceived notification:");
           System.out.println("\tClassName: " + notification.getClass().getName());
           System.out.println("\tSource: " + notification.getSource());
           System.out.println("\tType: " + notification.getType());
           System.out.println("\tMessage: " + notification.getMessage());
           if (notification instanceof AttributeChangeNotification) {
           AttributeChangeNotification acn =
           (AttributeChangeNotification) notification;
           System.out.println("\tAttributeName: " + acn.getAttributeName());
           System.out.println("\tAttributeType: " + acn.getAttributeType());
           System.out.println("\tNewValue: " + acn.getNewValue());
           System.out.println("\tOldValue: " + acn.getOldValue());
           }
          
           }
          


          I don't get any events come through on the attributes, can you subscirbe to attribute changes