0

I wonder is there any way to check service bus topic empty or not

I tried with nuget WindowsAzure.ServiceBus and below sample code.

In this nuget I do not get ITopicClient :(

 var topicClient =  TopicClient(); // we can not create object
            var topicPeek = topicClient.Peek();
            TopicDescription topicDescription = new TopicDescription(topicName);
            var topicSize = topicDescription.SizeInBytes;

any way to do so?

Neo
  • 15,491
  • 59
  • 215
  • 405
  • Why do you need that info? Remember that checking message counts via NamespaceManager is both slow and not necessarily accurate. – Sean Feldman Jan 15 '18 at 00:16

1 Answers1

1

With the WindowsAzure.ServiceBus package, you can create instances of Service Bus clients by using MessagingFactory.Create to get a reference to a MessagingFactory. Once you have one of those, you can call CreateTopicClient to get a TopicClient instance.

(Note that there's also a newer package called Microsoft.Azure.ServiceBus that's a bit limited in functionality, but it supports .NET Core. If you use that package, the class hierarchy is somewhat different, and you can create instances of the clients directly.)

Rytmis
  • 31,467
  • 8
  • 60
  • 69