Skip to main content

Former CTO, consultant, author, editor, and industry/web standards expert that still enjoys writing code.
Opinions are mine alone.

twitter.com/jevdemon

github.com/jevdemon

blogs.msdn.microsoft.com/jevdemon/

John Evdemon

Using Polly Context

1 min read

Polly is a .NET resilience and transient-fault-handling library that allows developers to express policies such as Retry, Circuit Breaker, Timeout, Bulkhead Isolation, and Fallback in a fluent and thread-safe manner.  The biggest challenge I've found with Polly is getting visibilty into the number of times you had to retry.  Luckily Polly allows us to pass in a Context (Dictionary) that we can populate with retry info. We can access the Context after our retry policy has completed to determine how many times we retried.

I've created a simple console app illustrating how you can use Polly Context to determine how many times your retry polcy was executed.

You can set up a Fiddler autoresponder rule to simulate transient service errors as follows:

 

 

John Evdemon

A quick demo of CallContext across child threads and app domains

1 min read

Here is a simple console app showing how CallContext can flow across both child threads and app domains.