how to check service bus topic empty or not c#

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?

1 answer

  • answered 2018-01-14 09:14 Rytmis

    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.)