0
votes

If I have a simple IntegrationFlow like this:

@Bean
public IntegrationFlow downloadFlow() {
    return IntegrationFlows.from("rabbitQueue1")
        .handle(longRunningMessageHandler)
        .channel("rabbitQueue2")
        .get();
}

... and if the rabbitQueue1 is filled with messages,

what should I do to handle multiple messages at the same time? Is that possible? It seems that by default, the handler executes one message at a time.

1

1 Answers

0
votes

Yes, that's true, by default endpoints are wired with DirectChannel. That's like performing a plain Java instructions one by one. So, to do some parallel job in Java you need an Executor to shift a call to the separate thread.

The same is possible with Spring Integration via an ExecutiorChannel. You can make that rabbitQueue1 as an ExecutorChannel bean or use this instead of that plain name:

IntegrationFlows.from(MessageChannels.executor("rabbitQueue1", someExecturorBean)

and all the messages arriving to this channel are going to be paralleled in the threads provided by an executor. That longRunningMessageHandler are going to process your messages in parallel.

See more info in the Reference Manual: https://docs.spring.io/spring-integration/docs/current/reference/html/#channel-implementations