Skip to content

REQUESTS - Resiliency

Resiliency is a necessary thing to do discuss when it comes to mobile & network calls. Cell signals can drop, wifi can be spotty, and servers can be down.
The Resilience middleware is designed to help you handle these situations. Shiny Mediator provides easy middleware to the actual workhorse in this equation - Microsoft.Extension.Resilience. This library provides a number of resiliency patterns such as Circuit Breakers, Retry Policies, and more.

For more documentation on the Microsoft.Extension.Resilience library, please see the official documentation


  1. Install the Shiny.Mediator.Resilience package from NuGet

  2. Add the resilience middleware to your mediator setup

    services.AddShinyMediator(cfg =>
    ("test", builder =>
    builder.AddRetry(new RetryStrategyOptions());
  3. With any request handler that provides a result, you can now add the following attribute

    public class MyRequestHandler : IRequestHandler<MyResponse, MyResponse>
    public async Task<MyResponse> Handle(MyResponse request, CancellationToken cancelToken)
    // do your work here
    var result = await SomeNetworkCallThatTakesForever(cancelToken);
    return result;

That’s it! Your request handler is now resilient!