路由到通道配置

时间:2016-08-17 14:27:43

标签: spring-integration

我想通过

发送消息
  

'startChannel-> router1-> outChannel'

如果我评论'config-2.xml'内容,它会按照我的预期运作。

当我启用'config-2.xml'内容时,我希望它应该通过

发送消息
  

'startChannel-> router1-> routerChannel-> router2-> outChannel'

但我得到以下例外。

  

EL1008E:(pos 0):无法找到属性或字段“routerChannel”   对象类型   'org.springframework.integration.message.GenericMessage' - 也许不是   公共?

如何将邮件路由到'routerChannel'?

配置-1.XML

<int:channel id="startChannel"/>

<int:router id="router1" 
            input-channel="startChannel"
            default-output-channel="outChannel"
            resolution-required="false"
            expression="routerChannel"/>

<int:channel id="outChannel"/>

配置-2.XML

<int:channel id="routerChannel"/>
<int:router id="router2"
            input-channel="routerChannel"
            resolution-required="true"
            expression="payload.paymentType">
    <int:mapping value="CASH" channel="cashPaymentChannel"/>
    <int:mapping value="CREDIT" channel="authorizePaymentChannel"/>
    <int:mapping value="DEBIT" channel="authorizePaymentChannel"/>
</int:router>

2 个答案:

答案 0 :(得分:1)

将评估路由器中的表达式,结果应为字符串(单通道)或字符串集合(多通道)。在您的用例中,路由器表达式在config1.xml中没有意义。如果是直接通道值,则此处不使用路由器。

答案 1 :(得分:1)

你的SpEL必须是这样的:

expression="@routerChannel"/>

由于它是运行时表达式,我们必须遵守它的bean引用协议。