我有一个负载很重(分配外部网络调用)的集成流程,它在进入主服务激活器之前使用 PriorityQueue。我想添加执行程序 channel 以改善系统负载,但我看不到组合这些 channel 的直接方法。
<int:channel id="monitorInPriorityUpdate">
<int:priority-queue/>
</int:channel>
<int:transformer id="monitorLogTransformerStub"
input-channel="monitorInPriorityUpdate" output-channel="monitorInUpdate"
expression="payload" />
<int:channel id="monitorInUpdate">
<int:dispatcher task-executor="monitorExecutor"/>
</int:channel>
我需要创建 2 个额外的组件才能完成这项工作,但是有没有一种方法可以将几个 Spring Integration Channels 合并为一个,而无需添加新组件?
最佳答案
实际上,看起来没有足够的信息。但我试着猜测。你需要这个:
<int:channel id="priorityChannel">
<int:priority-queue/>
</int:channel>
<int:bridge input-channel="priorityChannel" output-channel="executorChannel">
<int:poller fixed-rate="100"/>
</int:bridge>
<int:channel id="executorChannel">
<int:dispatcher task-executor="threadPoolExecutor"/>
</int:channel>
在这里,您使用Bridge 将消息从一个 channel 转移到另一个 channel 。
或者这个:
<int:channel id="priorityChannel">
<int:priority-queue/>
</int:channel>
<int:service-activator input-channel="priorityChannel" ref="service">
<int:poller fixed-rate="100" task-executor="threadPoolExecutor"/>
</int:service-activator>
在这里,您只需使用 Poller 将消息从 priorityChannel 发送到 taskExecutor。
在一个 channel 中混杂关注是不正常的。每种 channel 类型都扮演着自己的角色。 您想要实现的不仅仅是最小化输入,而且即使这恰好是您的解决方案,它也会非常复杂且不可靠。
关于java - 在 Spring Integration 中结合几个 channel ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20487264/