如何创建多个使用多个底层TCP连接的EventHubClient,以允许从.net核心Web应用程序快速写入EventHub?
在EventHubs(https://docs.microsoft.com/en-us/azure/event-hubs/event-hubs-programming-guide)的编程指南中写道:
It is important to note that additional EventHubClient objects created from a messaging factory instance reuse the same underlying TCP connection. Therefore,these objects have a client-side limit on throughput. The Create method reuses a single messaging factory. If you need very high throughput from a single sender,then you can create multiple message factories and one EventHubClient object from each messaging factory.
var factory = MessagingFactory.CreateFromConnectionString("your_connection_string"); var client = factory.CreateEventHubClient("MyEventHub");
但是,我不知道.Net核心中是否存在MessagingFactory?从.Net核心可以做到这一点吗?我查看了Microsoft.Azure.ServiceBus但找不到任何内容.
解决方法
在测试之后,似乎使用EventHubClient创建多个客户端.CreateFromConnectionString将按预期打开与EventHubs的多个连接. (可以将连接视为Windows资源监视器中的单独TCP连接).
(当我仔细阅读文档时,我认为它仅适用于从MessaginFactory创建的EventHubClients,这在我第一次阅读时并不清楚.但我将此作为答案添加并让问题留在以防其他人阅读文档之类的我先做了)