【问题标题】:recipient-list-router Spring integration收件人列表路由器 Spring 集成
【发布时间】:2015-10-06 07:51:18
【问题描述】:

我是 Spring 集成的新手。 在我的 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 类中,我定义了布尔返回的方法,我希望当它返回 true 时使用通道 channel1_3TRUE,当它返回 false 时使用通道 channel1_3FALSE?

【问题讨论】:

    标签: java spring spring-integration


    【解决方案1】:

    您可能需要考虑使用标头值路由器 (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>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-04-04
      • 2018-06-15
      • 1970-01-01
      • 2015-06-30
      • 1970-01-01
      • 2021-11-23
      相关资源
      最近更新 更多