简体   繁体   中英

JMX-Spring - When is a 'JMXNotification' broadcasted?

I was going through the Spring documentation on JMX and came across the following paragraph:

By configuring NotificationListeners in place, every time a JMX Notification is broadcast
from the target MBean (bean:name=testBean1),the ConsoleLoggingNotificationListener bean
that was registered as a listener via the notificationListenerMappings property will be 
notified.

And this is how the ConsoleLoggingNotificationListener is implemented:

public class ConsoleLoggingNotificationListener
               implements NotificationListener, NotificationFilter {

    public void handleNotification(Notification notification, Object handback) {
        System.out.println(notification);
        System.out.println(handback);
    }

    public boolean isNotificationEnabled(Notification notification) {
        return AttributeChangeNotification.class.isAssignableFrom(notification.getClass());
    }
}

But, since I am a newbie, I want to know when is a JMX Notification broadcasted? Is it when the a JMX-exposed attribute's value is changed ?

Please help me know this.

Thanks!

Maybe it is a bit too late.. however since this question has no accepted answer I'll post my answer.

Spring documentation also says:

The key interface in Spring's JMX notification publication support is the NotificationPublisher interface (defined in the org.springframework.jmx.export.notification package). Any bean that is going to be exported as an MBean via an MBeanExporter instance can implement the related NotificationPublisherAware interface to gain access to a NotificationPublisher instance.

The answer you are looking for is in the final sentence of above excerpt

Ref: http://static.springsource.org/spring/docs/3.0.0.M3/reference/html/ch24s07.html#jmx-notifications-listeners

I guess this question has nothing to do with Spring per se. If I understand correctly the notifications which are meant here are javax.management.Notification objects .

I haven't read it but at the first glance this article seems to cover the topic in a quite extensive manner.

And, as you can see attribute change is one of the events when a notification is broadcast.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM