我希望从现有的通道中创建一个消息链,而不需要再次具体地编写所有元素。
目前,我有几个长链,相互重叠,与某些元素。每次我添加一个新元素时,我必须将它添加到几个链中。我希望建立一个渠道链,这可以称为一个序列。
简化一下,我的applicationContext目前有三个频道。第一频道和第二频道,以及第三频道,由这两个频道组成:
<int:chain input-channel="channel-1">
<int:service-activator ref="serviceA" method="doService" />
<int:service-activator ref="serviceB" method="doService" />
<int:service-activator ref="serviceC" method="doService" />
</int:chain>
<int:chain input-channel="channel-2">
<int:service-activator ref="serviceD" method="doService" />
<int:service-activator ref="serviceE" method="doService" />
<int:service-activator ref="serviceF" method="doService" />
</int:chain>
<int:chain input-channel="channel-3">
<int:service-activator ref="serviceA" method="doService" />
<int:service-activator ref="serviceB" method="doService" />
<int:service-activator ref="serviceC" method="doService" />
<int:service-activator ref="serviceD" method="doService" />
<int:service-activator ref="serviceE" method="doService" />
<int:service-activator ref="serviceF" method="doService" />
</int:chain>我想要的是一个简单的解决方案,它可以让我做一些类似的事情
<int:chain input-channel="channel-3">
<??? channel-1 />
<??? channel-2 />
</int:chain>有什么简单的方法吗?
发布于 2019-01-02 11:24:56
我想你已经误解了chain和channel的概念。
channel是管道和过滤器的核心,因为它是一个管道,所以不管您是否使用链,您仍然使用通道。链允许您通过定义筛选器元素的列表来简化流的定义。这些元素仍然与匿名通道连接。<int:channel...>)被专门引用,允许通过向或从这些信道发送和或接收消息来彼此之间的多个流到intwine。所以,希望你能看到,从渠道中创建链,与管道和过滤器的体系结构和框架的设计都是背道而驰的,我们试图保持这个框架的一致性。换句话说,我从您的文章中看到的是,您有一些流可能是其他流(全部或部分)的生产者和/或消费者,如果是这样的话,只需使用显式通道即可。
下面是流程的简化版本:
<int:chain input-channel="channel-1" output-channel="channel-1out">
<int:service-activator ref="serviceA" method="doService" />
<int:service-activator ref="serviceB" method="doService" />
<int:service-activator ref="serviceC" method="doService" />
</int:chain>
<int:chain input-channel="channel-2">
<int:service-activator ref="serviceD" method="doService" />
<int:service-activator ref="serviceE" method="doService" />
<int:service-activator ref="serviceF" method="doService" />
</int:chain>
<int:bridge input-channel="channel-1out" output-channel="channel-2"https://stackoverflow.com/questions/54004472
复制相似问题