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

标签 spring-integration spring-integration-dsl

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

相关文章:

java - 如果 ThreadPoolTask​​Executor 没有可用容量,则将消息保留在 ActiveMQ 队列中

spring - 单个 JMSTemplate 可以在多个生产者中共享吗?

java - Spring集成DSL TCP : How to prevent excessive logging of Connection refused on the client side

java - Spring 集成 - 在流之间传递数据

spring-integration - Spring Integration DSL : How can I set the logging. 级别为 .log() 的调试

java - Spring集成消息历史记录

java - 在 spring 集成中将 json 转换为对象数组

java - Spring集成MessageQueue无需轮询

jms - 如何在Spring集成中设置每个出站jms消息的优先级?

java - 使用spring集成dsl逐行读取文件