| « PreviousNext » | |
![]() ![]() | Did this page help you? Yes | No | Tell us about it... |
The DeleteMessage action deletes the specified message from the specified
queue. You specify the message by using the message's receipt
handle and not the message ID you received when you
sent the message. Even if the message is locked by another reader due to the visibility
timeout setting, it is still deleted from the queue. If you leave a message in the queue
for longer than the queue’s configured retention period , SQS automatically deletes
it.
Note
The receipt handle is associated with a specific instance of receiving the message. If
you receive a message more than once, the receipt handle you get each time you receive the
message is different. When you request DeleteMessage, if you don't
provide the most recently received receipt handle for the message, the request will still
succeed, but the message might not be deleted.
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.
The following table lists the special request parameters the DeleteMessage
action uses in addition to the common parameters all actions use. For more information, see Common Query Parameters.
| Name | Description | Required |
|---|---|---|
|
|
The receipt handle associated with the message you want to delete. Type: String |
Yes |
The response contains no special elements besides the common elements returned in all successful responses. For more information, see Responses section in the Amazon SQS Developer Guide.
The request doesn't fail unless the ReceiptHandle is malformed. Even if
the specified ReceiptHandle doesn't exist or isn't the most recently
returned receipt handle for that message, the action returns Success.
The following example Query request deletes a message from the specified queue.
http://sqs.us-east-1.amazonaws.com/123456789012/testQueue/ ?Action=DeleteMessage &ReceiptHandle=MbZj6wDWli%2BJvwwJaBV%2B3dcjk2YW2vA3%2BSTFFljT M8tJJg6HRG6PYSasuWXPJB%2BCwLj1FjgXUv1uSj1gUPAWV66FU/WeR4mq2OKpEGY WbnLmpRCJVAyeMjeU5ZBdtcQ%2BQEauMZc8ZRv37sIW2iJKq3M9MFx1YvV11A2x/K SbkJ0= &Version=2009-02-01 &SignatureMethod=HmacSHA256 &Expires=2009-04-18T22%3A52%3A43PST &AWSAccessKeyId=AKIAIOSFODNN7EXAMPLE &SignatureVersion=2 &Signature=Dqlp3Sd6ljTUA9Uf6SGtEExwUQEXAMPLE
<DeleteMessageResponse>
<ResponseMetadata>
<RequestId>
b5293cb5-d306-4a17-9048-b263635abe42
</RequestId>
</ResponseMetadata>
</DeleteMessageResponse>