什么是最新 SDK 中 Microsoft.Azure.ServiceBus 的 ITopicClient 的等效项,即 Azure.Messaging.ServiceBus

What is the equivalent of ITopicClient of Microsoft.Azure.ServiceBus in the latest SDK i.e. Azure.Messaging.ServiceBus

我们的应用程序使用的是较旧的服务总线 SDK,即 Microsoft.Azure.ServiceBus。现在我们要移动到最新的 SDK 即 Azure.Messaging.ServiceBus.

但我无法在最新的 SDK 中找到等同于 ITopicClient 的 Microsoft.Azure.ServiceBus,即 Azure.Messaging.ServiceBus

基本上我想将这行代码从旧的 SDK 替换为最新的 SDK。

 private async Task<bool> PublishMessageAsync( IList<IOurApplicationTopicClient> topicClients, 
                                          string topicName)
    {
       // some code 

       ITopicClient primaryTopicClient = topicClients.First(x => 
       x.ServiceBusType.Equals(ServiceBusType.Primary)
       && x.TopicName.Trim().Equals(topicName));

      //some code 
}

IOurApplicationTopicClient接口如下

public interface IOurApplicationTopicClient: ITopicClient
{
    ServiceBusType ServiceBusType { get; set; }
    ServiceBusConnectionStringBuilder ServiceBusConnectionStringBuilder { get; set; }
}

另外我不确定是否有任何关于 smooter 迁移的适当文档。

ServiceBusSender type is the equivalent; it has the ability to send to either a queue or topic, depending on the queueOrTopicName passed when creating it. The sender is created via the ServiceBusClient, using its CreateSender 方法。

相同的概念适用于接收消息,其中 ServiceBusReceiver has responsibility for reading from both queues and subscriptions, depending on how it is created. The receiver is also created via the ServiceBusClient, using its CreateReceiver 方法。

您可能会发现 Migration Guide 有助于从 Microsoft.Azure.ServiceBus 移动到 Azure.Messaging.ServiceBus