How can I create multiple EventHubClients that use multiple underlying TCP connects to allow fast writes to the EventHubs from a .net core web app?
In the programming guide for EventHubs (https://learn.microsoft.com/en-us/azure/event-hubs/event-hubs-programming-guide) it is written:
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.
And then they have a code sample:
var factory = MessagingFactory.CreateFromConnectionString("your_connection_string");
var client = factory.CreateEventHubClient("MyEventHub");
However, I dont know where / if there is a MessagingFactory in .Net core? Is it at all possible to do this from .Net core? I looked at Microsoft.Azure.ServiceBus but could not find any.
After testing it seems like creating multiple clients with EventHubClient.CreateFromConnectionString
will open multiple connections to EventHubs just as expected. (The connections can be seen as separate TCP connections in Windows Resource Monitor).
(When I reread the documentation carefully I think its only applies to EventHubClients created from a MessaginFactory, which was not clear the first time I read it. But I add this as an answer and let the question stay in case someone else reads the documentation like I did at first)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With