8
我想使用Spring集成來實現基於內容的路由器,如果表達式值與任何映射都不匹配,則使用默認輸出通道。這裏是我的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" />
然而,似乎默認的輸出通道從未使用過。如果表達式評估爲例如「巴茲」,路由器似乎在尋找,而不是路由到「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
是我想在所有可能使用XML命名空間,還是我需要編寫我自己的實現?
如果您正在閱讀Spring Integration 2.1+,忽略了通道名稱解析失敗。您可以通過使用resolution-required =「false」來獲得相同的效果。請參閱http://static.springsource.org/spring-integration/reference/htmlsingle/#2.1-router-standardization – Joe