Spring 集成 Java DSL:创建 jms 消息驱动程序通道适配器

Spring integration Java DSL : creating jms Message Driver Channel Adapter

我在使用以下消息驱动程序通道适配器时遇到问题

@Bean
    public IntegrationFlow jmsInboundFlow() {
        return IntegrationFlows.from(Jms.messageDriverChannelAdapter(this.jmsConnectionFactory)
                .outputChannel(MessageChannels.queue("inbound").get())
                .destination("test"))   
                .get();
    }

    @Bean
    public IntegrationFlow channelFlow() {
        return IntegrationFlows.from("inbound")
                .transform("hello "::concat)
                .handle(System.out::println)
                .get();
    }

我收到关于 "Dispatcher has no subscribers for channel" 的错误。将消息负载发送到另一个集成流的首选配置是什么?

使用 Java DSL channel auto-creation 你应该小心。例如,.outputChannel(MessageChannels.queue("inbound").get()) 不会将 MessageChannel bean 填充到 bean 工厂。但是从另一边 IntegrationFlows.from("inbound") 做到了。

要解决您的问题,我建议为您的 inbound 频道提取 @Bean,或者仅依赖 DSL:

return IntegrationFlows.from(Jms.messageDriverChannelAdapter(this.jmsConnectionFactory)
            .destination("test"))
            .channel(MessageChannels.queue("inbound").get())   
            .get();

请随时提出 GH 问题以修复 Java有关 .outputChannel() 的文档或将其全部删除,因为它很混乱。