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

PurgeQueueAsync() public method

Deletes the messages in a queue specified by the QueueURL parameter.

When you use the PurgeQueue action, you can't retrieve a message deleted from a queue.

When you purge a queue, the message deletion process takes up to 60 seconds. All messages sent to the queue before calling the PurgeQueue action are deleted. Messages sent to the queue while it is being purged might be deleted. While the queue is being purged, messages sent to the queue before PurgeQueue is called might be received, but are deleted within the next minute.

/// Indicates that the specified queue previously received a PurgeQueue request /// within the last 60 seconds (the time it can take to delete the messages in the queue). /// /// The queue referred to doesn't exist. ///
public PurgeQueueAsync ( string queueUrl, PurgeQueueResponse>.AmazonServiceCallback callback, AsyncOptions options = null ) : void
queueUrl string The URL of the queue from which the PurgeQueue action deletes messages. Queue URLs are case-sensitive.
callback PurgeQueueResponse>.AmazonServiceCallback An Action delegate that is invoked when the operation completes.
options Amazon.Runtime.AsyncOptions /// A user-defined state object that is passed to the callback procedure. Retrieve this object from within the callback /// procedure using the AsyncState property. ///
return void
        public void PurgeQueueAsync(string queueUrl,  AmazonServiceCallback<PurgeQueueRequest, PurgeQueueResponse> callback, AsyncOptions options = null)
        {
            var request = new PurgeQueueRequest();
            request.QueueUrl = queueUrl;
            PurgeQueueAsync(request, callback, options);
        }

Same methods

AmazonSQSClient::PurgeQueueAsync ( PurgeQueueRequest request, System cancellationToken = default(CancellationToken) ) : Task
AmazonSQSClient::PurgeQueueAsync ( string queueUrl, System cancellationToken = default(CancellationToken) ) : Task
AmazonSQSClient::PurgeQueueAsync ( PurgeQueueRequest request, PurgeQueueResponse>.AmazonServiceCallback callback, AsyncOptions options = null ) : void

Usage Example

Example #1
0
        /// <summary>
        /// Purges the specified queue name.
        /// </summary>
        public void Purge()
        {
            try
            {
                using (var client = new AmazonSQSClient(_credentials))
                {
                    _logger.Value.InfoFormat("SqsMessageConsumer: Purging the queue {0}", _queueUrl);

                    client.PurgeQueueAsync(_queueUrl).Wait();

                    _logger.Value.InfoFormat("SqsMessageConsumer: Purged the queue {0}", _queueUrl);
                }
            }
            catch (Exception exception)
            {
                _logger.Value.ErrorException("SqsMessageConsumer: Error purging queue {0}", exception, _queueUrl);
                throw;
            }
        }
AmazonSQSClient