Spring Java DSL integration: creating a jms message channel adapter

I am having problems with the following message 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();
    }

I get the error "The dispatcher has no subscribers to the channel." What is the preferred configuration for sending a message payload to another integration thread?

+4
source share
1 answer

With this Java DSL channel auto-creationyou have to be careful. For example, .outputChannel(MessageChannels.queue("inbound").get())does not populate a MessageChannelbean bean factory. But on the other hand IntegrationFlows.from("inbound")does it.

To fix your problem, I suggest extracting @Beanfor your channel inboundor simply relying on DSL:

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

GH, JavaDocs .outputChannel() alltogether, .

+5

All Articles