Amazon.SQS.AmazonSQSClient.PurgeQueueAsync C# (CSharp) Метод

PurgeQueueAsync() публичный Метод

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, System cancellationToken = default(CancellationToken) ) : Task
queueUrl string The URL of the queue from which the PurgeQueue action deletes messages. Queue URLs are case-sensitive.
cancellationToken System /// A cancellation token that can be used by other objects or threads to receive notice of cancellation. ///
Результат Task
        public Task<PurgeQueueResponse> PurgeQueueAsync(string queueUrl, System.Threading.CancellationToken cancellationToken = default(CancellationToken))
        {
            var request = new PurgeQueueRequest();
            request.QueueUrl = queueUrl;
            return PurgeQueueAsync(request, cancellationToken);
        }

Same methods

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

Usage 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