| Did this page help you? Yes No Tell us about it... |
Once you receive the message, you must delete it from the queue to acknowledge that you processed
the message and no longer need it. You specify which message to delete by providing the
receipt handle that Amazon SQS returned when you received the message. You
can delete only one message per call. You can delete an entire queue with a call to
DeleteQueue, even if the queue has messages in it.
![]() | Note |
|---|---|
If you don't have the receipt handle for the message, you can call
|
The following examples demonstrate how to delete the message from your MyQueue
queue.
To delete a message
In the AWS Management Console select a queue.

Select View/Delete Messages from the Queue Actions drop-down list.
![]() | Note |
|---|---|
The Queue Actions drop-down list is available only if a queue is selected. |

Click Start Polling for Messages to view a message from the queue.

![]() | Note |
|---|---|
The Start Polling for Messages dialog box will not appear if you have previously selected the Don't show this again checkbox. |
The View/Delete Messages dialog box displays a message from the queue.

Select the message you want to delete.

Click Delete 1 Message to delete the selected message.
A Delete Messages confirmation dialog box appears.

Click Yes, Delete Checked Messages.
The selected message is deleted.
Click Close to close the View/Delete Messages dialog box.
To run the sample
In the scratchpad, select DeleteMessage from the Explore API list box.
Enter the queue URL in the Queue URL field.
Enter the receipt handle (which you received from the preceding
ReceiveMessage call) in the Receipt Handle
field.
Select one of the following:
To invoke the request, click Invoke Request. Amazon SQS returns a response.
To view the signed URL, click Display Signed URL. Then, copy and paste the signed URL into a browser. Amazon SQS returns a response.
To view the string to sign, click Display String to Sign.
To run the sample
Open SimpleQueueServiceSample.java.
The following section of the code deletes a message:
// Delete a message
System.out.println("Deleting a message.\n");
String messageRecieptHandle = messages.get(0).getReceiptHandle();
sqs.deleteMessage(new DeleteMessageRequest()
.withQueueUrl(myQueueUrl)
.withReceiptHandle(messageRecieptHandle));
Compile and run the sample.
The message is deleted from the MyQueue queue. The response includes the request ID that Amazon SQS assigned to your request.
To run the sample
Open Program.cs.
The following section of the code deletes a message:
//Deleting a message
Console.WriteLine("Deleting the message.\n");
DeleteMessageRequest deleteRequest = new DeleteMessageRequest();
deleteRequest.QueueUrl = myQueueUrl;
deleteRequest.ReceiptHandle = messageRecieptHandle;
sqs.DeleteMessage(deleteRequest);Run the sample.
The message is deleted from the MyQueue queue. The response includes the request ID that Amazon SQS assigned to your request.
To run the sample
Open DeleteMessageSample.pl.
Locate the following line.
# invokeDeleteMessage($service, $request);
Replace the line with the following new lines of code.
my $request = Amazon::SQS::Model::DeleteMessageRequest->new({
QueueUrl => "queue URL you received from CreateQueue call",
ReceiptHandle => "Receipt handle you received from ReceiveMessage call"
});
invokeDeleteMessage($service, $request);Run the sample.
The message is deleted from the MyQueue queue. The response includes the request ID that Amazon SQS assigned to your request.
To run the sample
Open DeleteMessageSample.php.
Locate the following line.
// invokeDeleteMessage($service, $request);
Replace the line with the following new lines of code.
require_once ('Amazon/SQS/Model/DeleteMessageRequest.php');
$request = new Amazon_SQS_Model_DeleteMessageRequest();
$request->setQueueUrl('queue URL you received from CreateQueue call');
$request->setReceiptHandle('Receipt handle you received from ReceiveMessage call');
invokeDeleteMessage($service, $request);Run the sample.
The message is deleted from the MyQueue queue. The response includes the request ID that Amazon SQS assigned to your request.