【问题标题】:Find list of Subscriptions from azure Topic从 azure 主题中查找订阅列表
【发布时间】:2014-06-30 07:32:39
【问题描述】:

是否可以在服务总线主题上找到订阅列表?

我希望能够找到列表然后循环遍历它。

【问题讨论】:

    标签: azure servicebus


    【解决方案1】:

    如果您使用的是 C#,则可以执行以下操作:

    private void EnumerateTopics()
    {
        var namespaceManager = NamespaceManager.CreateFromConnectionString(c_ConnectionString);
        const string topicName = "testtopic";
    
        var subscriptions = namespaceManager.GetSubscriptions(topicName);
    
        // do stuff with subscriptions
    }
    

    这显然都是同步的,但是调用有相应的异步版本(例如GetSubscriptionsAsync)。订阅对象是一个IEnumerable<SubscriptionDescription>,它可以让您了解您可能想要使用的订阅的任何其他方面。

    首先你需要:

    1. 将相应的“Windows Azure 服务总线”NuGet 包添加到您的解决方案中
    2. 将“Microsoft.ServiceBus”的引用添加到相应的 csproj
    3. 显然放弃了 using 语句 using Microsoft.ServiceBus; 在您的 .cs 文件中

    您的连接字符串将与您从 Azure 管理门户中提取的内容完全相同,大致如下: Endpoint=sb://[namespacename].servicebus.windows.net/;SharedSecretIssuer=owner;SharedSecretValue=[key]

    其他语言也有类似的易于使用的库。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2018-11-18
      • 2019-02-12
      • 1970-01-01
      • 1970-01-01
      • 2019-06-02
      • 2020-10-08
      • 1970-01-01
      相关资源
      最近更新 更多