6

我是春季集成的新手。我的配置文件中配置了几个频道,如下所示。

<int:channel id="channelOne" />
<int:channel id="channelTwo" />
<int:channel id="channelThree" />

我可以在这种情况下使用 MessageHandlerChain(http://static.springsource.org/spring-integration/docs/2.0.0.RC1/reference/html/chain.html )吗?

谢谢!

4

3 回答 3

14

当端点通过直接通道连接时,链可以方便地简化配置:

代替

<int:channel id="foo1"/>

<int:service-activator input-channel="foo1" output-channel="foo2" ref="s1" />

<int:channel id="foo2"/>

<int:service-activator input-channel="foo2" output-channel="foo3" ref="s2/>

<int:channel id="foo3"/>

<int:service-activator input-channel="foo3" output-channel="foo4" ref="s3" />

<int:channel id="foo4"/>

您可以使用

<int:channel id="foo1"/>

<int:chain input-channel="foo1" output-channel="foo4">    
    <int:service-activator ref="s1" />
    <int:service-activator ref="s2" />
    <int:service-activator ref="s3" />
</int:chain>

<int:channel id="foo4"/>

请使用当前文档

于 2012-12-03T15:32:41.707 回答
3

我会看看通道拦截器(http://static.springsource.org/spring-integration/docs/latest-ga/reference/htmlsingle/#channel-interceptors)。这些将允许您在消息到达您的输入通道之前做一些事情,我假设它是 channelOne。您可以根据用例记录消息或引发异常等。

<channel id="channelOne">
    <interceptors>
        <ref bean="yourValidatingInterceptor"/>
    </interceptors>
</channel>

<beans:bean id="yourValidatingInterceptor" class="com.yourcompany.YourValidatingInterceptor"/>
于 2012-12-03T14:45:22.083 回答
1

当一组处理程序需要以线性方式连接时,我们使用消息处理程序链。

<int:chain input-channel="marketDataInputChannel"> 
    <int:splitter ref="marketDataSplitter"/> 
    <int:service-activator ref="marketFieldServiceActivator"/> 
    <int:aggregator ref="marketDataAggregator"/> 
    <int:service-activator ref="marketItemServiceActivator"/> 
</int:chain>

在上面的例子中,channel splitter的输出数据将是 service-activator 的输入,而service-activator的输出将是aggregator的输入......
希望这个解释能帮助你理解<int:chain />

于 2015-03-05T10:59:08.060 回答