微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

c# – 如何使用.Net核心应用程序发送到EventHubs时优化吞吐量

如何创建多个使用多个底层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,这在我第一次阅读时并不清楚.但我将此作为答案添加并让问题留在以防其他人阅读文档之类的我先做了)

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐