当嵌套链失败并到达错误通道流时,任务执行程序线程将阻塞并且不会返回到池中。是否有任何方法表明流程已结束,需要将其返回池中。

例如,拆分器将有效负载分解为3条消息。这些消息用作-

message 1 - fileChannelTaskExecutor1
message 2 - fileChannelTaskExecutor2

如果“嵌套链”网关调用成功,则将第3条消息提供给任何较早释放的执行程序线程。

但是,如果“嵌套链”网关调用失败并到达errChannel,则上述执行程序线程块都不会返回到池中。结果,由于池中没有可用线程,因此未处理连续消息(消息3)。
<bean id="fileChannelTaskExecutor"
class="org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor">
    <property name="corePoolSize" value="2"/>
    <property name="daemon" value="false"/>
</bean>

<int:channel id="splitterResponseChannel">
    <int:dispatcher task-executor="fileChannelTaskExecutor"/>
</int:channel>

<int:splitter input-channel="splitterRequestChannel" output-channel="splitterResponseChannel" >

<int:chain input-channel="splitterResponseChannel">
    <int:gateway request-channel="nested-chain" error-channel="errChannel"/>
</int:chain>

<int:chain input-channel="errChannel" output-channel="nullChannel">
     .....
</int:chain>

最佳答案

这里的问题与单向nullChannel<int:gateway>请求/回复性质有关。

即使将Exception发送给error-channel,也应该将其重新引发到调用中,或者从错误流中返回一些compensation消息。
否则,您最终会挂在网关上,这将永远等待答复。当然默认情况下!

您可以调整此事的reply-timeout并在一段时间内将线程释放到池中,以防发生单向错误过程。

10-06 15:35