c# - 如何禁用 'EnableLinkRedirect' 属性以便在没有端口 104XX 的情况下从事件中心获取数据?

标签 c# azure azureservicebus azure-eventhub

我正在使用连接字符串来连接 Azure 事件中心。

为了避免使用 TCP 端口 104XX,Microsoft 有 documented转动 EnableAmqpLinkRedirect 属性为 false默认True

EventHubsConnectionStringBuilder根本没有此属性。 ServiceBusConnectionStringBuilder 创建一个 EventHubClient 不接受的连接字符串。

那么...我该如何禁用此标志以避免使用端口 104xx ?

System.ArgumentException
  HResult=0x80070057
  Message=Illegal connection string parameter name 'EnableAmqpLinkRedirect'
Parameter name: connectionString
  Source=Microsoft.Azure.EventHubs
  StackTrace:
   at Microsoft.Azure.EventHubs.EventHubsConnectionStringBuilder.ParseConnectionString(String connectionString)
   at Microsoft.Azure.EventHubs.EventHubsConnectionStringBuilder..ctor(String connectionString)
   at Microsoft.Azure.EventHubs.EventHubClient.CreateFromConnectionString(String connectionString)
   at Nodinite.LogAgent.PickupService.Helpers.AzureEventHubHelper.GetEventHubClient() in C:\Projects\Nodinite\LogAgent.PickupService\Nodinite.LogAgent.PickupService\Helpers\EventHubHelper.cs:line 59

enter image description here

最佳答案

EnableLinkRedirect 功能由 Microsoft.ServiceBus.Messaging 库实现,默认启用。该实现并未引入 Microsoft.Azure.EventHubs 库,这就是您无法找到禁用它的方法的原因。

该功能的工作原理是使用标准 AMQP 端口(5671、5672)建立与事件中心网关的连接,并请求该服务为分区节点提供发现以直接连接,这将使用 104xx 端口范围。

默认情况下,该服务不会尝试重定向,并且 Microsoft.Azure.EventHubs 库在连接时不会选择加入该功能。因此,您应该只能看到标准 AMQP 端口上的事件中心流量。

关于c# - 如何禁用 'EnableLinkRedirect' 属性以便在没有端口 104XX 的情况下从事件中心获取数据?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62322458/

相关文章:

azure - 队列消息自动缩放

c# - 将代码中的 userid 和 guid 提供给 signalr 服务器

c# - 如何确保 winform 被垃圾收集?

c# - http ://to https://redirect 期间的重定向循环

azure - 如何使用 Azure CLI 或 Terraform 创建 DNS A 记录

azure - Azure 中的目录审核日志中缺少 odata.type

C# Service Bus 多个监听器都收到相同的消息 (BrokeredMessage)

c#无法终止进程

c# - .Net 7 隔离进程中的服务总线触发 Azure Function - 处理死信队列

Azure 服务总线 - MaxConcurrentCalls PerSession > 1 不保证 session 的 FIFO 处理队列