1

I'm using azure-sdk-js for reading and sending messages to Azure Service Bus Queues.

I've successfully managed to connect to queues, reading messages, reading DLQ and sending messages. I would like to extend this to show information about how many messages that exist in each queue, how many are being processed and how many DLs there are. I found that QueueDetails hold this information. But I do not understand how to obtains those QueueDetails. QueueDetails is implemented by QueueResponse, so basically I am looking for a method that is GetQueue(queueName), but I can't seem to find it.

Has anyone implemented something like this before and knows what method I need to use?

simonauner
  • 1,021
  • 1
  • 8
  • 10

4 Answers4

3

A few interfaces like QueueDetails got exposed by accident from the @azure/service-bus package in version 1.1.3. The ATOM management client that uses these interfaces is still under works and therefore is not part of the exported public facing API surface. We have a working implementation, but the final design for it is still under discussion and the APIs might change.

Follow https://github.com/Azure/azure-sdk-for-js/issues/7991 and https://github.com/Azure/azure-sdk-for-js/issues/7938 for more on this.

For now, please use the @azure/arm-servicebus package to fetch details on the queue. If you want these features by using a connection string, then azure-sb is the recommended package until @azure/service-bus offers similar capabilities in the near future.

Update as of June 8th, 2020:

Hello all,

We are happy to share that the third preview to v7 (7.0.0-preview.3) of the @azure/service-bus package now supports the CRUD & list operations on queues, topics, subscriptions and rules via a separate "client" that can be instantiated either via a connection string or an AAD credential.

Please checkout the sample for management operations for more details.

Please note that this is still in preview and the next preview might have some changes in the API based on internal and external feedback.

Please give it a try and let us know if you have any feedback by logging issues at https://github.com/Azure/azure-sdk-for-js

Ramya Rao
  • 111
  • 5
2

So @azure/service-bus package essentially provides AMQP based connectivity to Azure Service Bus and has only methods to mainly work with messages. Functionality to manage entities (Queues, Topics, and Subscriptions) has been removed from this package.

You basically have three options:

  1. Use @azure/arm-servicebus package: Azure Service Bus team has moved the functionality to manage entities from data plane to control plane. So you have to use this package to get details about a queue. The method you would want to call is get
  2. Use azure-sb package: This is really an old package which is a wrapper over REST API. You can find more details about this package here: https://github.com/Azure/azure-sdk-for-node/tree/master/lib/services/serviceBus.
  3. Use REST API directly: As mentioned in the other answer, you can use REST API directly to get details about a queue.
Gaurav Mantri
  • 128,066
  • 12
  • 206
  • 241
  • Thanks for providing many options to solve my issues. I think the first option is the best to go with, it seems easiest. However, I am not keen on adding another authentication setup besides connection strings, and I cannot seem to find that in the documentation for [@azure/arm-servicebus](https://azuresdkdocs.blob.core.windows.net/$web/javascript/azure-arm-servicebus/3.2.0/index.html). – simonauner Mar 23 '20 at 07:50
  • Go with the 2nd option. – Gaurav Mantri Mar 23 '20 at 08:10
1

You can use REST Api and the GET operation:

https://learn.microsoft.com/en-us/rest/api/servicebus/queues/get

The information you're looking for is inside Message Count Details:

https://learn.microsoft.com/en-us/rest/api/servicebus/queues/get#messagecountdetails

Thiago Custodio
  • 17,332
  • 6
  • 45
  • 90
1

I check the sdk, there is a serviceBusAtomManagementClient, it has the getQueueDetails method, in the sdk it use the GetQueueResponse extend the QueueDetails , you could refer to here.

And in the github there is a sample about atomManagement, more details refer to atomManagementApi.

George Chen
  • 13,703
  • 2
  • 11
  • 26
  • Thanks, this seems like the easiest approach since I'm already using the SDK. However, the `serviceBusAtomManagementClient` isn't exported, and importing the file directly seems a bit hazardous. Plus, I'm using modules, and the SDK's `dist-esm` files cannot be imported since the nearest `package.json` doesn't define the `modules` prop. – simonauner Mar 23 '20 at 07:43