JMX-Spring - 什么时候是“JMXNotification”?播出?

发布于 2024-10-04 01:05:26 字数 1123 浏览 0 评论 0原文

我正在浏览 Spring 文档< /a> 上的 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 通知 已广播?是在 JMX 公开的属性值更改时发生吗?

请帮助我了解这一点。

谢谢!

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!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

痕至 2024-10-11 01:05:26

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

我还没读过,但乍一看这篇文章 似乎以相当广泛的方式涵盖了该主题。

而且,正如您所看到的,属性更改是广播通知时发生的事件之一。

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.

小梨窩很甜 2024-10-11 01:05:26

也许有点太晚了..但是由于这个问题没有被接受的答案,我会发布我的答案。

Spring 文档还指出:

Spring 的 JMX 通知发布支持中的关键接口是NotificationPublisher 接口(在 org.springframework.jmx.export.notification 包中定义)。任何要通过 MBeanExporter 实例导出为 MBean 的 bean 都可以实现相关的NotificationPublisherAware 接口来访问NotificationPublisher 实例。

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

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

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文