I have a Service Bus Queue with two messages in it:
- One enqueued 10 minutes ago with a ScheduledEnqueueTimeUtc set to 30 minutes in the future
- One enqueued 5 minutes ago (for immediate processing)
When I call QueueClient.PeekAsync, I'm getting the first message (the first enqueued message) instead of the second (the next message that will be processed).
Is this the expected behavior of Peek? If so, is there any way to inspect (without removing from the queue) the next message that will be processed?
My scenario is that I'm trying to calculate our queue latency and the queue contains a mix of scheduled/non-scheduled messages. Currently, I'm working around the behavior noted above by calling PeekBatchAsync to retrieve several messages and then I'm sorting them by when I expect the messages to "become visible" (i.e. eligible for processing).
I'm looking for a fully supported solution (or any mistakes in my observations/analysis/logic above).
Thanks!