Esempio n. 1
0
        /// <summary>
        /// Clears the queue.
        /// </summary>
        public async Task ClearQueue()
        {
            var startTime = DateTime.UtcNow;

            if (logger.IsEnabled(LogLevel.Trace))
            {
                logger.Trace("Clearing a queue: {0}", QueueName);
            }
            try
            {
                // that way we don't have first to create the queue to be able later to delete it.
                await queueClient.ClearMessagesAsync();

                logger.Info((int)AzureQueueErrorCode.AzureQueue_05, "Cleared Azure Queue {0}", QueueName);
            }
            catch (RequestFailedException exc)
            {
                if (exc.Status != (int)HttpStatusCode.NotFound)
                {
                    ReportErrorAndRethrow(exc, "ClearQueue", AzureQueueErrorCode.AzureQueue_06);
                }
            }
            catch (Exception exc)
            {
                ReportErrorAndRethrow(exc, "ClearQueue", AzureQueueErrorCode.AzureQueue_06);
            }
            finally
            {
                CheckAlertSlowAccess(startTime, "ClearQueue");
            }
        }
Esempio n. 2
0
        // These tests require Azure Storage Emulator v5.7
        public async Task <QueueClient> ContainerInit(string name)
        {
            var queue = new QueueClient(ConnectionString, name);
            await queue.CreateIfNotExistsAsync();

            await queue.ClearMessagesAsync();

            return(queue);
        }
Esempio n. 3
0
        public async Task ClearAsync_Error()
        {
            // Arrange
            var queueName = GetNewQueueName();
            QueueServiceClient service = GetServiceClient_SharedKey();
            QueueClient        queue   = InstrumentClient(service.GetQueueClient(queueName));

            // Act
            await TestHelper.AssertExpectedExceptionAsync <RequestFailedException>(
                queue.ClearMessagesAsync(),
                actualException => Assert.AreEqual("QueueNotFound", actualException.ErrorCode));
        }