6 Replies Latest reply on Dec 2, 2004 2:15 PM by dimitris

    Sending notifications from MBean to client

    mmigal

      I am using JBoss 4.x and have a number of MBeans registered. On the client side, I am using RMIAdapter to do the communication with the MBeans. I am looking for a way to do a notification from the MBeans on the server to the client. Can somebody point me towards the best way to do it? Sample code would be welcomed and appreciated.

      Michael

        • 1. Re: Sending notifications from MBean to client
          dimitris

          I haven't touched the RMIAdaptor for some time, but doesn't RMIAdaptor have an addNotificationListener() and removeNotificationListener on its interface?

          If that works as expected you'd just have to call the above methods and implement the following interface:

          public interface RMINotificationListener extends Remote
          {
           public void handleNotification(Notification notification, Object handback)
           throws RemoteException;
          }
          


          So that's more or less a remote version of the javax.management.NotificationListener interface

          • 2. Re: Sending notifications from MBean to client
            starksm64

            There are examples of this in the testsuite as well as the admin/devel guide.

            • 3. Re: Sending notifications from MBean to client
              mmigal

              In the 3.2.6 version, in order to receive JMX notifications, docs/examples/jmx/jmx-rmi-adaptor.sar file needed to be copied to the deploy directory, and jmx-invoker-adaptor-server.sar removed. Is it still necessary in the 4.0.0 version? I don't see the jmx-rmi-adaptor.sar in the 4.0.0 docs/examples/jmx directory.

              • 4. Re: Sending notifications from MBean to client
                starksm64

                No.

                • 5. Re: Sending notifications from MBean to client
                  mmigal

                  Thank you for quick responses.

                  I have another question though. If there are multiple clients that want to listen for notifications, does the ServiceMBeanSupport class handles this case? Should I pass a unique handback object when registering, so that the listener can be uniquely identified?

                  Michael

                  • 6. Re: Sending notifications from MBean to client
                    dimitris

                    Yes, you can have multiple clients without confusion.

                    The handback object is more or less of use to the Listener. If it has made many registrations to different MBeans it could use the handback as an id to quickly distinguish from which subscription a notification came when handleNotification() is called.