I am using Spring Integration with ActiveMQ. I defined a DefaultMessageListenerContainer with maxConcurrentConsumers = 5. It is referenced in a . After an int-xml:validating-filter and an int-xml:unmarshalling-transformer, I defined a queue channel actionInstructionTransformed. And I have got a poller for this queue channel. When I start my application, in the ActiveMQ console, I can see that a connection is created and inside five sessions.
Now, I have got a @MessageEndpoint
with a method annotated
@ServiceActivator(inputChannel = "actionInstructionTransformed", poller = @Poller(value = "customPoller")).
I have got a log statement at the method entrance. Processing of each message is long (several minutes). In my logs, I can see that thread-1
starts the processing and then I can only see thread-1
outputs. Only when thread-1
has finished processing 1 message, I can see thread-2
starts processing the next message, etc. I do NOT have any synchronized block inside my class annotated @MessageEndpoint
. I have not managed to get thread-1
, thread-2
, etc process messages concurrently.
Has anybody experienced something similar?
Look, you say:
After an int-xml:validating-filter and an int-xml:unmarshalling-transformer, I defined a queue channel actionInstructionTransformed.
Now let's go to the QueueChannel
and PollingConsumer
definitions !
On the other hand, a channel adapter connected to a channel that implements the org.springframework.messaging.PollableChannel interface (eg a QueueChannel) will produce an instance of PollingConsumer.
And pay attention that @Poller
( PollerMetadata
) has taskExecutor
option.
By default the TaskScedhuler
ask QueueChannel
for data periodically according to the trigger
configuration. If that is PeriodicTrigger
with default options like fixedRate = false
, the next poll really happens after the previous one. That's why you see only one Thread.
So, try to configure taskExecutor
and your messages from that queue will go in parallel.
The concurrency
on the DefaultMessageListenerContainer
does not have effect. Because in the end you place all those messages to the QueueChannel
. And here a new Threading model starts to work based on the @Poller
configuration.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.