Oct 26th, 2011, 07:23 AM
DefaultMessageListenerContainer scaling concurrent consumers not behaving as I expect
I am try to using the DefaultMessageListenerContainer to do the following:
This container will have no messages coming in for a few hours and the suddenly there will be ~1000 messages sent. Each message takes ~1 minute to execute. I have configured concurrency 1-5. The behaviour I expected is that when the burst of messages comes in, the container would scale up to 5 consumers and all 5 would continue consuming and executing simultaneously until all messages are consumed. But what actually happens is the the container scales up to 5 consumers and executes the first 5 messages. After that, only one consumer consumes the remaining messages. I have tried all manner of messagesPerTask, idelConsumerLimit, idelTaskExecutionLimit. I have tried the default executor and a ThreadPoolTaskExecutor. The behaviour is always the same. I don't have any experience with JMS. It seems that the calls to receive() return null on all but 1 thread (after the initial 5 messages are consumed). Shouldn't receive() return a message if there is a message in the queue, even if another message is being executed. If not, shouldn't this listener execute these messages asynchronously? Or is this not the container to use to get the functionality I need?