Resilient HttpClient using Polly and IHttpClientFactory in .NET Core 3

Поділитися
Вставка
  • Опубліковано 6 жов 2024
  • Become a Patreon and get source code access: / nickchapsas
    Check out my courses: dometrain.com
    The giveaway is now over. Thanks for participating.
    Hello everybody I'm Nick and in this .NET tutorial I will show you how you can create a high performing, efficient and resilient HttpClient using .NET Core's IHttpClientFactory and it's support for Polly.
    A new HttpClient instance is returned each time CreateClient is called on the IHttpClientFactory. An HttpMessageHandler is created per named client. The factory manages the lifetimes of the HttpMessageHandler instances.
    IHttpClientFactory pools the HttpMessageHandler instances created by the factory to reduce resource consumption. An HttpMessageHandler instance may be reused from the pool when creating a new HttpClient instance if its lifetime hasn't expired.
    Pooling of handlers is desirable as each handler typically manages its own underlying HTTP connections. Creating more handlers than necessary can result in connection delays. Some handlers also keep connections open indefinitely, which can prevent the handler from reacting to DNS (Domain Name System) changes.
    Don't forget to comment, like and subscribe :)
    Social Media:
    Follow me on GitHub: bit.ly/ChapsasG...
    Follow me on Twitter: bit.ly/ChapsasT...
    Connect on LinkedIn: bit.ly/ChapsasL...
    #dotnet #polly #httpclient

КОМЕНТАРІ • 36