【问题标题】:Creating a Azure.Storage.Queues client that can handle multiple queues创建可以处理多个队列的 Azure.Storage.Queues 客户端
【发布时间】:2021-03-01 09:18:06
【问题描述】:

我正在将我的代码从 Microsoft.WindowsAzure.Storage.Queue 迁移到 Azure.Storage.Queues。在我的应用程序中,我将我使用的所有队列操作包装在 MyQueueClient 类中。创建队列客户端的旧方法如下:

CloudStorageAccount account = CloudStorageAccount.Parse(ConnectionString);
CloudQueueClient client = account.CreateCloudQueueClient();

因为我有多个队列,所以这种方法对我来说效果很好。在新方法中,看起来我需要将队列名称作为参数之一传递来创建队列客户端——请参阅文档:https://docs.microsoft.com/en-us/azure/storage/queues/storage-dotnet-how-to-use-queues?tabs=dotnet#create-the-queue-service-client

QueueClient queueClient = new QueueClient(connectionString, queueName);

所以,我在这里有点困惑。这是否意味着,我必须为我使用的每个队列创建一个单独的队列客户端?比如说,我有 3 个队列,这是否意味着我必须创建 3 个队列客户端?似乎没有意义。我在这里错过了什么?

【问题讨论】:

    标签: azure azure-storage azure-queues azure-storage-queues


    【解决方案1】:

    您可以使用下面的代码:

            QueueServiceClient queueServiceClient = new QueueServiceClient(connectionString);
    

    那么您可以使用基于queueServiceClient的方法(注意,与旧方法相比,它可能有一些限制)。

    【讨论】:

    • 感谢您也帮我解决这个问题 :-)
    猜你喜欢
    • 2017-04-08
    • 1970-01-01
    • 1970-01-01
    • 2015-10-13
    • 2015-11-30
    • 2013-05-20
    • 2021-04-09
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多