Reputation: 735
I am trying to understand whether multiple threads can concurrently/parallelly messages from Spring Integration Queue Channel. Suppose I have the following configuration :
<int:channel id="fooChannel">
<int:queue />
</int:channel>
From the documentation, I understand that by using a Queue Channel producer and consumer get decoupled and both happen in different threads.
My point of confusion is - Is there a way that Multiple threads can work on the messages stored in the queue channel. Something that we regularly do with JMS channels. (one/multiple producer & multiple consumer)
If it is not possible what is the recommended way to achieve concurrent processing of the messages in a queue channel
Upvotes: 1
Views: 1762
Reputation: 121560
The QueueChannel
is backed by the java.util.Queue
(the LinkedBlockingQueue
by default), which is designed for multi-threaded interaction.
So, you definitely can send message to this channel from different threads.
And on the other hand it is also true: this channel works exactly as JMS queue: you can have several competitive consumers (PollingConsumer
endpoints) and only one of them will poll and process a message from the queue.
Upvotes: 2