10 Replies Latest reply on Apr 21, 2007 11:02 AM by leonz11

    jboss JMX notification type

      Where can I find a documentation for available JBoss JMX notification type?

      Thanks,

        • 1. Re: jboss JMX notification type
          dimitris

          There is no comprehensive list of notifications, although I tried to make start in the JMX FAQ.

          • 2. Re: jboss JMX notification type

            thanx, dimitris.

            I tried to subscribe the "org.jboss.system.server.stopped" in a simple MBean as the following sample code; but could not get this event notification when I shut down the server with control-C on windows.

            --------------------------------------------------------
            package notificationMbean;

            import javax.management.Notification;
            import javax.management.ObjectName;

            import org.jboss.system.ListenerServiceMBeanSupport;


            public class NotificationListener
            extends ListenerServiceMBeanSupport
            implements NotificationListenerMBean
            {
            // Constructors --------------------------------------------------
            /**
            * CTOR
            **/
            public NotificationListener()
            {
            // empty
            }

            // NotificationListenerMBean implementation ----------------------
            // No attributes or operations in this example to implement!

            // Lifecycle control (ServiceMBeanSupport) -----------------------
            /**
            * Start
            **/
            public void startService()
            throws Exception
            {
            // subscribe for notification, true=dynamic
            super.subscribe(true); // listener is me!
            }

            /**
            * Stop
            **/
            public void stopService()
            throws Exception
            {
            // unsubscribe for notifications
            super.unsubscribe();
            }

            // ListenerServiceMBeanSupport override ------------------------
            /**
            * Overriden to add handling!
            **/
            public void handleNotification2(Notification notification, Object handback)
            {
            System.out.println("Got notification2: " + notification + ", handback: " + handback);
            }

            public void handleNotification(Notification notification, Object handback)
            {
            System.out.println("Got notification1: " + notification + ", handback: " + handback);
            }
            }

            -----------------------------------------

            service xml
            -----------------------------------------





            <subscription-list>



            </subscription-list>



            -------------------------------------------

            can you see why I could not get the notification?

            Thanx

            • 3. Re: jboss JMX notification type

              service.xml:






              <subscription-list>

              <!--


              -->


              </subscription-list>

              <!--
              <subscription-list>






              </subscription-list>
              -->




              • 4. Re: jboss JMX notification type

                 

                <server>
                 <mbean code="notificationMbean.NotificationListener"
                 name="notificationMbean:name=NotificationListener">
                
                 <attribute name="SubscriptionList">
                
                 <subscription-list>
                 <mbean name="jboss.system:type=Server">
                 <!-- <filter factory="NotificationFilterSupportFactory">
                 <enable type="org.jboss.system.server.stopped"/>
                 </filter>
                 -->
                 <notification type="org.jboss.system.server.stopped"/>
                 </mbean>
                 </subscription-list>
                
                 <!--
                 <subscription-list>
                 <mbean name="*:service=invoker,*" handback="anObject"/>
                 <mbean name="jboss.monitor:*"/>
                 <notification type="JBOSS_MONITOR_NOTIFICATION"/>
                 <mbean name="JMImplementation:type=MBeanServerDelegate">
                 <notification type="JMX.mbean.registered"/>
                 </mbean>
                 </subscription-list>
                 -->
                 </attribute>
                 </mbean>
                </server>


                • 5. Re: jboss JMX notification type
                  dimitris

                  What jboss version you are using? If I remember, there was a problem as to when this notification is produced, by I think I've fixed that recently.

                  Another thing, don't override handleNotification() because dynamic subscriptions do not work then.

                  • 6. Re: jboss JMX notification type

                    I tested JBoss 4.0.2.

                    • 7. Re: jboss JMX notification type
                      dimitris

                      Try 4.0.4+

                      • 8. Re: jboss JMX notification type

                        yeap, it works on 4.0.4

                        one more question, dimtris:

                        when I override the method "handleNotification", this event is captured by this method; however, as you suggested I comment out this method, the event then is captured by "handleNotification2".

                        Can you tell how those "handleNotification" methods are used in JBoss JMX?

                        thanks,

                        LZ

                        • 9. Re: jboss JMX notification type
                          dimitris

                          Simple:

                          According to the JMX spec, handleNotification(..) is the method that should be implemented by NotificationListeners.

                          The ListenerServiceMBeanSupport base class however, in order to implement the "dynamic" notification subscription feature (when doing subscribe(true)), it needs to monitor the registration/unregistration of mbeans in the mbean server and apply the subscription criteria.

                          So it overrides the handleNotification() method in the baseclass to intercept, act upon, and remove, those notifications, before passing on the call to the handleNotification2() method, that you are supposed to implement.

                          It just occurred to me I could have probably implemented it differently, by forking a seperate notification listener, but thats history now :)

                          • 10. Re: jboss JMX notification type

                            ic.

                            Thanks,

                            LZ