Adrian Ber
Adrian Ber

Reputation: 21390

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?

Upvotes: 3

Views: 4426

Answers (2)

Gary Russell
Gary Russell

Reputation: 174779

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)

Upvotes: 7

Artem Bilan
Artem Bilan

Reputation: 121560

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.

Upvotes: 4

Related Questions