如何检查服务总线主题是否为空c#

时间:2018-01-14 08:52:52

标签: c# azure servicebus azure-servicebus-topics

我想知道有没有办法检查service bus topic empty or not

我尝试使用nuget WindowsAzure.ServiceBus以及示例代码。

在这个nuget中,我没有得到ITopicClient :(

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

任何方式这样做?

1 个答案:

答案 0 :(得分:1)

使用WindowsAzure.ServiceBus包,您可以使用MessagingFactory.Create创建Service Bus客户端实例,以获取对MessagingFactory的引用。获得其中一个后,您可以致电CreateTopicClient以获取TopicClient个实例。

(请注意,还有一个名为Microsoft.Azure.ServiceBus的新软件包,其功能有限,但它支持.NET Core。如果使用该软件包,则类层次结构有所不同,您可以直接创建客户端实例。)