JMX的春天 - 当一个“JMXNotification”时间播出?(JMX-Spring - Wh

2019-10-29 06:47发布

我经历的Spring 文档上JMX和整个下段传来:

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.

这是怎么ConsoleLoggingNotificationListener实现:

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());
    }
}

但是,因为我是新手,我想知道的是,当一个JMX Notification时间播出? 它是在一个JMX暴露属性的值被改变

请帮我知道这一点。

谢谢!

Answer 1:

我想这个问题无关与Spring本身。 如果我理解正确的话,其在这里指的通知是javax.management.Notification对象 。

我没有看过,但第一眼这篇文章似乎涵盖在一个相当广泛的方式的话题。

而且,正如你所看到的属性变化时的通知是广播的事件之一。



Answer 2:

也许这是一个有点太晚了。但是因为这个问题没有公认的答案我会后我的答案。

Spring文档也说:

在Spring的JMX通知发布支持中,关键的是NotificationPublisher接口(在包org.springframework.jmx.export.notification定义)。 这是怎么回事任何bean来通过MBeanExporter实例可以导出为一个MBean可以实现对应的NotificationPublisherAware接口来访问NotificationPublisher的实例。

你正在寻找的答案在上面摘录的最后一句

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



文章来源: JMX-Spring - When is a 'JMXNotification' broadcasted?