I have been trying the reply timeout of Gateway in Spring Integration but it doesn't work in the configuration I've been using below:
<int:gateway id="TrailerGateway" service-interface="com.12lmdk.gateways.TrailerGateway"
default-request-channel="trailerChannel" default-reply-timeout="5000"/>
<int:channel id="trailerChannel" />
<int:service-activator input-channel="trailerChannel"
ref="trailerService" method="getTrailer"/>
I have read in a stackoverflow question that I should provide a reply channel on the gateway and output channel in the service activator and that channel should be pollable so I tried that as well
<int:gateway id="TrailerGateway" service-interface="com.12lmdk.gateways.TrailerGateway" default-reply-channel="trailerOutputChannel" default-reply-timeout="5000"/>
<int:channel id="trailerChannel" />
<int:channel id="trailerOutputChannel" >
<int:queue/>
</int:channel>
<int:service-activator input-channel="trailerChannel" output-channel="trailerOutputChannel" ref="trailerService" method="getTrailer"/>
This still won't work and the reply-timeout has no effect. (I've tested it by putting a Thread.sleep of 10 seconds in one of the method accessed by the service activator) The gateway still waits for the reply of the service activator which is not what I am expecting.
How can I produce an exception or even a null response from the gateway due to timeout???
The timer doesn't start until the thread returns to the gateway. It is intended for use when the calling thread hands off the work to another thread, for example with a QueueChannel
or ExecutorChannel
. When the calling thread returns to the gateway, the timer starts.