Is there a way to auto delete SQS queues entirely. I have a solution wherein a server on startup creates an SQS and subscribes to SNS topic.
However there maybe scenarios wherein the server crashes and is irrecoverable. In such cases, I would replace the server with a different one which would create its own queue on startup. Now the earlier queue is not going to be used anymore.
Is there a way to for the queue to get auto-deleted with me going and deleting it explicitly (maybe like if the queue remains empty for 5 days, it gets auto deleted or some other alternative)?
At the moment, AWS SQS does not provide a mechanism to automatically delete a queue when it is empty for a certain number of days. Even I feel like this is a needed feature. But there are ways to tackle this problem.
Mentioned below, are a few ways to delete the AWS SQS according to the scenario in your question. You can select which suits you the most.
sqs.deleteQueue(new DeleteQueueRequest(myQueueUrl));
Whenever a Server is started, it can send an Email to a person with the Server IP and SQS URL using SNS. Using a CloudWatch Rule, invoke a Lambda from time to time, and get all Instances, and check if any instance is down. If an instance is down, send an email to the relevant person using SNS, emailing that this server is down. It is semi-automatic, where the use can manually delete the queue after seeing the email.
Simply let the Empty queues be on its own. There is no limit as to how many queues can be made inside AWS. So why bother to delete them if that process is hard. Simply create new Queue as you go along. (See: No Max number of SQS Queue Limitation)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With