我正在使用 Spring 集成,但想使用 jmxtrans-agent 来监控我的拆分器。就像下面的简单示例一样,我尝试计算到达拆分器的请求数。
@ManagedResource
public class Splitter {
private final AtomicInteger count = new AtomicInteger();
@ManagedAttribute
public int getCount(){
return this.count.get();
}
public List<JsonNode> split(Message<ArrayNode> message) {
count.incrementAndGet();
...
}
}
// spring integration workflow
<int:gateway id="myGateway" service-interface="someGateway" default-request-channel="splitChannel" error-channel="errorChannel" default-reply-channel="replyChannel" async-executor="MyThreadPoolTaskExecutor"/>
<int:splitter id="mySplitter" input-channel="splitChannel" output-channel="transformChannel" method="split">
<bean class="Splitter" />
</int:splitter>
// in MBeanExporter, I added
<entry key="myApplication:type=Splitter,name=splitter" value-ref="mySplitter" />
// query
<query
objectName='myApplication:type=Splitter,name=splitter'
attribute='Count'
resultAlias='myApplication.Splitter.count'/>
<collectIntervalInSeconds>20</collectIntervalInSeconds>
我无法查询数据,收到此错误。
javax.management.AttributeNotFoundException: getAttribute failed: ModelMBeanAttributeInfo not found for number
at javax.management.modelmbean.RequiredModelMBean.getAttribute(RequiredModelMBean.java:1524)
at org.springframework.jmx.export.SpringModelMBean.getAttribute(SpringModelMBean.java:109)
- 这个分离器是否必须实现一些类来管理资源?
- 我认为spring集成bean范围是每个请求,如果jmxtrans-agent每20s收集一次信息,它会错过数据吗?