Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get message ID in Azure queue

Tags:

azure

Is there a way to get the message ID after insert it in a queue Azure ?

CloudStorageAccount storageAccount = 
    CloudStorageAccount.parse(storageConnectionString);

CloudQueueClient queueClient = storageAccount.createCloudQueueClient();

CloudQueue queue = queueClient.getQueueReference("myqueue");

queue.createIfNotExist();

CloudQueueMessage message = new CloudQueueMessage("Hello, World");
queue.addMessage(message);

// Get message ID here ?
like image 285
JGeo Avatar asked Feb 13 '23 20:02

JGeo


2 Answers

I realize it has been 5 years since this was originally asked; however, it is now possible to achieve this.

CloudQueueMessage message = new CloudQueueMessage("Hello, World");
queue.AddMessage(message);

// here's how you get the id
string id = message.Id;
like image 131
Safari137 Avatar answered Feb 20 '23 02:02

Safari137


Only way you could get the message id is by getting the message. So you would have to fetch messages from the queue using GetMessage or GetMessages method. However there's no guarantee that you will get the message you just created as GetMessages can only return up to 32 visible messages from the top of the queue.

like image 21
Gaurav Mantri Avatar answered Feb 20 '23 01:02

Gaurav Mantri