Deleting a Message from an Amazon SQS Queue - AWS SDK for .NET (version 3)

This documentation is for version 3.0 of the AWS SDK for .NET, which is mostly centered around .NET Framework and ASP.NET 4.x, Windows, and Visual Studio.

The latest version of the documentation at is mostly centered around .NET Core and ASP.NET Core. In addition to Windows and Visual Studio, it gives equal consideration to cross-platform development.

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

  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 = receiptHandle;
  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.

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.