Mik*_*ike 3 spring-integration spring-integration-dsl
如何使用channelMapping方法路由到标题中名称的通道?所以如果我尝试这个
@Bean
private IntegrationFlow postDataToChannelX() {
return f -> f
...
.<String, Boolean> route(s -> s.equals("[]"), m -> m
.channelMapping(false, "headers['channelName']")
.channleMapping(true, ...);
}
Run Code Online (Sandbox Code Playgroud)
来了
引起:org.springframework.messaging.core.DestinationResolutionException:无法在 BeanFactory 中查找名称为“headers['channelName']”的 MessageChannel。;嵌套异常是 org.springframework.beans.factory.NoSuchBeanDefinitionException:没有名为 'headers['channelName']' 的 bean 可用
你可以这样做:
.route(Message.class, (m) -> m.getHeaders().get("channelName"))
Run Code Online (Sandbox Code Playgroud)
因此,您根本不需要任何映射,因为您直接在路由函数中解析到目标通道。
| 归档时间: |
|
| 查看次数: |
1045 次 |
| 最近记录: |