Hello Azure Experts !
I am in a need to browse through the messages in the service bus queue using peek().
Say, there are 500 servicepathURL I am sending a message request 500 messages in total. I store these 500 request messages and correlation ids in a DB Table. Each servicepathURL respond back to a different destination URL(Ack ServicepathURL). So there will
be 500 ack messages. Now, I need check the Ack ServicepathURL for each of the 500 messages i sent.
Pseudocode
foreach (corrid in DB table) //total 500 corrIds { BrokeredMessage message = new BrokeredMessage(); message = null; // Start searching the corrid 1 // Next iteration of for loop. Continue Looking corrid 2 while ((message = reader.Peek()) != null && row_count > 0) // total 500 msgs in the queue { // Here I just peek, not receive. So the message will still stay in the queue if (DB.corrId == message.corrId { write_log("Found My Message") } } //End While } // End Foreach... For loop continues
From the above pseudo code, it is shown that, I take a corrId from my local DB table, compare it with 500 messages in the queue, If a match is found, I mark it as MESSAGE FOUND in the table. But not marking the message as complete. So the message will be left in the queue.
Then, take the next corrid from the DB table again, compare it with all the 500 messages in the queue. This keeps going for all the 500 records in the table.
So the total number of reads will be 500 * 500 = 250,000. This takes lot of time and keeps the queue read busy which could potentially cause some issues..??
Is while loop the only way to browse the messages ? Can I all the 500 messages in the queue at one shot, store it in a dictionary or something and then compare against the table..?
- Neuronring