Announcement Announcement Module
No announcement yet.
DefaultMessageListenerContainer, maxConcurrentConsumers and shrinking of consumers Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • DefaultMessageListenerContainer, maxConcurrentConsumers and shrinking of consumers


    I am using the DefaultMessageListenerContainer and it states in the documentation that is I use maxConcurrentConsumers then threads will shrink back to the concurrentConsumers value after a specific time. I don't see that happening, with the number of threads staying at the maxConcurrentConsumers value.

    I use default values for all the rest. This means, based on my understanding, that maxMessagesPerTask remains at its Integer.MIN_VALUE, and the thread executor is the SimpleAsyncTaskExecutor.

    Looking at the runnable code, it looks like this code will be executed:

    while (isActive()) {
    if (isActive()) {
    messageReceived = invokeListener();

    And it seems like it will never exit the thread in order to perform the dynamic shrinking (which based on the javadoc it should shrink).

    Am I missing something?

  • #2
    I think it will only work when maxMessagesPerTask property is set no non negative value. Is so, instead of never ending loop you mentioned this code is invoked:

    int messageCount = 0;
    while (isRunning() && messageCount < maxMessagesPerTask) {
    	messageReceived = (invokeListener() || messageReceived);
    Here would be confirmation of my theory (though growing does work without maxMessagesPerTask) - fragment "Note: shrink/grow only works if the maxMessagePerTask property is set to a positive value, preferably 1.".

    This would be actually strange that documentation says nothing about such requirement.

    Is what I think correct?


    • #3
      But in this case, using the SimpleAsyncTaskExecutor, new thread will be created each time (pass the maxMessages marker), and the idle settings won't take affect?


      • #4
        Yes, and that is why I use thread pool