我试图了解如何使用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
花费的时间,并跟踪最小,最大,平均持续时间,消息计数等指标。 最佳答案
它只是工作。
链中服务激活程序消息处理程序的Bean名称为
<chainId>.<elementId>.handler