Behaviour of the 'default-reply-timeout' of the 'int:gateway'
Code:
<int:channel id="channel.request" />
<int:channel id="channel.reply" />
<rabbit:template id="rabbitTemplate" connection-factory="connectionFactory" message-converter="marshallingMessageConverter"
reply-timeout="10000"/>
<int:gateway id="gatewayService" service-interface="com.gatewayservice.GatewayService" default-reply-timeout="6000">
<int:method name="calculateLoanAmount" request-channel="channel.request" reply-channel="channel.reply" />
</int:gateway>
<int-amqp:outbound-gateway amqp-template="rabbitTemplate" exchange-name-expression="headers.exchange" routing-key-expression="headers.routingKey"
request-channel="channel.request" reply-channel="channel.reply"/>
Hi,
In our spring integration as shown above, we have configured the 'default-reply-timeout' attribute of the 'int:gateway' and 'reply-timeout' attribute of the 'rabbit:template'.
Our observations are as follows :
1. When there is no reply on AMQP for the request, 'calculateLoanAmount' method of the 'GatewayService.java' returns null after it waits
for 16000 milliseconds. It seems that 16000 milliseconds is built of (default-reply-timeout="6000" + reply-timeout="10000").
2. If we don't configure the 'default-reply-timeout' attribute of the 'int:gateway', we noticed that the invoking thread gets parked
forever until the server is restarted.
3. If we set a minus value (-1) for either attributes ('default-reply-timeout' & 'reply-timeout'), we noticed that the invoking thread gets parked
forever until the server is restarted.
4. If there is a reply after 10000 milliseconds which is after the 'reply-timeout' attribute of the 'rabbit:template', it seems that the gateway doesn't pick that
reply. The Gateway waits for another 6000 milliseconds and returns null.
Ex. If a reply comes after 12000 milliseconds, it seems that the 'gateway' doesn't pick that reply. It simply waits 6000 milliseconds after the AMQP timeout which
is 10000 milliseconds and returns null.
It would be great if you could verify and answer the questions that are listed below :
Is our understanding correct on the following?
1. When the down stream process ('amqp:outbound-gateway') times out (in 10000 milliseconds) and it hands over
the control to the gateway ('int:gateway') at which point the 'default-reply-timeout' counter is started in the gateway.
On completion of the 'default-reply-timeout' counter (in 6000 milliseconds) a null is returned from the 'calculateLoanAmount' method.
Simply the 'calculateLoanAmount' method returns null after the 16000 milliseconds.
2. If we configured only 'reply-timeout' attribute of the 'rabbit:template' and the down stream process ('amqp:outbound-gateway')
times out (in 10000 milliseconds) and it hands over the control to the gateway ('int:gateway'). As we don't configure 'default-reply-timeout'
attribute of the 'int:gateway', it doesn't start the timeout counter and it hangs forever.
3. If we configured only 'default-reply-timeout' attribute of the 'int:gateway' and and the down stream process ('amqp:outbound-gateway')
doesn't find the reply and as of that it doesn't hand over the control to the gateway. Then the execution thread is hung forever in the down stream process.
4. When the down stream process ('amqp:outbound-gateway') times out (in 10000 milliseconds) and it hands over
the control to the gateway ('int:gateway') at which point the 'default-reply-timeout' counter is started in the gateway. If the reply comes after
the counter has begun, the 'gateway' doesn't pick that reply. So there is no point to configured a large timeout value for the 'default-reply-timeout' as it just waits for the configured timeout time period and returns null.
Thanks in advance
Varuna