I am trying to understand how to profile my Spring Integration application using the Metrics framework introduced in the Spring Integration 4.2 (http://docs.spring.io/spring-integration/reference/htmlsingle/#mgmt-handler-features).
I can see how to use the framework to monitor Channels and Message Handlers (end points). How can I monitor beans that are annotated with @ServiceActivator
?
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());
}
Is there a similar way to monitor named Service Activators? This what my integration-context.xml looks like:
<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>
I want to be able to profile how long each ServiceActivator
in a processing chain takes and keep track of metrics such as min, max, mean duration, message counts etc.