AWS SDK for .NET
Developer Guide

Deleting a Message from an Amazon SQS Queue

You can use the AWS SDK for .NET to delete messages from an Amazon SQS queue.

To delete a message from an Amazon SQS queue

For information about sending a message to a queue, see Sending an Amazon SQS Message.

For information about receiving messages from a queue, see Receiving a Message from an Amazon SQS Queue.

  1. Create and initialize a DeleteMessageRequest object. Specify the Amazon SQS queue to delete a message from and the receipt handle of the message to delete, as follows.

    var deleteMessageRequest = new DeleteMessageRequest(); deleteMessageRequest.QueueUrl = queueUrl; deleteMessageRequest.ReceiptHandle = recieptHandle;
  2. Pass the request object as a parameter to the DeleteMessage method. The method returns a DeleteMessageResponse object, as follows.

    var response = sqsClient.DeleteMessage(deleteMessageRequest);

    Calling DeleteMessage unconditionally removes the message from the queue, regardless of the visibility timeout setting. For more information about visibility timeouts, see Visibility Timeout.