jueves, 3 de marzo de 2022

ASP.NET MVC HTTP resiliencia con Polly (.NET Framework)

Partimos de

https://docs.microsoft.com/en-us/dotnet/architecture/microservices/implement-resilient-applications/implement-http-call-retries-exponential-backoff-polly

The Polly Project - https://github.com/App-vNext/Polly

Using Polly (! the parrot) in .NET

POLLY, UNA LIBRERÍA DE PATRONES DE RESILIENCIA PARA .NET

Create a simple Retry Policy by using Polly in any fault.


Para poder implementar Polly, sería necesario utilizar IHttpClientFactory.

En .NET Framework se implementa de la siguiente manera:

https://hamidmosalla.com/2020/05/22/using-ihttpclientfactory-with-asp-net-mvc5/

Luego, se aplica el Polly siguiendo estos pasos:

https://www.c-sharpcorner.com/article/using-retry-pattern-in-asp-net-core-via-polly/


Sin embargo, lo anterior aplica muy bien para .Net Core pero se complica la implementación en .Net Framework 4.0. Nuestra solución "de compromiso" final fue la siguiente:

Using Polly (! the parrot) in .NET

Polly Call async

https://stackoverflow.com/questions/30437715/right-method-to-use-polly-c-sharp-library-to-handle-exception

https://www.asptricks.net/2019/06/create-simple-retry-policy-by-using.html

HttpClient estático

https://www.aspnetmonsters.com/2016/08/2016-08-27-httpclientwrong/

No hay comentarios:

Publicar un comentario