0
votes

I am using spring integration gateway for exposing a rest service. It has request-channel and reply-channel configured. I am looking for configuration that give me the time taken for each rest operation.

Below is the gateway configuration:

<int:gateway id="testServiceGateway"
         service-interface="com.test.ws.TransactionServices"
         default-reply-time-out="5000"
         error-channel="txErrorChan">
     <int:method name="evaluateTransaction"
             request-channel="tranRequestChan"
             reply-channel="tranResponseChan"
             reply-time-out="3000" />
</int:gateway>

For example: I used custom request-handler-advice-chain for kafka-outbound-channel-adapter. Looking for something like this for gateway?

1
Maybe you can check this : stackoverflow.com/questions/32213467/… - Yiao SUN
What is your configuration so far? - Artem Bilan
@Artem, this is my current gateway configuration. <int:gateway id=“testServiceGateway” service-interface=“com.test.ws.TransactionServices” default-reply-time-out=“5000” error-channel=“txService”><int:method name=“evaluateTransaction” request-channel=“tranRequestChan” reply-channel=“tranResponseChan” reply-time-out=“3000” /></int:gateway> - Teja
Please, don't place bug code snippets in the comments. Would be better to edit your question with an appropriate formatting. - Artem Bilan
See how I formatted you question to make it readable for other people. Please, learn how to post over here on SO: stackoverflow.com/help/how-to-ask. - Artem Bilan

1 Answers

0
votes

Since you talk about a REST call you probably can think about using a tracing tool like Spring Cloud Sleuth: https://cloud.spring.io/spring-cloud-static/spring-cloud-sleuth/2.2.2.RELEASE/reference/html/#http-client-integration

Although for your so simple use-case I would just take a current time before calling that TransactionServices.evaluateTransaction() method and after to calculate a whole call period.

You can also follow my recommendations in the mentioned answer for the Spring Integration - Log time taken for whole file processing. So, you can inject a startTime header in the interceptor for the tranRequestChan and calculate in the interceptor for the tranResponseChan.

Another way is to rely on the Micrometer metrix on the channels or MessageHandlers: https://docs.spring.io/spring-integration/docs/current/reference/html/system-management.html#mgmt-channel-features