Spring 集成 - 将 IntegrationManagementConfigurer 与服务激活器一起使用

Spring Integration - Using IntegrationManagementConfigurer with Service Activators

我想了解如何使用 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());
}

是否有类似的方法来监控指定的服务激活器?这就是我的集成-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