【问题标题】:How configure EventBusServiceBus with Azure Service Bus?如何使用 Azure 服务总线配置 EventBusServiceBus?
【发布时间】:2019-05-12 18:36:57
【问题描述】:

我需要配置一个库EventBusServiceBus,但是搜索没有找到任何样本。请,我需要示例,如何使用 appSettings.json 配置与EventBusServiceBus 的连接

【问题讨论】:

标签: c# asp.net azureservicebus event-bus


【解决方案1】:

这是一本“.NET 微服务:容器化 .NET 应用程序架构”电子书,又名 eShopOnContainers,代码位于 GitHub

EventBusServiceBus 应该收到IServiceBusPersisterConnection 的实现。这是使用DefaultServiceBusPersisterConnection 实现的,随后依赖于Azure 服务总线ServiceBusConnectionStringBuilder 在服务中创建和注册。一个示例是服务配置之一,例如 Ordering service here

appsettings.json 中,您必须定义以下设置:

  • AzureServiceBusEnabled 设置为 true
  • EventBusConnection 设置为 Azure 服务总线连接字符串

【讨论】:

  • 配置 EventBus 时出现此错误:System.ArgumentException: 'The argument is null or white space.' .以下数据为空:EntityPath, SasToken
  • 如何构造ServiceBusConnectionStringBuilder
  • 初始化DefaultServiveBusPersisterConnection时需要提供SerciveBusConnectionStringBuilder并传入。你看过我指向here的代码吗?
  • 看看我的创业公司,我相信没问题ghostbin.com/paste/vgdkn
  • 代码使用连接字符串生成器实例化TopicClient。连接字符串中的EntityPath 未定义,因此出现异常。此外,更改您的连接字符串的 SasKey,因为它现在已公开... 提示:将来,向相关代码添加链接/永久链接会有所帮助。干杯!
【解决方案2】:

使用 eShopOnContainers 应用程序时,服务总线未在 GIT 存储库中正确实现。

您的连接字符串中缺少 entityPath 参数。您必须首先在 Azure 服务总线中创建一个主题。在 Azure 服务总线中设置你的主题的 entityPath= 名称。在 Azure 服务总线中,还为此主题创建订阅。您需要在 appsettings.json 文件中进行配置。将 appsettings 文件中的 subscriptionClientName 的值设置为刚刚创建的 Subscription 的名称。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-06-06
    • 2017-11-21
    • 1970-01-01
    • 2018-10-30
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多