Exemple #1
0
        public void DeleteReservedMessageViaQueue()
        {
            PostTwoMessages();
            var message = queue.Reserve();
            var deleted = queue.DeleteMessage(message.Id, message.ReservationId);

            Assert.IsTrue(deleted);
            Assert.AreEqual(queue.Info().Size, 1);
        }
        /// <summary>
        /// Receive and process messages from a queue.
        /// </summary>
        /// <param name="connectionString">
        /// A connection string to your Azure Storage account.
        /// </param>
        /// <param name="queueName">
        /// The name of an existing queue to operate on.
        /// </param>
        public static void ReceiveMessages(string connectionString, string queueName)
        {
            #region Snippet:Azure_Storage_Queues_Samples_Sample01a_HelloWorld_ReceiveMessages
            // We'll need a connection string to your Azure Storage account.
            //@@ string connectionString = "<connection_string>";

            // Name of an existing queue we'll operate on
            //@@ string queueName = "sample-queue";

            // Get a reference to a queue and then fill it with messages
            QueueClient queue = new QueueClient(connectionString, queueName);
            queue.SendMessage("first");
            queue.SendMessage("second");
            queue.SendMessage("third");

            // Get the next messages from the queue
            foreach (QueueMessage message in queue.ReceiveMessages(maxMessages: 10).Value)
            {
                // "Process" the message
                Console.WriteLine($"Message: {message.MessageText}");

                // Let the service know we're finished with the message and
                // it can be safely deleted.
                queue.DeleteMessage(message.MessageId, message.PopReceipt);
            }
            #endregion Snippet:Azure_Storage_Queues_Samples_Sample01a_HelloWorld_ReceiveMessages
        }
Exemple #3
0
        public void DequeueMessages()
        {
            // <snippet_DequeueMessages>
            // Get the connection string from app settings
            string connectionString = ConfigurationManager.AppSettings["StorageConnectionString"];

            // Instantiate a QueueClient which will be used to create and manipulate the queue
            QueueClient queueClient = new QueueClient(connectionString, "myqueue");

            if (queueClient.Exists())
            {
                // Receive and process 20 messages
                QueueMessage[] receivedMessages = queueClient.ReceiveMessages(20, TimeSpan.FromMinutes(5));

                foreach (QueueMessage message in receivedMessages)
                {
                    // Process (i.e. print) the messages in less than 5 minutes
                    Console.WriteLine($"De-queued message: '{message.MessageText}'");

                    // Delete the message
                    queueClient.DeleteMessage(message.MessageId, message.PopReceipt);
                }
            }
            // </snippet_DequeueMessages>
        }
Exemple #4
0
        private async void ReceiveC2dFromQueueAsync()
        {
            receiveLoopChecked = true;

            // Create the queue client.
            QueueClient queueClient = new QueueClient(queueStorageConnString, deviceId);

            while (receiveLoopChecked)
            {
                QueueMessage[] queueMessages = await queueClient.ReceiveMessagesAsync();

                if (queueMessages == null || queueMessages.Length == 0)
                {
                    await Task.Delay(100);

                    //Thread.Sleep(100);
                }
                else
                {
                    foreach (var queueMessage in queueMessages)
                    {
                        var receivedMessage = queueMessage.MessageText;
                        textBoxOutput.Text  = string.Format("** Received from Queue Storage ** (Datetime:{0})", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff"));
                        textBoxOutput.Text += Environment.NewLine;
                        textBoxOutput.Text += receivedMessage;
                        queueClient.DeleteMessage(queueMessage.MessageId, queueMessage.PopReceipt);
                    }
                }
            }
        }
        public void SendReceiveMessages()
        {
            // Name of the queue to send messages to
            Uri queueUri = new Uri(ConfigurationManager.AppSettings["QueueUri"]);

            var credentials = new ClientSecretCredential(
                ConfigurationManager.AppSettings["TenantID"],
                ConfigurationManager.AppSettings["ClientID"],
                ConfigurationManager.AppSettings["ClientSecret"]
                );

            // Create queue client using accountURI and Service Principal credentials
            QueueClient queueClient = new QueueClient(queueUri, credentials);

            // sending test messages
            for (int i = 0; i < 10; i++)
            {
                queueClient.SendMessage($"{i} - {DateTime.Now.Ticks}");
            }

            // Read messages from the queue
            foreach (QueueMessage message in queueClient.ReceiveMessages(maxMessages: 10).Value)
            {
                // Display the message and its properties
                Console.WriteLine($"Message: \"{message.Body}\" : {message.MessageId} : {message.InsertedOn}");

                // Delete the message once it has been processed
                queueClient.DeleteMessage(message.MessageId, message.PopReceipt);
            }
            Console.WriteLine("Completed Successfully!");
        }
Exemple #6
0
        /// <summary>
        /// This is where the work of the completer happens
        /// </summary>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        private async Task RunAsync(CancellationToken cancellationToken)
        {
            var messageCount = 0;
            var backoff      = 1;

            while (_queueClient.Exists())
            {
                // Receive and process messages in batches
                var receivedMessages = (await _queueClient.ReceiveMessagesAsync(20, TimeSpan.FromMinutes(5))).Value;

                // there was something to read out of the queue
                if (receivedMessages.Any())
                {
                    // reset the backoff
                    backoff = 1;

                    // iterate over the messages we got from the queue
                    foreach (var receivedMessage in receivedMessages)
                    {
                        // Deseralize the message
                        var message = JsonConvert.DeserializeObject <Replicatable>(receivedMessage.MessageText);

                        // Convert the detination uri string to a uri
                        var newUri = new Uri(message.Destination);

                        // lookup the image record in the database
                        var image = _imageContext.Images
                                    .FirstOrDefault(x => x.ImageId == int.Parse(message.DiagnosticInfo["ImageId"]));

                        if (image != null)
                        {
                            // update the image record with the new url (without the SAS)
                            image.Url = newUri.GetLeftPart(UriPartial.Path);

                            // Save th changes to sql server
                            await _imageContext.SaveChangesAsync(cancellationToken);

                            // incrament our counter
                            messageCount++;
                        }

                        // Delete the message
                        _queueClient.DeleteMessage(receivedMessage.MessageId, receivedMessage.PopReceipt);
                    }

                    _logger.LogInformation($"Sample WebAppCompleter Worker batch complete. Total message count {messageCount} at {DateTimeOffset.UtcNow}");
                }
                else
                {
                    //queue empty, exponential backoff (in minutes)
                    await Task.Delay(backoff * 60000, cancellationToken);

                    backoff = backoff * 2;
                }
            }

            _logger.LogInformation($"Sample WebAppCompleter Worker Done updating the DB. Total message count {messageCount} at {DateTimeOffset.UtcNow}");
        }
        static void Main(string[] args)
        {
            Console.OutputEncoding = Encoding.UTF8;
            UrlCrawler bot = new UrlCrawler();
            //bot.Run();

            var queueName = "runurlqueue";
            // Get the connection string from app settings
            string connectionString = ConfigurationManager.AppSettings["StorageConnectionString"];

            // Instantiate a QueueClient which will be used to manipulate the queue
            QueueClient queueClient = new QueueClient(connectionString, queueName);

            //queue polling
            //if have messgae in queue then -> process messgae
            //if not -> waiting for specific time then stop
            var currentInterval = 0;
            var maxInterval     = 15;

            if (queueClient.Exists())
            {
                while (true)
                {
                    try
                    {
                        // Get the next message
                        QueueMessage[] retrievedMessage = queueClient.ReceiveMessages(1, TimeSpan.FromSeconds(120));
                        //get messge text
                        var message = retrievedMessage[0].MessageText;
                        // Process the message in less than 120 seconds
                        Console.WriteLine(message);
                        //run bot when received message
                        bot.Run();
                        //reset interval
                        currentInterval = 0;
                        Console.WriteLine(currentInterval);
                        // Delete the message
                        queueClient.DeleteMessage(retrievedMessage[0].MessageId, retrievedMessage[0].PopReceipt);
                    }
                    catch (Exception err)
                    {
                        Console.WriteLine(err.Message);
                        if (currentInterval < maxInterval)
                        {
                            currentInterval++;
                        }
                        else
                        {
                            break;
                        }
                        Console.WriteLine("waiting for " + currentInterval + "s");
                        Thread.Sleep(TimeSpan.FromSeconds(currentInterval));
                    }
                }
            }
            Console.WriteLine("Press any key to continue...");
            Console.ReadLine();
        }
 public void DeleteMessage()
 {
     if (queueClient.Exists())
     {
         Azure.Storage.Queues.Models.QueueMessage[] retrievedMessage = queueClient.ReceiveMessages();
         Console.WriteLine($"Pop Receipt is {retrievedMessage[0].PopReceipt}");
         queueClient.DeleteMessage(retrievedMessage[0].MessageId, retrievedMessage[0].PopReceipt);
     }
 }
        /// <summary>
        ///    Pops and returns a message from the queue.
        /// </summary>
        /// <returns>The message text or null if there is no messages to return</returns>
        public async Task <string> GetMessage()
        {
            QueueMessage[] messages = await _queue.ReceiveMessagesAsync();

            if (messages.Length == 0)
            {
                return(null);
            }


            var m = messages[0];

            string msg = m.MessageText;

            _queue.DeleteMessage(m.MessageId, m.PopReceipt);

            return(msg);
        }
        public void Acknowledge(object acknowledgementToken)
        {
            Guard.AgainstNull(acknowledgementToken, nameof(acknowledgementToken));

            lock (_lock)
            {
                if (!(acknowledgementToken is AcknowledgementToken data))
                {
                    return;
                }

                if (_acknowledgementTokens.ContainsKey(data.MessageId))
                {
                    _acknowledgementTokens.Remove(data.MessageId);
                }

                _queueClient.DeleteMessage(data.MessageId, data.PopReceipt);
            }
        }
        static String GetNextMessage(QueueClient queueClient)
        {
            QueueMessage[] retrievedMessages = queueClient.ReceiveMessages();
            QueueMessage   retrievedMessage  = retrievedMessages[0];

            String message = retrievedMessage.MessageText;

            queueClient.DeleteMessage(retrievedMessage.MessageId, retrievedMessage.PopReceipt);

            return(message);
        }
Exemple #12
0
        /// <summary>
        /// This Function will dequemsg
        /// </summary>
        public static void DequeueMessageInQueue()
        {
            QueueServiceClient queueServiceClient = new QueueServiceClient(connectionString);
            QueueClient        queueClient        = queueServiceClient.GetQueueClient(queueName);

            queueClient.CreateIfNotExists();

            if (queueClient.Exists())
            {
                QueueMessage[] queueMessages = queueClient.ReceiveMessages();
                queueClient.DeleteMessage(queueMessages[0].MessageId, queueMessages[0].PopReceipt);
            }
        }
        public void DequeueMessage(string queueName, string messageId, string popReceipt)
        {
            QueueClient queueClient = CreateQueueClient(queueName);

            if (queueClient.Exists())
            {
                QueueMessage[] retrievedMessage = queueClient.ReceiveMessages();

                queueClient.DeleteMessage(messageId, popReceipt);

                Console.WriteLine($"Dequeued message Id: '{messageId}");
            }
        }
Exemple #14
0
        public void DequeueMessage(string queueName, QueueMessage message)
        {
            // Get the connection string from app settings
            string connectionString = ConfigurationManager.AppSettings["StorageConnectionString"];

            // Instantiate a QueueClient which will be used to manipulate the queue
            QueueClient queueClient = new QueueClient(connectionString, queueName);

            if (queueClient.Exists())
            {
                // Delete the message
                queueClient.DeleteMessage(message.MessageId, message.PopReceipt);
            }
        }
        public void RegisterOnMessageHandlerAndReceiveMessages()
        {
            using var scope = _serviceScopeFactory.CreateScope();
            var dispatcher = scope.ServiceProvider.GetService <ICommandDispatcher>();

            while (_queueClient.Exists())
            {
                var     message         = _queueClient.ReceiveMessage().Value;
                var     messageAsString = Encoding.UTF8.GetString(message.Body);
                dynamic command         = JsonConvert.DeserializeObject(messageAsString);
                AsyncHelper.RunSync(() => dispatcher.SendAsync(command).ConfigureAwait(false));
                _queueClient.DeleteMessage(message.MessageId, message.PopReceipt);
            }
        }
Exemple #16
0
 public void DeleteMessage(string queueName, string messageId, string popReceipt)
 {
     try
     {
         QueueClient queueClient = new QueueClient(this.ConnectionString, queueName);
         if (queueClient.Exists())
         {
             queueClient.DeleteMessage(messageId, popReceipt);
         }
     }
     catch (Exception ex)
     {
         this.ErrorMessage = ex.ToString();
     }
 }
Exemple #17
0
        public void GetDamage()
        {
            var messageWrapper = _queueClient.RetrieveQueueMessage();

            if (messageWrapper == null || messageWrapper.Message == null || messageWrapper.Message == "")
            {
                return;
            }

            var damage = int.Parse(messageWrapper.Message);

            ApplyDamage(damage);

            _queueClient.DeleteMessage(messageWrapper.MessageId, messageWrapper.PopReceipt);
        }
        private void DoWork(object state)
        {
            _logger.LogInformation("=========================");

            QueueMessage[] retrievedMessage = _queueClient.ReceiveMessages(20);

            _logger.LogInformation("RetrievedMessage Count: " + retrievedMessage.Count());
            foreach (var message in retrievedMessage)
            {
                _logger.LogInformation($"Deleted message:");
                _logger.LogInformation(Base64Service.DecodeBase64ToString(message.MessageText));
                longTaskRunningMessageSender.SendAll(message.MessageText);
                _queueClient.DeleteMessage(message.MessageId, message.PopReceipt);
            }
        }
Exemple #19
0
        public void DequeueAndUpdate()
        {
            // Get a connection string to our Azure Storage account.
            string connectionString = ConnectionString;

            // Get a reference to a queue named "sample-queue" and then create it
            QueueClient queue = new QueueClient(connectionString, Randomize("sample-queue"));

            queue.Create();
            try
            {
                // Add several messages to the queue
                queue.EnqueueMessage("first");
                queue.EnqueueMessage("second");
                queue.EnqueueMessage("third");

                // Get the messages from the queue with a short visibility timeout
                List <DequeuedMessage> messages = new List <DequeuedMessage>();
                foreach (DequeuedMessage message in queue.DequeueMessages(10, TimeSpan.FromSeconds(1)).Value)
                {
                    // Tell the service we need a little more time to process the message
                    UpdatedMessage changedMessage = queue.UpdateMessage(
                        message.MessageText,
                        message.MessageId,
                        message.PopReceipt,
                        TimeSpan.FromSeconds(5));
                    messages.Add(message.Update(changedMessage));
                }

                // Wait until the visibility window times out
                Thread.Sleep(TimeSpan.FromSeconds(1.5));

                // Ensure the messages aren't visible yet
                Assert.AreEqual(0, queue.DequeueMessages(10).Value.Count());

                // Finish processing the messages
                foreach (DequeuedMessage message in messages)
                {
                    // Tell the service we need a little more time to process the message
                    queue.DeleteMessage(message.MessageId, message.PopReceipt);
                }
            }
            finally
            {
                // Clean up after the test when we're finished
                queue.Delete();
            }
        }
Exemple #20
0
        /// <summary>
        /// Update message in Azure Queue Storage
        /// </summary>
        /// <returns></returns>
        public static string DeleteMsgByIdQueue()
        {
            QueueClient queueClient = new QueueClient(queue_connection_string, queue_name);

            if (queueClient.Exists())
            {
                // Get the next message
                QueueMessage[] retrievedMessage = queueClient.ReceiveMessages();

                if (retrievedMessage.Length > 0)
                {
                    queueClient.DeleteMessage(retrievedMessage[0].MessageId, retrievedMessage[0].PopReceipt);
                }
            }
            return("Message delete Successfully");
        }
Exemple #21
0
        static void Main(string[] args)
        {
            QueueClient queueClient = new QueueClient(connectionString, queueName);

            //Create the queue
            queueClient.CreateIfNotExists();

            //Sending messages to the queue.
            for (int i = 0; i < maxNumOfMessages; i++)
            {
                queueClient.SendMessageAsync($"Message {i} {DateTime.Now}");
            }

            //Getting the length of the queue
            QueueProperties queueProperties    = queueClient.GetProperties();
            int?            cachedMessageCount = queueProperties.ApproximateMessagesCount;

            //Reading messages from the queue without removing the message
            Console.WriteLine("Reading message from the queue without removing them from the queue");
            PeekedMessage[] peekedMessages = queueClient.PeekMessages((int)cachedMessageCount);

            foreach (PeekedMessage peekedMessage in peekedMessages)
            {
                Console.WriteLine($"Message read from the queue: {peekedMessage.MessageText}");

                //Getting the length of the queue
                queueProperties = queueClient.GetProperties();
                int?queueLenght = queueProperties.ApproximateMessagesCount;
                Console.WriteLine($"Current lenght of the queue {queueLenght}");
            }

            //Reading messages removing it from the queue
            Console.WriteLine("Reading message from the queue removing");
            QueueMessage[] messages = queueClient.ReceiveMessages((int)cachedMessageCount);
            foreach (QueueMessage message in messages)
            {
                Console.WriteLine($"Message read from the queue: {message.MessageText}");
                //You need to process the message in less than 30 seconds.
                queueClient.DeleteMessage(message.MessageId, message.PopReceipt);

                //Getting the length of the queue
                queueProperties = queueClient.GetProperties();
                int?queueLenght = queueProperties.ApproximateMessagesCount;
                Console.WriteLine($"Current lenght of the queue {queueLenght}");
            }
        }
Exemple #22
0
        //-------------------------------------------------
        // Process and remove a message from the queue
        //-------------------------------------------------
        public void DequeueMessage(string queueName)
        {
            // Instantiate a QueueClient which will be used to manipulate the queue
            QueueClient queueClient = new QueueClient(ConnectionString, queueName);

            if (queueClient.Exists())
            {
                // Get the next message
                QueueMessage[] retrievedMessage = queueClient.ReceiveMessages();

                // Process (i.e. print) the message in less than 30 seconds
                Console.WriteLine($"Dequeued message: '{retrievedMessage[0].MessageText}'");

                // Delete the message
                queueClient.DeleteMessage(retrievedMessage[0].MessageId, retrievedMessage[0].PopReceipt);
            }
        }
Exemple #23
0
        static async Task Main(string[] args)
        {
            QueueClient queue = new QueueClient(CONNECTION_STRING, "nowezamowienia");

            if (await queue.ExistsAsync())
            {
                QueueProperties properties = await queue.GetPropertiesAsync();

                if (properties.ApproximateMessagesCount > 0)
                {
                    QueueMessage[] messages = await queue.ReceiveMessagesAsync(1);

                    Console.WriteLine(messages[0].MessageText);

                    queue.DeleteMessage(messages[0].MessageId, messages[0].PopReceipt);
                }
            }
        }
Exemple #24
0
        public void Dequeue()
        {
            // Get a connection string to our Azure Storage account.
            string connectionString = ConnectionString;

            // Get a reference to a queue named "sample-queue" and then create it
            QueueClient queue = new QueueClient(connectionString, Randomize("sample-queue"));

            queue.Create();
            try
            {
                // Add several messages to the queue
                queue.EnqueueMessage("first");
                queue.EnqueueMessage("second");
                queue.EnqueueMessage("third");
                queue.EnqueueMessage("fourth");
                queue.EnqueueMessage("fifth");

                // Get the next 10 messages from the queue
                List <string> messages = new List <string>();
                foreach (DequeuedMessage message in queue.DequeueMessages(maxMessages: 10).Value)
                {
                    // "Process" the message
                    messages.Add(message.MessageText);

                    // Let the service know we finished with the message and
                    // it can be safely deleted.
                    queue.DeleteMessage(message.MessageId, message.PopReceipt);
                }

                // Verify the messages
                Assert.AreEqual(5, messages.Count);
                Assert.Contains("first", messages);
                Assert.Contains("second", messages);
                Assert.Contains("third", messages);
                Assert.Contains("fourth", messages);
                Assert.Contains("fifth", messages);
            }
            finally
            {
                // Clean up after the test when we're finished
                queue.Delete();
            }
        }
Exemple #25
0
        static void Main(string[] args)
        {
            var queueConnection = Environment.GetEnvironmentVariable("QCONNECTION");

            QueueClient queue = new QueueClient(queueConnection, "keda");

            Console.CancelKeyPress += new ConsoleCancelEventHandler(cancelHandler);

            while (!canToken.IsCancellationRequested)
            {
                foreach (QueueMessage message in queue.ReceiveMessages(maxMessages: 1).Value)
                {
                    Console.WriteLine($"Message: {message.Body}");
                    queue.DeleteMessage(message.MessageId, message.PopReceipt);
                }
                Console.WriteLine("Waiting 5 seconds.");
                Task.Delay(5000).Wait();
            }
        }
        /// <summary>
        /// Receive messages and update their visibility timeout for extended
        /// processing.
        /// </summary>
        /// <param name="connectionString">
        /// A connection string to your Azure Storage account.
        /// </param>
        /// <param name="queueName">
        /// The name of an existing queue to operate on.
        /// </param>
        public static void ReceiveAndUpdate(string connectionString, string queueName)
        {
            // Add several messages to the queue
            QueueClient queue = new QueueClient(connectionString, queueName);

            queue.SendMessage("first");
            queue.SendMessage("second");
            queue.SendMessage("third");

            // Get the messages from the queue with a short visibility timeout
            // of 1 second
            List <QueueMessage> messages = new List <QueueMessage>();

            foreach (QueueMessage message in queue.ReceiveMessages(10, TimeSpan.FromSeconds(1)).Value)
            {
                // Tell the service we need a little more time to process the
                // message by giving them a 5 second visiblity window
                UpdateReceipt receipt = queue.UpdateMessage(
                    message.MessageId,
                    message.PopReceipt,
                    message.MessageText,
                    TimeSpan.FromSeconds(5));

                // Keep track of the updated messages
                messages.Add(message.Update(receipt));
            }

            // Wait until the original 1 second visiblity window times out and
            // check to make sure the messages aren't showing up yet
            Thread.Sleep(TimeSpan.FromSeconds(1.5));
            Assert.AreEqual(0, queue.ReceiveMessages(10).Value.Length);

            // Finish processing the messages
            foreach (QueueMessage message in messages)
            {
                // "Process" the message
                Console.WriteLine($"Message: {message.MessageText}");

                // Tell the service we need a little more time to process the message
                queue.DeleteMessage(message.MessageId, message.PopReceipt);
            }
        }
        public void DequeueMultipleMessages(string queueName, string to)
        {
            QueueClient queueClient = CreateQueueClient(queueName);

            if (queueClient.Exists())
            {
                QueueMessage[] receivedMessages = queueClient.ReceiveMessages(20, TimeSpan.FromMinutes(1));

                foreach (QueueMessage message in receivedMessages)
                {
                    string decodedMessage = Decode.Base64Decode(message.MessageText);

                    Console.WriteLine($"Deleted message: '{decodedMessage}'");

                    queueClient.DeleteMessage(message.MessageId, message.PopReceipt);

                    _smtp.SendEmail(decodedMessage, to);
                }
            }
        }
Exemple #28
0
        static void Main(string[] args)
        {
            string       connectionString = Environment.GetEnvironmentVariable("ConnectionString");
            const string queueName        = "test-queue";

            QueueClient client  = new QueueClient(connectionString, queueName);
            var         message = client.ReceiveMessage();

            if (message.Value != null)
            {
                Console.WriteLine(message.Value.Body);
                client.DeleteMessage(message.Value.MessageId, message.Value.PopReceipt);
            }
            else
            {
                Console.WriteLine("No message");
            }

            Thread.Sleep(2000);
        }
Exemple #29
0
        public async Task <UserOutQueueItem> Dequeue()
        {
            if (!await _outQueueClient.ExistsAsync())
            {
                throw new InvalidOperationException("User outqueue client does not exist.");
            }

            var result = await _outQueueClient.ReceiveMessagesAsync();

            var message = result.Value.FirstOrDefault();

            if (message == null)
            {
                throw new NullReferenceException(nameof(message));
            }

            _outQueueClient.DeleteMessage(message.MessageId, message.PopReceipt);

            return(new UserOutQueueItem(true, message.MessageText));
        }
Exemple #30
0
        public static void DequeueMessage()
        {
            //ToDO: Get the connection string from app settings
            var connectionString =
                @"DefaultEndpointsProtocol=https;AccountName=testbusinesstorage;AccountKey=Dm8SUVbN8WvU+LapoOGTB+O+u3b07Tt5WPY9cqTS6WOvNQSR1Os7DLvQkubIk0VnzMMiOrZeEk3j5ykZK8A3qw==;EndpointSuffix=core.windows.net";

            var queueClient = new QueueClient(connectionString, "test");

            if (queueClient.Exists())
            {
                // Get the next message
                QueueMessage[] retrievedMessage = queueClient.ReceiveMessages();

                // Process (i.e. print) the message in less than 30 seconds
                Console.WriteLine($"Dequeued message: '{Encoding.UTF8.GetString(Convert.FromBase64String(retrievedMessage[0].MessageText))}'");

                // Delete the message
                queueClient.DeleteMessage(retrievedMessage[0].MessageId, retrievedMessage[0].PopReceipt);
            }
        }