Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Spring Integration - channels and threads

I would like to understand how messages are processed in Spring Integration: serial or parallel. In particular I have an inbound channel adapter with a poller and an HTTP outbound gateway. I guess splitters, transformers, header enrichers etc are not spawning their own threads.

I could have missed them, but are these details specified somewhere in the documentation?

Also can I programatically get all the channels in the system?

like image 523
Adrian Ber Avatar asked Mar 20 '26 09:03

Adrian Ber


2 Answers

Channel types are described here.

The default channel type is Direct (the endpoint runs on the caller's thread); QueueChannel and ExcecutorChannel provide for asynch operations.

context.getBeansOfType(MessageChannel.class)

like image 200
Gary Russell Avatar answered Mar 22 '26 23:03

Gary Russell


Actually "threading" dependes on MessageChannel type:

E.g. DirectChannel (<channel id="foo"/> - default config) doesn't do anything with threads and just shifts the message from send to the subscriber to handle it. If the handler is an AbstractReplyProducingMessageHandler it sends its result to the outputChannel and if the last one is DirectChannel, too, the work is done within the same Thread.

Another sample is about your inbound channel adapter. On the background there is a scheduled task, which executes within the Scheduler thread and if your poll is very often the next poll task might be executed within the new Thread.

The last "rule" is acceptable for QueueChannel: their handle work is done with Scheduler thread, too.

ExcecutorChannel just places the handle task to the Executor.

All other info you you can find in the Reference Manual provided by Gary Russell in his answer.

like image 25
Artem Bilan Avatar answered Mar 22 '26 22:03

Artem Bilan



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!