After update to latest version SimpleMessageListenerContainer is warning #373
Comments
It looks like number of messages received from AWS by single batch receive operation (by default 10 - What I'd suggest is to create SimpleMessageListenerContainer "manually" (by providing bean of SimpleMessageListenerContainerFactory) and call setMaxNumberOfMessages with value of X. In that case when task executor is initialized it sees non-null value of 10 and creates X+1 receiver threads. |
I have same issue after updating from 1 to 2 |
I have the same issue with version 2.0.1
|
Here's my code and it does not generate errors in runtime. As far as I remember the thing is that size of queueContainerTaskEecutor defined is larger than maxNumberOfMessages in SimpleMessageListenerContainerFactory
|
Is a change required here or a documentation update? |
It is. As mentioned @j-gurda SimpleMessageListenerContainerFactory is allocating more threads than AsyncTaskExecutor supports. I had to create SimpleMessageListenerContainerFactory manually with one thread lower than AsyncTaskExecutor to workaround the problem. |
@rotilho actually number of messages received in single batch operation (by default 10 - AbstractMessageListenerContainer.DEFAULT_MAX_NUMBER_OF_MESSAGES) is larger than size of taskExecutor which processes these messages (by default 2+1 -see SimpleMessageListenerContainer.createDefaultTaskExecutor). So what we may do is:
These'd be the defaults which could be tuned with specific "manual" configuration so I'd suggest to go with less resources allocated i.e. receive by 1 message from AWS and have 2 threads handling receiving and processing of messages. |
So if I set setMaxNumberOfMessages to 10 this will create a higher ThreadScheduler :
Adding some explanation about how this works: Spring-cloud-aws will set the number of threads to the number of messages if the number of messages has ben explicitly set, otherwise it will set it to 2 even if the default number of messages is 10 from Stackoverflow -> https://stackoverflow.com/questions/51373082/springboot-sqslistener-not-working-with-exception-taskrejectedexception?rq=1 |
Surely a change is required to bring this into line? As currently the default config causes these exceptions if the queue has more than 2 messages on it? The DEFAULT_MAX_NUMBER_OF_MESSAGES = 10 but the default number of worker threads is 2 so you are always going to get this exception if your queue has more than 10 and then you're going to get a 10 second pause for no genuine reason. Another option is to change the rejection policy from AbortPolicy (java.util.concurrent.ThreadPoolExecutor.AbortPolicy) to CallerRuns which makes a lot of sense to me as it will mean mean you won't get this message and it will only poll again once all messages have been processed (though there may be other reasons why this won't work). |
It doesn't make sense that the default configuration seems doomed to failure. It leaves a poor first impression. :) |
I'll double check but I think this issue has been already fixed. |
Fixed in 9dcdd53 |
After update to 2.0.0 from 1.2.3 I usually to see frequently the following warn:
The text was updated successfully, but these errors were encountered: