2

Gary Russels 的 Monitoring Spring Integration应用程序很棒。

我想添加简单的 MBean 来监控应用程序。这是我的代码:

package com.example;

import org.springframework.jmx.export.annotation.ManagedOperation;
import org.springframework.jmx.export.annotation.ManagedResource;
import org.springframework.stereotype.Component;

@Component
@ManagedResource(objectName="myapp:application=hello")

public class HelloBean {

    @ManagedOperation
    public String sayHello(String name) {
       return "Hello " + name;
    }
}

我还在 spring-context xml 文件中添加了以下内容:

<context:mbean-server />
<int-jmx:mbean-export id="integrationMBeanExporter" default-domain="spring.application" />

<bean id="helloBean" class="com.example.HelloBean" />

当我查看 jVisualVM 时,我没有看到 bean。我可以在 spring.application 域中看到 MessageChannel,但看不到我的 MBean。 spring.integration 中 MBean 的图像

要让带注释的 MBean 在 VisualVM 中显示,还有其他事情要做吗?

谢谢。

4

1 回答 1

2

<context:mbean-export/>是给你的。

<int-jmx:mbean-export>MBeanExporterSpring Integration 组件的自定义。其他一切都应由标准 Spring 管理<context:mbean-export/>

于 2016-06-09T19:22:16.607 回答