mmierins
mmierins

Reputation: 3774

Behaviour of multiple inbound channel adapters/pollers in a single context

I have a Spring Integration context with multiple inbound channel adapters, each with his own poller (currently all the pollers have their refresh time configured with fixed-delay but may use fixed-rate in future). All the inbound adapters output their produced messages to the same processing chain. The question is what is the behaviour of polling and message consuming in such a situation? Imagine, that poller #1 has produced 1000 messages and they are handed to my processing chain. Since processing can take some significant time it is possible that it has come time for the poller #2 to do its job and possibly produce messages. But remeber - my processing chain is still handling messages passed by poller #1. What happens?

  1. Poller #2 is not run at all until all the poller #1 messages are processed.
  2. Poller #2 is run (but how could it be run if we have only one thread?), its messages are stored for later use when all the poller #1 messages are processed.
  3. Processing initiated by poller #1 is interrupted, poller #2 is run, produced messages are passed to the processing chain immediately.
  4. Some other answer

Note that all my channels are direct channels and there are no task executors used.

Upvotes: 3

Views: 1159

Answers (2)

mger1979
mger1979

Reputation: 109

I have almost the same case, however the behaviour is a bit differs.

My case is :

  1. I have 4 pollers which requests data independently from 4 different blocking queues ( i have set up timeout for 1 sec for each of them)
  2. I have 4 inbound channel adapters configured to use fixed-delay (100ms) and the pollers above (one to one).
  3. I have thread pool with 4 threads core/max, configured to handle inbound channel adapters (all adapters use this pool)

And now i see at logs that each thread executes all pollers sequently, and if there is an empty queue (i am using blocking queue) then all threads are delayed for 1 sec. This means even if you have enough threads you still may get delay for all your threads if at least one poller is slow. For instance if I would not use timeout for queue reading at all then all threads would stop on empty queue and nothing would be read from all others non-empty queues .

To solve this issue I guess we need to configure separate thread pools for each poller<-->inbound channel adapter.

Upvotes: 0

Gary Russell
Gary Russell

Reputation: 174484

Pollers are independent tasks handled by the common taskScheduler bean; as long as the task scheduler has sufficient threads, there is no coordination across pollers.

If the pool is exhausted, pollers will run "late".

By default the taskScheduler has 10 threads; but you can reconfigure it.

Upvotes: 2

Related Questions