Spring 集成 Java DSL:如何使用 channelMapping 方法路由到名称在 headers 中的频道?
Spring Integration Java DSL: How to route with the channelMapping method to the channel which name is in the headers?
如何用channelMapping
方法路由到headers中的频道?所以如果我试试这个
@Bean
private IntegrationFlow postDataToChannelX() {
return f -> f
...
.<String, Boolean> route(s -> s.equals("[]"), m -> m
.channelMapping(false, "headers['channelName']")
.channleMapping(true, ...);
}
来了
Caused by: org.springframework.messaging.core.DestinationResolutionException: failed to look up MessageChannel with name 'headers['channelName']' in the BeanFactory.; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'headers['channelName']' available
你可以这样做:
.route(Message.class, (m) -> m.getHeaders().get("channelName"))
因此,您根本不需要任何映射,因为您直接在路由函数中解析到目标通道。
如何用channelMapping
方法路由到headers中的频道?所以如果我试试这个
@Bean
private IntegrationFlow postDataToChannelX() {
return f -> f
...
.<String, Boolean> route(s -> s.equals("[]"), m -> m
.channelMapping(false, "headers['channelName']")
.channleMapping(true, ...);
}
来了
Caused by: org.springframework.messaging.core.DestinationResolutionException: failed to look up MessageChannel with name 'headers['channelName']' in the BeanFactory.; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'headers['channelName']' available
你可以这样做:
.route(Message.class, (m) -> m.getHeaders().get("channelName"))
因此,您根本不需要任何映射,因为您直接在路由函数中解析到目标通道。