2015-10-06 64 views
2

我是新的春季集成。 在我的Spring集成的配置我有:收件人列表路由器弹簧集成

<int:chain input-channel="channel1_2" output-channel="channel1_3"> 
    <int:service-activator> 
     <bean class="com.csv.CSVEntreprise"/> 
    </int:service-activator> 
</int:chain> 

<int:channel id="channel1_3"/> 

<int:recipient-list-router id="id-entreprise" input-channel="channel1_3"> 
    <int:recipient channel="channel1_3TRUE" /> 
    <int:recipient channel="channel1_3FALSE"/> 
</int:recipient-list-router> 

<int:channel id="channel1_3TRUE"/> 
<int:channel id="channel1_3FALSE"/> 

在CSVEntreprise我与布尔返回definied方法的类,我希望当它返回true使用信道channel1_3TRUE时,它的返回false使用信道channel1_3FALSE?

回答

2

您可能要考虑使用标头值路由器(http://docs.spring.io/spring-integration/reference/html/messaging-routing-chapter.html)。

您可以使用您的CSVEnterprise bean在MessageHeaders中设置布尔值。

@ServiceActivator应该设置你的头的值:

return MessageBuilder.withPayload(message) 
        .setHeader("MY_HEADER", Boolean.FALSE).copyHeadersIfAbsent(headers).build(); 

然后,使用一个标头值的路由器,以确定哪个通道路由的顺序。

<int:header-value-router input-channel="channel1_3" header-name="MY_HEADER" id="headerValueRouter"> 
    <int:mapping value="true" channel="channel1_3TRUE"/> 
    <int:mapping value="false" channel="channel1_3FALSE" /> 
</int:header-value-router>