2

我有一个重载(分配外部网络调用)集成流,它在进入主服务激活器之前使用 PriorityQueue。我想添加执行程序通道以改善系统负载,但我没有看到直接的方法来组合这些通道。

<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 集成通道组合在一起,而不添加新组件?

4

1 回答 1

2

实际上,看起来不像是ebough信息。但我试着猜测。你需要这个:

<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将消息从一个通道转移到另一个通道。

或这个:

<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。

在一个渠道中混合关注是不正常的。每种渠道类型都扮演着自己的具体角色。您想要实现的不仅仅是最小化输入,而且即使这恰好是您的解决方案,它也会非常复杂且不健壮。

于 2013-12-10T09:24:28.127 回答