Reputation: 360
If all the threads in the taskExecutor are busy (All 100 of them). Will the threads used by the poller block? Or will the poller thread leave the message on the queue and try again in another 300ms?
<int:channel id="tasksIn">
<int:queue capacity="50"/>
</int:channel>
<int:bridge input-channel="tasksIn" output-channel="taskProcessing" >
<int:poller fixed-rate="300" max-messages-per-poll="2" />
</int:bridge>
<int:channel id="taskProcessing">
<int:dispatcher task-executor="executor"/>
</int:channel>
<service-activator input-channel="taskProcessing" output-channel="taskCompleteChannel" ref="taskProcessor" method="processTask"/>
<task:executor id="executor" pool-size="100" />
Upvotes: 1
Views: 1430
Reputation: 174664
The behavior depends on the queue-capacity
attribute of the task executor and its rejection policy.
By default the queue is unbounded so the tasks will be queued until you eventually run out of memory.
When there is a bounded queue size and there are no available threads and the queue is full, the default policy is to throw an exception (default reject policy is abort). You can set the rejection policy to CALLER_RUNS
, in which case the task will run on the poller thread.
Spring Integration provides a CallerBlocksPolicy
(it needs a queue capacity > 0) but the task namespace doesn't support custom policies, you'll need to define the executor as a <bean/>
.
For more sophistication, you can apply an advice to the poller and "skip" polls under your chosen conditions. As can be seen in that link, we plan to provide a standard advice in the near future.
Upvotes: 1