Amazon.SQS.AmazonSQSClient.DeleteQueue C# (CSharp) Method

DeleteQueue() public method

Deletes the queue specified by the QueueUrl, even if the queue is empty. If the specified queue doesn't exist, Amazon SQS returns a successful response.

Be careful with the DeleteQueue action: When you delete a queue, any messages in the queue are no longer available.

When you delete a queue, the deletion process takes up to 60 seconds. Requests you send involving that queue during the 60 seconds might succeed. For example, a SendMessage request might succeed, but after 60 seconds the queue and the message you sent no longer exist.

When you delete a queue, you must wait at least 60 seconds before creating a queue with the same name.

public DeleteQueue ( DeleteQueueRequest request ) : Amazon.SQS.Model.DeleteQueueResponse
request Amazon.SQS.Model.DeleteQueueRequest Container for the necessary parameters to execute the DeleteQueue service method.
return Amazon.SQS.Model.DeleteQueueResponse
        public DeleteQueueResponse DeleteQueue(DeleteQueueRequest request)
        {
            var marshaller = new DeleteQueueRequestMarshaller();
            var unmarshaller = DeleteQueueResponseUnmarshaller.Instance;

            return Invoke<DeleteQueueRequest,DeleteQueueResponse>(request, marshaller, unmarshaller);
        }

Same methods

AmazonSQSClient::DeleteQueue ( string queueUrl ) : Amazon.SQS.Model.DeleteQueueResponse

Usage Example

        public void When_obtaining_details_on_a_message_queue(string queueName, bool exists)
        {
            // Arrange
            var client = new AmazonSQSClient("access key", "secret key");

            if (exists)
            {
                client.CreateQueue(new CreateQueueRequest().WithQueueName(queueName));
            }
            else
            {
                var response = client.ListQueues(new ListQueuesRequest().WithQueueNamePrefix(queueName));
                if (response.ListQueuesResult.QueueUrl.Any())
                {
                    client.DeleteQueue(new DeleteQueueRequest().WithQueueUrl(response.ListQueuesResult.QueueUrl.First()));
                }
            }

            Thread.Sleep(2000); // Give the queues some time to spin up
          
            var factory = new AmazonSqsMessageQueueDetailFactory(client);


            // Act
            var result = factory.Build<TestMessage>(queueName);

            // Assert
            Assert.That(result.Uri, Is.StringContaining(queueName));
            Assert.That(result.Exists, Is.EqualTo(exists));
        }  
All Usage Examples Of Amazon.SQS.AmazonSQSClient::DeleteQueue
AmazonSQSClient