0

I've got a question, i want to implement an input adapter in spring integration using dsl, as an event listener and redirect messages from that event listener to a channel.

desired code:

@Bean
public IntegrationFlow listenerFlow() {
    return IntegrationFlows.from(InputAdapterListener.listen())
            .channel("ChannelXYZ")
            .get();
}

can someone explain to me what would be the implementation of the InputAdatperListener class to support a behaviour like this, or where to look for some examples?

Luka Špoljarić
  • 988
  • 1
  • 10
  • 23

1 Answers1

1

There is an ApplicationEventListeningMessageProducer in the spring-integration-event for you to use in that from() configuration:

 private ApplicationListener<?> applicationListener() {
        ApplicationEventListeningMessageProducer producer = new ApplicationEventListeningMessageProducer();
        producer.setEventTypes(TestApplicationEvent1.class);
        producer.setOutputChannel(resultsChannel());
        return producer;
    }

... 

 IntegrationFlows.from(applicationListener())

And this one is going to be registered as a bean automatically.

Artem Bilan
  • 113,505
  • 11
  • 91
  • 118
  • 1
    However, if you are not talking about Spring Application events but some other event source, then you would extend `MessageProducerSupport` and call `sendMessage()`. – Gary Russell Oct 29 '18 at 15:30