We're using Spring Cloud AWS to receive messages from SQS.
Now, due to a bug, one of our services threw an OutOfMemoryError.
Having a redrive policy to a dead-letter queue set on the SQS queue, I assumed that with deletion policy NO_REDRIVE, the messages would get returned to the queue.
But that is not happening, as the AbstractMethodMessageHandler, that re-throws exceptions in case they occur, does not do that with errors (to be more precise, with all Throwables that are not of type Exception):
executeMessage() returns silently, as the throwable was swallowed, and hence, applyDeletionPolicyOnSuccess() is executed next.
In case of an Exception, it would execute applyDeletionPolicyOnError, but not in case of an error.
Question: Is the Spring Framework violating the contract, by swallowing the Error? IMHO it should be re-thrown, just like ordinary Exceptions are.
Or is the SimpleMessageListenerContainer wrong to assume that if executeMessage has returned normally, the processing went fine without any problem? If yes, how can it figure out that an error has occurred?
We're rethrowing Errors and other non-Exceptions as MessageHandlingException now, sending it through the common exception resolution algorithm. This is on master now; I'll backport it to 5.0.x and 4.3.x tomorrow after a few additional tests (in particular for cause resolution).