ott*_*ath 9 java routing spring spring-integration
我想使用Spring Integration来实现基于内容的路由器,如果表达式值与任何映射都不匹配,则使用默认输出通道.这是我的bean定义:
<int:router input-channel="channel_in" default-output-channel="channel_default" expression="payload.name">
<int:mapping value="foo" channel="channel_one" />
<int:mapping value="bar" channel="channel_two" />
Run Code Online (Sandbox Code Playgroud)
但是,似乎从不使用默认输出通道.如果表达式评估为例如'baz',则路由器似乎正在寻找名为'baz'的频道,而不是路由到'channel_default'频道:
org.springframework.integration.MessagingException: failed to resolve channel name 'baz'
Caused by: org.springframework.integration.support.channel.ChannelResolutionException:
failed to look up MessageChannel bean with name 'baz'
Caused by: org.springframework.beans.factory.NoSuchBeanDefinitionException:
No bean named 'baz' is defined
Run Code Online (Sandbox Code Playgroud)
我想要的是使用XML命名空间,或者我是否需要编写自己的实现?
ott*_*ath 10
事实证明,我必须做的就是将路由器的ignore-channel-name-resolution-failures属性设置为false:
<int:router input-channel="channel_in" default-output-channel="channel_default"
expression="payload.name" ignore-channel-name-resolution-failures="true">
<int:mapping value="foo" channel="channel_one" />
<int:mapping value="bar" channel="channel_two" />
</int:router>
Run Code Online (Sandbox Code Playgroud)
我以为我之前尝试过,但我似乎没有.
| 归档时间: |
|
| 查看次数: |
11490 次 |
| 最近记录: |