10 Replies Latest reply on Nov 1, 2006 7:36 AM by Dimitris Andreadis

    Problem with notification filter?

    Mike Cev Newbie

      I have a listener bean that subscribes to some of the monitoring beans. I am trying to filter notification coming from "JMImplementation:type=MBeanServerDelegate" with type "JMX.mbean.registered" and "JMX.mbean.unregistered". I have added mbean to my subscription list with filter attributes but it doesn't seem to work.
      Ant ideas?

      <mbean code="com.bfm.app.monitoring.ViewserverJMXNotificationHandler"
       name="jboss.monitor:service=ViewserverMonitoring" >
       <attribute name="SubscriptionList">
       <subscription-list>
       <mbean name="jboss.monitor:service=MemoryMonitor">
       <notification type="jboss.alarm.memory"/>
       </mbean>
       <mbean name="jboss.monitor:service=JDBCMonitor">
       <notification type="jboss.notification.jdbc"/>
       </mbean>
       <mbean name="jboss.system:service=Logging,type=JMXNotificationAppender">
       <notification type="jboss.notification.logging"/>
       </mbean>
       <mbean name="JMImplementation:type=MBeanServerDelegate">
       <filter factory="NotificationFilterSupportFactory">
       <enable type="JMX.mbeank"/>
       </filter>
       </mbean>
       </subscription-list>
       </attribute>
       </mbean>


        • 1. Re: Problem with notification filter?
          Dimitris Andreadis Master

          You have misspelled "JMX.mbeank" (k)

          You may try also MBeanServerNotificationFilterFactory, if interested in receiving register/unregister notifications for particular mbeans (enable object-name="...")

          • 2. Re: Problem with notification filter?
            Mike Cev Newbie

            I have corrected the spelling mistake and still getting notifications from JMImplementation:type=MBeanServerDelegate with type = JMX.mbean.registered. I also tried with filter:

            <filter factory="NotificationFilterSupportFactory">
             <enable type="JMX.mbean.registered"/>
             <enable type="JMX.mbean.unregistered"/>
             </filter>

            Here is the config:
            <mbean code="com.bfm.app.monitoring.ViewserverJMXNotificationHandler"
             name="jboss.monitor:service=ViewserverMonitoring" >
             <attribute name="SubscriptionList">
             <subscription-list>
             <mbean name="jboss.monitor:service=MemoryMonitor">
             <notification type="jboss.alarm.memory"/>
             </mbean>
             <mbean name="jboss.monitor:service=JDBCMonitor">
             <notification type="jboss.notification.jdbc"/>
             </mbean>
             <mbean name="jboss.system:service=Logging,type=JMXNotificationAppender">
             <notification type="jboss.notification.logging"/>
             </mbean>
             <mbean name="JMImplementation:type=MBeanServerDelegate">
             <filter factory="NotificationFilterSupportFactory">
             <enable type="JMX.mbean.registered"/>
             <enable type="JMX.mbean.unregistered"/>
             </filter>
             </mbean>
             </subscription-list>
             </attribute>
             </mbean>
            


            • 4. Re: Problem with notification filter?
              Mike Cev Newbie

              But still getting the notifications!!!! Isn't that supposed to filter the notifications?

              • 5. Re: Problem with notification filter?
                Dimitris Andreadis Master

                You have understood wrong. The filter specifies which notifications to allow, not which to discart.

                • 6. Re: Problem with notification filter?
                  Mike Cev Newbie

                  Then what is the difference between:

                  <mbean name="JMImplementation:type=MBeanServerDelegate">
                   <filter factory="NotificationFilterSupportFactory">
                   <enable type="JMX.mbean.registered"/>
                   <enable type="JMX.mbean.unregistered"/>
                   </filter>
                   </mbean>



                  and:

                  <mbean name="JMImplementation:type=MBeanServerDelegate">
                   <notification type="jMX.mbean.registered"/>
                   <notification type="jMX.mbean.unregistered"/>
                   </mbean>


                  If they are the same the how would I filter out a specific notification type? I am tring to NOT to receive bean registeration messages.

                  • 7. Re: Problem with notification filter?
                    Dimitris Andreadis Master

                    The 2 examples are equivalent. The 2nd was the initial syntax, the 1st was a more generic extension that allowed the plugin-in of arbitrary filter factorys.

                    I've provided already 4 filter factories that all work by 'enabling' what you want to receive.

                    It wouldn't be very hard to extend those or write your own filter factory that works by instead 'disabling' what you don't want to receive.

                    However, when it comes to the notifications emitted by the MBeanServerDelegate mbean, there is little point in disabling those 2 notifications types, because those are the only notifications this mbean produces. If you don't want to receive them, simply remove this mbean from the subscription list.

                    • 8. Re: Problem with notification filter?
                      Mike Cev Newbie

                      Thank you for the prompt replies. Unfortunalty removing the mbean from the subscription does not stop the messages from coming in. Is this something by defeault all MBeans register to?

                      this is what I removed:

                      <mbean name="JMImplementation:type=MBeanServerDelegate">
                       <filter factory="NotificationFilterSupportFactory">
                       <enable type="JMX.mbean.registered"/>
                       <enable type="JMX.mbean.unregistered"/>
                       </filter>
                       </mbean>



                      this is the config:
                      <mbean code="com.bfm.app.monitoring.ViewserverJMXNotificationHandler"
                       name="jboss.monitor:service=ViewserverMonitoring" >
                       <attribute name="SubscriptionList">
                       <subscription-list>
                       <mbean name="jboss.monitor:service=MemoryMonitor">
                       <notification type="jboss.alarm.memory"/>
                       </mbean>
                       <mbean name="jboss.monitor:service=JDBCMonitor">
                       <notification type="jboss.notification.jdbc"/>
                       </mbean>
                       <mbean name="jboss.system:service=Logging,type=ViewserverNotificationAppender">
                       <notification type="jboss.notification.logging"/>
                       </mbean>
                       </subscription-list>
                       </attribute>
                       </mbean>


                      • 9. Re: Problem with notification filter?
                        Mike Cev Newbie

                        I found out what was happening. I should have mentioned that my ViewserverJMXNotificationHandler extends from ListenerServiceMBeanSupport
                        which in the the init method subscribed to Mbean registeration type

                        private void init()
                         {
                         // just pickup a unique object
                         this.myHandback = new Integer(Integer.MAX_VALUE);
                        
                         // allow only registration events
                         this.myFilter = new NotificationFilterSupport();
                         this.myFilter.enableType(MBeanServerNotification.REGISTRATION_NOTIFICATION);
                         }


                        I was avoding to implement all the subscription and notification methods which are already provided by the ListenerServiceMBeanSupport.

                        • 10. Re: Problem with notification filter?
                          Dimitris Andreadis Master

                          If you read carefully http://www.jboss.org/wiki/Wiki.jsp?page=ListenerServiceMBeanSupport

                          you must override handleNotification2(), not handleNotification().

                          This is needed so the baseclass can implement dynamic subscriptions, if needed.