MBEE没有在jvisualVM中显示

时间:2016-06-09 19:07:01

标签: java spring-integration mbeans spring-jmx

Gary Russels's 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。 image of MBeans in spring.integration

是否有任何其他事情要做,以便在visualVM中显示带注释的MBean?

感谢。

1 个答案:

答案 0 :(得分:2)

<context:mbean-export/>适合你。

<int-jmx:mbean-export>是Spring Integration组件的自定义MBeanExporter。其他所有内容都应由标准的Spring <context:mbean-export/>管理。