Reputation: 67
I am using this code :
var ServiceBusClient = require('azure-service-bus-client');
var serviceBusClient = new ServiceBusClient(
{
serviceBusConnection: ""
}
);
(function(){
serviceBusClient.receiveSubscriptionMessage(topicName, subscriptionName,
function (err, message) {
console.log("message body :", message);
});
})();
I am searching for a particular message body, for which I am thinking to iterate the above method - receiveSubscriptionMessage() but for this I need the count of total messages in a subscription client.
I am looking for node.js code, many places on internet they have given in JAVA or c# but for count I cannot find MessageCount. Any help will be fine.
Link to the libraray I am using is : https://www.npmjs.com/package/azure-service-bus-client
Upvotes: 1
Views: 620
Reputation: 141
I know this is a late reply, but the library mentioned in the post is not maintained by Microsoft or Azure.
The latest version 7.0.0 of @azure/service-bus
offers ServiceBusAdministrationClient
that lets you manage the service-bus resources.
For the problem in this question, you can leverage the getSubscriptionRuntimeProperties
method to get the count of messages in the subscription.
Here is an example on using ServiceBusAdministrationClient
- administrationClient.ts
In case someone is running into issues with the older service-bus SDK for node and landed here, refer to the links below.
Upvotes: 1
Reputation: 67
The total count is not possible to fetch, until and unless we have the command over the sender.
So, the other workaround that I was able to figure out was only after receiving and checking every message for the specific pattern/condition required.
Upvotes: 0