Search code examples
spring-integrationcommonj

Common timeout across ExecutorChannel threads


Our application integration flow is defined as splitter -> ws gateway -> aggregator. The splitter splits request into a list of account numbers; so that for each account number a web service call is initiated and the responses from multiple web service calls are aggregated in the aggregator.The channel between splitter and ws gateway is defined with dispatcher "commonj WorkManagerTaskExecutor" so that each webservice call is initiated parallel in different threads.

We have added timeout for each webservice call. But we would like to set a single timeout for the whole process. i.e. all the webservice calls should be completed in, say 50 secs, rather than setting 50 secs timeout for each individual call. commonj WorkManagerTaskExecutor, provides this feature by waitForAll(Collection workItems, long timeout_ms) method when implemented directly through code. Is there any way to use this or a similar feature to achieve our requirement.


Solution

  • Unfortunately, no, we can't use such a custom feature of that specific TaskExecutor.

    From other side if you say "single timeout for the whole process" I can help you with the <gateway> pattern:

    <chain>
        <gateway request-channel="splitterChannel" reply-timeout="50000"/>
    </chain>
    

    Where reply-timeout is:

    Specifies how long this gateway will wait for the reply message before returning. By default it will wait indefinitely. 'null' is returned if the gateway times out.

    Does it make sense for you?