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。
是否有任何其他事情要做,以便在visualVM中显示带注释的MBean?
感谢。
答案 0 :(得分:2)
<context:mbean-export/>
适合你。
<int-jmx:mbean-export>
是Spring Integration组件的自定义MBeanExporter
。其他所有内容都应由标准的Spring <context:mbean-export/>
管理。