【发布时间】:2014-09-11 20:39:03
【问题描述】:
我有以下配置,我试图同时处理最多 5 个请求。 每个请求都需要不同的时间来处理。我注意到它开始处理 5 个任务,这很好,但是当其中一个任务完成时,它不会立即执行另一个任务,实际上它正在等待所有 5 个任务完成,然后才开始接下来的 5 个任务。所以我得到了某种批处理行为。可能是我没有正确配置,请帮助纠正这个问题。我想在线程处理完一个任务后立即开始下一个任务。
我可以增加队列容量,在这种情况下它确实会启动下一个任务,但我只想在准备好处理消息时调用我的入站消息提供程序,而不仅仅是将其保存在任务执行器队列中。
<int:inbound-channel-adapter ref="feeder" channel="in">
<int:poller fixed-rate="100">
</int:poller>
</int:inbound-channel-adapter>
<int:bridge input-channel="in" output-channel="out" />
<task:executor id="taskExecutor" pool-size="1-5" keep-alive="120"
queue-capacity="0" rejection-policy="CALLER_RUNS"/>
<int:channel id="out">
<int:dispatcher task-executor="taskExecutor"/>
</int:channel>
<int:service-activator input-channel="out" output-channel="replyChannel"
ref="processor" method="process"/>
【问题讨论】: