SIGN UP MEMBER LOGIN:    
ARTICLE

Adding Message in a Windows Azure Queue

Posted by Dhananjay Kumar Articles | Cloud Computing September 21, 2011
In this post I will show you code snippet to add message to an azure queue.
Reader Level:

In this post I will show you code snippet to add message to an azure queue. I have written a function returning a Boolean value and taking a string input parameter to add as a message to the queue.
 

  1. Create instance of cloud storage account

    Adding message in a Windows Azure Queue
     
  2. Create a client of azure queue

    WinAzrQueue2.gif
     
  3. Get the reference of particular queue. Create queue if does not exist.

    Adding message in a Windows Azure Queue
     
  4. Add message to queue

    Adding message in a Windows Azure Queue

For your reference, the full source code is given below,

   public bool AddMessageinQueue(string MessageToAdd, string QueueName)
        {
            try
            {
                CloudStorageAccount account = CloudStorageAccount.Parse(RoleEnvironment.GetConfigurationSettingValue("DataConnectionString"
);
                CloudQueueClient queueClient = account.CreateCloudQueueClient();
                CloudQueue queue = queueClient.GetQueueReference(QueueName);
                queue.CreateIfNotExist();               
                  
                        CloudQueueMessage m = new CloudQueueMessage(MessageToAdd);
                        queue.AddMessage(m);
                   
                   
                    return true;
               

            }
            catch (Exception ex)
            {
                return false;
            }
        }


In this way you can add message to an azure queue. I hope this post was useful. Thanks for reading.

If you find my posts useful you may like to follow me on twitter http://twitter.com/debug_mode or may like Facebook page of my blog http://www.facebook.com/DebugMode.Net If you want to see post on a particular topic please do write on FB page or tweet me about that, I would love to help you.

Login to add your contents and source code to this article
share this article :
post comment
 

Hi , When you get a subscriptrion for Windows Azure , you can create two types of service 1. Hosted service 2. Srorage account. Storage account allows you to work with table , Blob , Queue. Each table/Blob/Queue in your table can be accessed via particular URI over REST ... however there are API also given to us to work with azure storage.

Posted by Dhananjay Kumar Sep 25, 2011

Hi dhananjay, can u tell me the function of cloud storage account in respect to Window Azure

Posted by Shweta Kuthi Sep 23, 2011
6 Months Free & No Setup Fees ASP.NET Hosting!
Become a Sponsor
PREMIUM SPONSORS
  • ceTE software specializes in components for dynamic PDF generation and manipulation. The DynamicPDF™ product line allows you to dynamically generate PDF documents, merge PDF documents and new content to existing PDF documents from within your applications. Visit DynamicPDF here
    ceTE software specializes in components for dynamic PDF generation and manipulation. The DynamicPDF™ product line allows you to dynamically generate PDF documents, merge PDF documents and new content to existing PDF documents from within your applications. Visit DynamicPDF here
Team Foundation Server Hosting
Become a Sponsor