Building Resilient Service-to-Service Communications in ASP.NET Core with Polly, the .NET Resilience Framework
Service-to-service communication is becoming more and more common, but we know the network has never been reliable and that other people's code has bugs. Packets are lost, exceptions are thrown, and requests fail; it will happen to your application—to all applications!
Using the Polly Resilience Framework you can easily retry a failed request, no messy for loops or try catches needed. Just a few lines of code and your applications will never be the same!
This post shows how to make reliable requests to an unreliable "remote" service with almost no overhead.
You’ll start with a “remote” Web API application that returns errors 75% of the time. Then you’ll build a “local“ Web API application that calls the remote one (of course receiving errors three quarters of the time).
Finally, you will add Polly to the “local” application to perform retires on failed requests. With a few ...