AWS SDK for .NET
Developer Guide

This documentation is for version 2.0 of the AWS SDK for .NET. For the latest version, see the AWS SDK for .NET Developer Guide for version 3.

Delete a Message from an Amazon SQS Queue

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

To delete a message from an Amazon SQS queue

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

    DeleteMessageRequest 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:

    DeleteMessageResponse response =
      amazonSQSClient.DeleteMessage(deleteMessageRequest);
    

    Calling DeleteMessage unconditionally removes the message from the queue, regardless of the visibility timeout setting. For more information about visibility timeouts, go to 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.