none
Azure

    Question

  • I have create a sample WPF application for Azure Queue Storage.

    It takes around a minute to add a single message to the queue.

    Following is my code -

    CloudStorageAccount storageAccount = CloudStorageAccount.Parse(
                     CloudConfigurationManager.GetSetting("StorageConnectionString"));

                // Create the queue client
                CloudQueueClient queueClient = storageAccount.CreateCloudQueueClient();

                CloudQueue queue = queueClient.GetQueueReference("emailqueue");

                // Create the queue if it doesn't already exist
                queue.CreateIfNotExists();

                Email objEmail = new Email
                {
                    To = "xxxx",
                    From = "xxxx",
                    Subject = "xxxx",
                    Body = "xxxx"
                };

                string emailMessage = JsonConvert.SerializeObject(objEmail);
                CloudQueueMessage message = new CloudQueueMessage(emailMessage);
                await queue.AddMessageAsync(message);

    Please suggest any performance improvements in above code.

    Monday, April 11, 2016 7:51 AM

All replies

  • I have create a sample WPF application for Azure Queue Storage.

    It takes around a minute to add a single message to the queue.

    Following is my code -

    CloudStorageAccount storageAccount = CloudStorageAccount.Parse(
                     CloudConfigurationManager.GetSetting("StorageConnectionString"));

                // Create the queue client
                CloudQueueClient queueClient = storageAccount.CreateCloudQueueClient();

                CloudQueue queue = queueClient.GetQueueReference("emailqueue");

                // Create the queue if it doesn't already exist
                queue.CreateIfNotExists();

                Email objEmail = new Email
                {
                    To = "xxxx",
                    From = "xxxx",
                    Subject = "xxxx",
                    Body = "xxxx"
                };

                string emailMessage = JsonConvert.SerializeObject(objEmail);
                CloudQueueMessage message = new CloudQueueMessage(emailMessage);
                await queue.AddMessageAsync(message);

    Please suggest any performance improvements in above code.

    Monday, April 11, 2016 7:49 AM
  • Hi,

    Thank you for posting here.

    By using REST API, you can manage timeouts for putting and getting massages from queue.

    For more information, refer given link:

    https://msdn.microsoft.com/en-us/library/dd179346.aspx

    Regards,

    Vikranth S

    Monday, April 11, 2016 4:27 PM
    Moderator
  • Are you sure it's the queue.AddMessage statement that's taking so long? I would add some debug statements and show the date/time stamp to see if that's really where your bottleneck it. I have written thousands of messages to a queue in the matter of a couple of minutes. What you are seeing is way too long.

    Why are you checking to see if the queue exists and creating it every time you want to write to it? This should be refactored so you do it once, not every time you write a message to the queue. If you take this out, does it speed up your process?

    Robin


    Sr. Content Developer at Microsoft

    Wednesday, April 20, 2016 2:53 AM