forked from basavarajbhavi/Storage-Queuedemo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathProgram.cs
36 lines (31 loc) · 1.22 KB
/
Program.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
using System;
using Azure.Storage.Queues;
using Azure.Storage.Queues.Models;
namespace StorageQueueDemo
{
class Program
{
private const string storageConnectionString = "<STORAGE ACCOUNT CONNECTION STRING>";
private const string queueName = "store-messages";
static void Main(string[] args)
{
// Instantiate a QueueClient which will be used to create and manipulate the queue
QueueClient queueClient = new QueueClient(storageConnectionString, queueName);
if (queueClient.Exists())
{
while (true)
{
// Get the next message
QueueMessage[] retrievedMessages = queueClient.ReceiveMessages(1);
if (retrievedMessages.Length > 0)
{
// Process (i.e. print) the message in less than 30 seconds
Console.WriteLine($"Dequeued message: '{retrievedMessages[0].MessageText}'");
// Delete the message
queueClient.DeleteMessage(retrievedMessages[0].MessageId, retrievedMessages[0].PopReceipt);
}
}
}
}
}
}