Non blocking response for azure service bus queue

András Ratz 0 Reputation points
2023-10-11T14:31:02.25+00:00

Hello,

I have an Azure Service Bus with 3 different queue with different "priority" (high, medium, low). This "priority" is only represented in the naming, our workers take care of this by checking always for a new message first in the "high" queue, then "medium" and then "low".

We use the REST API for the service bus:

XX://XXX.servicebus.windows.net/{high|medium|low}/messages/head

Our problem is, if a worker checks only a single queue, then it processes the data very fast, as we would expect, but if any of the queue is empty from the 3, there is like a 5 sec "wait/blocking" Whenever we call the "messages/head" endpoint, it looks like, that the call is waiting a bit for a message to arrive into the queue

Is there a way to disable this "blocking" and if the queue is empty, then the response is immediately sent, like if there is a message inside of it?

Azure Service Bus
Azure Service Bus
An Azure service that provides cloud messaging as a service and hybrid integration.
635 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Pramod Valavala 20,636 Reputation points Microsoft Employee
    2023-10-18T15:11:27.56+00:00

    @András Ratz The REST API doesn't have the ability to browse messages but you can do this using the SDK for language. This would not lock messages and lets you to just view the messages.

    But if you can't use the SDK, then I suppose the option is to try setting the timeout query parameter as shown in the example in the REST API Reference, which I can confirm works though undocumented explicitly.

    Another option you could explore is to use the ARM REST API, Queues - Get (or Subscriptions - Get), which also returns message count details.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.