This forum is now a read-only archive. All commenting, posting, registration services have been turned off. Those needing community support and/or wanting to ask questions should refer to the Tag/Forum map, and to http://spring.io/questions for a curated list of stackoverflow tags that Pivotal engineers, and the community, monitor.

AnnouncementAnnouncement Module

Collapse

No announcement yet.

Does Spring Integration provide any out-of-box solution to capture execution time ?Page Title Module

Does Spring Integration provide any out-of-box solution to capture execution time ?

Jun 28th, 2013, 02:20 AM

Hi

I've a simple requirement to capture my application's overall execution time for a use case so that I can judge the performance of my app.

The use case is a below:

Client makes a REST request. The request is recvd by a POJO that in-turn places the request on the Spring Integration's Gateway.
From hereon, the request is processed by various external and internal components that are invoked using <chain> elements.
While to few external components, invoke is asynchronous (via JMS), for others it is synchronous (via REST).
However at the end, handle comes back to Gateway's default-reply-channel.

I need to know that when the handle comes back to the Gateway's default-reply-channel, is there a way to know what was the total time taken by the request to get processed (i.e., starting from the time it was put on Gateway until the time response was recvd on Gateway's default-reply-channel) ?

I know that I can handle it through code but just need to know if Spring Integration can provide an out-of-box solution.

If you use only DirectChannels (no queue channels or executor channels), you can enable JMX and use the sendDuration property of the initial request channel's metrics. It's an exponential moving average though; if you want to capture the response time of each individual request you'll have to do it in the POJO that calls the gateway.

Spring provides a convenient StopWatch class for this purpose.

Comment

Do you think it could be a good proposition to have this feature provided in upcoming version (if any) of Spring Integration framework ?
Will that not be a "nice" feature to provide user with an attribute at "Gateway" level (or for that matter even at "chain" level) using which user can ask the framework to calculate the time elapsed between when a message was put on it and when the response was recvd on its "output-channel"/"reply-channel" ?

Comment

I meant some mechanism to get the time for each and "every" request that is put on the Gateway (i.e., the elapsed time when the request was placed on Gateway and when a response was recvd on its reply-channel).

Comment

I thought of that but problem with "my" use case is, in the overall execution chain, few external components have to be invoked asynchronously (via JMS).
I'm thinking of trying to achieve this through wire-tap interceptor.
I just read about this interceptor in reference doc but not clear on one point (though an attempt has been made in the reference doc to clarify the point specifically):
I understand that wire-tap can route the "same" message over two different channels (i.e., the main channel - say Channel A which is part of main thread; and side channel - say Channel B) and the processing of message over Channel B will be sync/async depending on what is the "type" of channel B.
I want my Channel B to process the message in async manner but I'm not clear what type of Channel I should define it (Pollable, Subscriable, etc...bit confused on their functionality). Can you pls suggest what should be the channel type for Channel B based on the details mentioned above ?