gpt4 book ai didi

spring-integration - Spring Integration Java DSL : How to route with the channelMapping method to the channel which name is in the headers?

转载 作者:行者123 更新时间:2023-12-04 01:50:41 27 4
gpt4 key购买 nike

如何使用 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/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com