Programming techniques designed to retry operations that failed due to error codes, exceptions, or other language specific means.
Questions tagged [retry-logic]
377 questions
1
vote
2 answers
Polly policy handle Refit ApiException with DI AddPolicyHandler
I set up the following service collection with a Refit client and a Polly policy for dependency injection in my UWP app:
var serviceCollection = new ServiceCollection();
serviceCollection
.AddRefitClient(typeof(IClassevivaAPI))
…

Gabboxl
- 91
- 3
- 16
1
vote
5 answers
How to implement a generic retry pattern for methods with parameters
So far I implemented this:
public class Retrier
{
///
/// Execute a method with no parameters multiple times with an interval
///
///
///

SeReGa
- 1,219
- 2
- 11
- 32
1
vote
1 answer
How to stop Kafka retry for specific error
I'm working on a nodeJS/nestJS project and have setup a kafka consumer for topics. I've also added a payload validator that throws an error when the payload in the topic does not meet the required standards.
Issue now is that the consumer keeps…

Zephyr
- 1,612
- 2
- 13
- 37
1
vote
2 answers
How to throw a custom exception in polly rate limit exceeds the rate?
I have an API that has certain limits defined. Since I have used Polly C# library to limit the calls made to API. Below is the policy I am using.
var _rateLimitPolicy = Policy.RateLimitAsync(10,TimeSpan.FromSeconds(1), 5);
var _retryPolicy =…

Kavin404
- 959
- 2
- 11
- 18
1
vote
2 answers
what is the difference between Circuit Breaker and Retry in spring boot microservice?
One of my colleagues asked me this question what the difference between Circuit Breaker and Retry is but I was not able answer him correctly. All I know circuit breaker is useful if there is heavy request payload, but this can be achieve using…

Satyaprakash Nayak
- 454
- 5
- 22
1
vote
1 answer
Polly - 'Cannot access a closed Stream'
I am upgrading a Xamarin app to MAUI and thought of decoupling things a bit. Before i had a datastore which handled all requests to an API, now i have a service for each section of the app from which requests go to a HttpManager, problem is when the…

Adrian Radulescu
- 25
- 3
1
vote
1 answer
C# Polly WaitandRetry or delay and then retry
I have created a policy which will wait and retry for:
My step is depending on output of a SELECT query. Sometimes database takes a long time around 35-45 seconds to generate the value in a table. So, I have to wait till that time to check if value…

born2Learn
- 1,253
- 5
- 14
- 25
1
vote
1 answer
Retry Pattern via polly
Please let me know is there any chance in the below code the "response" turns to be null, that results an error if I try to get response.result and response.statuscode value in onRetry block.
Sample code below
AsyncRetryPolicy…

user18024637
- 15
- 5
1
vote
1 answer
Polly re-try policy not working in conjunction with circuit breaker with Ocelot
I wanted to use Polly re-try and circuit breaker with Ocelot api gateway. I am trying to wrap policies with DelegatingHandler, the circuit breaker works, but re-try not works.
Below code just throw the exception, but NO re-try happening. When I am…

user584018
- 10,186
- 15
- 74
- 160
1
vote
1 answer
Polly - How to achieve a circuit breaker that opens the circuit on WaitAndRetry failure and puts back retry logic on each 30 minutes if it fails
I was used to WaitAndRetryForeverAsync in the past which was wrong because I believe the Retry pattern is supposed to handle only transient faults, such as rate limiting, 429 status code, etc. At the moment that the API I was subscribing to went…

nop
- 4,711
- 6
- 32
- 93
1
vote
1 answer
Polly Retry - Accept optional custom exception handler
How do I make the following Polly Retry policy let the user specify a custom handler such as the one below:
.Handle(exception => IsWebSocketErrorRetryEligible(exception))
Snippet
public static async Task DoAsync(Func…

nop
- 4,711
- 6
- 32
- 93
1
vote
2 answers
Retry the call if server is down in JAVA
I am trying to implement the retry logic or mechanism on micro-services to micro-services call. Basically, have to attempt retry 2 times if server is down only.
I tried to use @Retryable and @Recover to perform same but no luck. Instead I can…

Vrinda Garg
- 11
- 2
1
vote
1 answer
Accessing retry attempt number in spring cloud stream kafka transaction
I need to access the retry attempt number in spring cloud stream kafka transactional retry so that for a particular exception, based on the retry attempt number i can post the outcome to different topic

DreamCoder
- 23
- 5
1
vote
1 answer
Should non-idempotent operations be called with a retry policy?
This is probably a silly question but can I call a non-idempotent with a retry policy?
The action is a SQL Write operation.
My understanding is that I am able to do it because the stored procedures I have are transactional so if they fail, the…

ProgrammingNewbie199
- 91
- 1
- 10
1
vote
2 answers
retry insert 3 times only when error code 403002 occurs
I came to know through Polly I can re-try the execution up to multiple configurable time like below example,
Policy
.Handle(ex => ex.Number == 1205)
.Or(ex => ex.ParamName == "example")
.WaitAndRetry(3, _ =>…

user584018
- 10,186
- 15
- 74
- 160