开发者

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

开发者 https://www.devze.com 2023-01-27 03:25 出处:网络
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

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(handbac开发者_如何学Pythonk);
    }

    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!


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.


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

0

精彩评论

暂无评论...
验证码 换一张
取 消