如何使用 channelMapping
方法路由到名称在标题中的 channel ?所以如果我试试这个
@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"))
因此,您根本不需要任何映射,因为您直接在路由函数中解析到目标 channel 。
关于spring-integration - Spring Integration Java DSL : How to route with the channelMapping method to the channel which name is in the headers?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53256596/