使用多个执行程序通道阻塞主线程
Block main thread with multiple executor channel
我有一个多线程项目,我从队列中读取消息并将其传递给 spring 集成来处理它。每条消息通过差异通道最终存储在数据库中并发送到下游 Qs。
<int:channel id="mainChannel">
<int:interceptors>
<int:wire-tap channel="channel1" selector-expression="!headers['somevalue']"/>
<int:wire-tap channel="channel2" selector-expression="!headers['somevalue']"/>
<int:wire-tap channel="channel3" selector-expression="!headers['somevalue']"/>
</int:interceptors>
</int:channel>
<int:channel id="channel1">
<int:dispatcher task-executor="exec1" />
</int:channel>
<int:channel id="channel2">
<int:dispatcher task-executor="exec2" />
</int:channel>
<int:channel id="channel3">
<int:dispatcher task-executor="exec3" />
</int:channel>
现在我想阻塞发送方线程,直到所有异步任务都完成处理,例如,在线程中,只有一条消息发送到所有通道 (1,2,3),而对于另一个线程,它将只发送到 2 个通道(1,2) 等等。
我已经看到 aggregator/Thread 障碍方法但不确定它是如何工作的,因为每个线程流都会不同。
我怎样才能做到这一点?
线程无关紧要;主线程调用屏障,无论哪个线程将第三条消息添加到聚合器都将释放该组,然后可用于触发屏障。
https://docs.spring.io/spring-integration/docs/current/reference/html/message-routing.html#barrier
我有一个多线程项目,我从队列中读取消息并将其传递给 spring 集成来处理它。每条消息通过差异通道最终存储在数据库中并发送到下游 Qs。
<int:channel id="mainChannel">
<int:interceptors>
<int:wire-tap channel="channel1" selector-expression="!headers['somevalue']"/>
<int:wire-tap channel="channel2" selector-expression="!headers['somevalue']"/>
<int:wire-tap channel="channel3" selector-expression="!headers['somevalue']"/>
</int:interceptors>
</int:channel>
<int:channel id="channel1">
<int:dispatcher task-executor="exec1" />
</int:channel>
<int:channel id="channel2">
<int:dispatcher task-executor="exec2" />
</int:channel>
<int:channel id="channel3">
<int:dispatcher task-executor="exec3" />
</int:channel>
现在我想阻塞发送方线程,直到所有异步任务都完成处理,例如,在线程中,只有一条消息发送到所有通道 (1,2,3),而对于另一个线程,它将只发送到 2 个通道(1,2) 等等。
我已经看到 aggregator/Thread 障碍方法但不确定它是如何工作的,因为每个线程流都会不同。
我怎样才能做到这一点?
线程无关紧要;主线程调用屏障,无论哪个线程将第三条消息添加到聚合器都将释放该组,然后可用于触发屏障。
https://docs.spring.io/spring-integration/docs/current/reference/html/message-routing.html#barrier