1
votes

How to create automatic shutdown in spring integration after finish all process for all file? My application use a lot of file as input and use http outbound gateway as last endpoint, so i have http outbound request for each file input , and i try to use the last http response from that endpoint as the trigger to shutdown (context.close()) the spring integration. My idea is try to use (System.currentTime()-lastTimeGatewayResponse)>= idleTime as trigger . But i did not find way to get lastTimeGatewayResponse from that gateway.

And afterward I try to folow http://forum.spring.io/forum/spring-projects/integration/116366-orderly-shutdown-how-to-know-when-downstream-executor-is-idle. But mybe that not the best aproach, because my application has shutdown while the the process unfinish.

Anyone has experience about that?

Thanks

2

2 Answers

0
votes

If you are using 4.2.x (current version is 4.2.6) you can call channel.getTimeSinceLastSend() on the reply channel.

The javadocs says it's in seconds but that's not correct, it's milliseconds.

0
votes

Well, actually the lastTimeGatewayResponse may be fully equivalent to the timeSinceLastSend from the reply-channel on that gateway.

So, you can specify nullChannel as an output (reply-channel) for your http outbound gateway and track its timeSinceLastSend to perform your shutdown logic.

On the other hand, try to accomplish similar, but more robust behavior, with an <aggregator>. You can use correlationKey as something static for all your files and trigger shutdown as an input action from the <aggregator>. The release strategy may be the count of your input files.