我试图了解如何使用Spring Integration 4.2(http://docs.spring.io/spring-integration/reference/htmlsingle/#mgmt-handler-features)中引入的Metrics框架来剖析我的Spring Integration应用程序。
我可以看到如何使用框架来监控频道和消息处理程序(端点)。如何监控使用@ServiceActivator
注释的bean?
for (String monitoredChannel : getMonitoredChannels()) {
MessageChannelMetrics channelMetrics = integrationManagementConfigurer.getChannelMetrics(monitoredChannel);
LOGGER.info("Channel {}, Send Count: {}", monitoredChannel, channelMetrics.getSendCount());
}
for (String monitoredHandler : getMonitoredHandlers()) {
MessageHandlerMetrics handlerMetrics = integrationManagementConfigurer.getHandlerMetrics(monitoredHandler);
LOGGER.info("Handler {}, Max Duration: {}", monitoredHandler, handlerMetrics.getDuration().getMax());
LOGGER.info("Handler {}, Min Duration: {}", monitoredHandler, handlerMetrics.getDuration().getMin());
LOGGER.info("Handler {}, Mean Duration: {}", monitoredHandler, handlerMetrics.getMeanDuration());
}
是否有类似的方法来监控命名的服务激活器?这就是我的integration-context.xml的样子:
<int:chain input-channel="messageReceived" output-channel="messageValidated" id="messageValidationChain">
<int:service-activator ref="enricher" method="getMessageAttributes" id="attributeEnricher" />
<int:service-activator ref="stateValidator" method="processMessage" id="stateValidator" />
<int:service-activator ref="attributeValidator" method="validateMessage" id="attributeValidator"/>
</int:chain>
我希望能够分析处理链中每个ServiceActivator
占用多长时间并跟踪指标,例如最小值,最大值,平均持续时间,消息计数等。
答案 0 :(得分:1)
它只是有效。
链中服务激活器消息处理程序的bean名称是
<chainId>.<elementId>.handler