'Amazon sqs messages stuck in available messages

I'm new using Amazon sqs and I'm supporting some queues in my company. The problem that I'm facing is that a few days ago some messages just got stuck in available messages as you can see in the picture. It's not every message that gets stuck.

Do you guys know what this is about?

My aws queue control panel



Solution 1:[1]

I had a similar problem while reading messages from SQS in a recurrent @Scheduled java job. As John Rotenstein pointed out, the deleteMessage method must be called to remove messages from the queue.

In my case, the problem was on the @Scheduled annotated method itself. For some specific reason, it didn't finished executing under some specific conditions and so the scheduler was never ready to run my reading method again.

Solution 2:[2]

It sounds like a worker is failing to correctly process the messages from the queue.

When a worker (or app) retrieves a message from the queue, it needs to call DeleteMessage() when it has finished processing. This removes it from the queue.

However, it the worker fails, or fails to call DeleteMessage(), the message will automatically reappear after the invisibility period expires.

You can implement an Amazon SQS dead-letter queue, which will move messages to the dead-letter queue after it has been received a certain number of times. That will move it out of the queue for further examination/processing.

Solution 3:[3]

In my case, I didn't have EC2 workers available for my queue A. You can check that by going to the corresponding cluster.

Elastic Container Services -> Clusters -> filter for corresponding cluster A -> check Pending tasks count and Running tasks count metrics

You can wait till the workers become available again. Or spin-up some yourselves.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 lgdestro
Solution 2 John Rotenstein
Solution 3