So im sending an item off my ASP.NET Web API to a Azure Storage Queue and i'd like to provide some feedback to the user on the position of their item in the queue aswell as be able to update them on the position of their item if they come back or something similar.
Not that it has much to do with the question here but this is the method im using to place the item in the Queue
CloudStorageAccount storageAccount = CloudStorageAccount.Parse(ConfigHelper.GetAzureStorage());
CloudQueueClient queueClient = storageAccount.CreateCloudQueueClient();
CloudQueue queue = queueClient.GetQueueReference("my-queue");
await queue.CreateIfNotExistsAsync();
var messageJson = JsonConvert.SerializeObject(item);
CloudQueueMessage cloudQueueMessage = new CloudQueueMessage(messageJson);
await queue.AddMessageAsync(cloudQueueMessage);
So i've poked around CloudQueueClient
and CloudQueue
but all I could find was CloudQueue.ApproximateMessageCount
which always returned null.
I've also tried a bit of googling how that always comes up with Getting started guides, noting specifically around how i'd go about getting the size then position of the item in a queue, so is it even possible?
It's not possible to get the position of the item within the queue.
For the approximate message count, you must call FetchAttributes
or FetchAttributesAsync
before retrieving the value. This will populate ApproximateMessageCount
with the actual value from the queue.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With