Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • Retrieving message from an azure queue

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 183
    Comment on it

    In my previous blog, I had explained how to add a message in queue. Now here is the sample code to read the message from a queue  

     

    CloudStorageAccount storageAccount = CloudStorageAccount.Parse(RoleEnvironment.GetConfigurationSettingValue("torageConnectionString"));
                         CloudQueueClient queueClient = storageAccount.CreateCloudQueueClient();
    
                         // Retrieve a reference to a queue
                         CloudQueue queue = queueClient.GetQueueReference("queueName");
    
                         if (!queue.Exists())
                             continue;//In case queue is not found
    
                         //Retrieve message from queue
                         CloudQueueMessage retrievedMessage = queue.GetMessage();
                         if (retrievedMessage == null)
                             continue;//If Message is found null
    
                         string message = retrievedMessage.AsString;//Retrieve message in as string 
    
                         queue.DeleteMessage(retrievedMessage);//After reading the message, we should dequeue it so that it does not come in process again
    

    This way we can retrieve message from Azure queue

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: