0

I have created a MessageAdapter by extending MessageProducerSupport. I produce message to output channel by calling MessageProducerSupport.sendMessage. Then I defined an IntegrationFlow to consume messages from the message adapter, and send it to a channel. But I don't receive any messages on the channel.

This is my configuration

 @Bean
  public MyAdapter myAdapter() {
    MyAdapter myAdapter = new MyAdapter();
    myAdapter.setOutputChannel(new QueueChannel());
    return myAdapter;
  }

  @Bean
  public IntegrationFlow integrationFlow() {

    return IntegrationFlows
        .from(myAdapter())
        .channel("myChannel")
        .get();
  }

and message endpoint for "myChannel":

@MessageEndpoint
public class MyConsumer {

  @ServiceActivator(inputChannel = "myChannel")
  public void parseMessage(Message message) {
    System.out.println(message.getPayload().toString());
  }

}

Is there something I am missing to configure?

Thank you

sansari
  • 558
  • 1
  • 7
  • 17
  • What triggers the `sendMessage`? Turn on DEBUG logging to see if it helps. – Gary Russell Sep 20 '18 at 13:20
  • @GaryRussell My adapter gets messages from KCL record processor and triggers the sendMessage on `MessageProducerSupport`. I changed the above code and added a `PollableChannel` bean and passed it to output channel. Debug shows `preSend` and `postSend` successfully done on that output channel. – sansari Sep 20 '18 at 13:45
  • So, do you mean that messages are sent to that `new QueueChannel()`, but not to the `"myChannel"` in the flow? Try remove the `@Bean` annotation from the `myAdapter()` definition - the Java DSL will take care about bean registration for you. – Artem Bilan Sep 20 '18 at 14:03
  • That's right! I debugged the code and I can verify messages are hold by the channel (`new QueueChannel()`) in `GenericMessagingTemplate.doSend(...)`, but it seems they are not polled. I also removed `@Bean` from `myAdapter()`, did not help. – sansari Sep 20 '18 at 14:08
  • @ArtemBilan @GaryRussel I just removed `new QueueChannel()` and output channel is set to default `DirectChannel()` by `IntegrationFlow`. Now it works fine. I don't understand why manual setting outputchannel does not work! – sansari Sep 20 '18 at 16:21
  • It works, but it sends a message to the provided `new QueueChannel()`, not that one you configure in the flow. – Artem Bilan Sep 20 '18 at 16:44
  • Right! then how can I poll messages from `new QueueChannel()` ? – sansari Sep 20 '18 at 17:19

0 Answers0