spring-cloud-aws
spring-cloud-aws copied to clipboard
Pause @SqsListener receiver
Is your feature request related to a problem? Please describe. I am using SQS to store messages that are bound for a database, in the event that the database goes down for service or unexpectedly. I have a scheduled task checking the state of the database periodically, but it would be nice to be able to stop processing the SQS queues from SQS when I know the database is down, while still utilizing the simplicity of the @SqsListener annotation.
Describe the solution you'd like Add a mechanism to pause the SQS listener thread and resume on demand.
Describe alternatives you've considered Currently, I just use the NEVER_DELETE policy and return early from processing the received messages, but the overhead is still there. Optionally, I am looking into moving away from the @SqsListener annotation and implementing the SQSMessagingTemplate with a manual scheduled task to pull from the queue.
@massivespace you can achive this by autowiring the SimpleMessageListenerContainer and then use the stop method.
At least this worked for me :)