问题
I have a small set of messages in an SQS queue, that are not deleted even though a deletion request sent to the AWS endpoint returns with a 200 response. The messages are processed by my application fine, and the deletion request is sent fine too.
I'm using the Java AWS SDK 1.3.6.
Has anyone else experienced this problem?
回答1:
Whoops - the queue was accidentally set to defaultVisibilityTimeout=0
. Changing this to a positive value fixed the problem.
This still raises a few questions though:
- Why did this only affect some messages? Perhaps some took longer to process?
- Why did Amazon return a 200 for delete when the messages weren't being deleted?
- Was the deletion failing because it fell outside of the 0-second window (in which case why did any deletion requests succeed?), or did they fail because another consumer had picked them up by the time the deletion request was received?
回答2:
Official documentation (version 1.9.13)
IMPORTANT: It is possible you will receive a message even after you have deleted it. This might happen on rare occasions if one of the servers storing a copy of the message is unavailable when you request to delete the message. The copy remains on the server and might be returned to you again on a subsequent receive request. You should create your system to be idempotent so that receiving a particular message more than once is not a problem.
来源:https://stackoverflow.com/questions/10194293/sqs-messages-not-deleting