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:
Code:
int messageCount = 0;
while (isRunning() && messageCount < maxMessagesPerTask) {
messageReceived = (invokeListener() || messageReceived);
messageCount++;
}
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?