Search code examples
javaspringspring-integrationintegration

Forwarding message to Message Channel manually - Spring Integration


Am able to send the message successfully using the below from my FirstHandler

messageChannel.send(MessageBuilder.withPayload(pa).build());

But, the flow is waiting for the handler2 associated with the messageChannel to complete.

I would like to just forward the data to the channel and forgot , I tried publish-subscribe & direct channel both wait for the handler2 to complete


Solution

  • Please, learn what types of MessageChannel implementations are there: https://docs.spring.io/spring-integration/docs/current/reference/html/core.html#channel-implementations

    That's correct that DirectChannel is just calling the MessageHandler in the same sending thread. The PublishSubscribeChannel has the same behavior by default.

    If you'd like to send-n-forget, then you need a MessageChannel which shifts consuming task to a different thread. For this purpose there are QueueChannel, ExecutorChannel and FluxMessageChannel.