Azure queues are helpful in background processes. It provides reliable messaging solutions for independent asynchronous communication between components in application.
Here is a sample code for adding message in a queue
//Create an object of cloud storage
CloudStorageAccount storageAccount= CloudStorageAccount.Parse(StorageConnectionString);
//Create an object of CloudQueueClient
CloudQueueClient queueClient = storageAccount.CreateCloudQueueClient();
//Get reference of cloud queue by passing cloud queue name
CloudQueue queue = queueClient.GetQueueReference("queueName");
//Create a cloud key if it does not exists
queue.CreateIfNotExists();
//Create an CloudMessageQueue with our content as constructor`s parameter
CloudQueueMessage message = new CloudQueueMessage(MyMessage);
//Add Message to queue
queue.AddMessage(message);
0 Comment(s)