Questions tagged [retry-logic]

Programming techniques designed to retry operations that failed due to error codes, exceptions, or other language specific means.

377 questions
3
votes
2 answers

How to retry a Polly rate limit when the rate limit has exceeded?

I've got the following policy setup: // Slack api for postMessage is generally 1 per channel per second. // Some workspace specific limits may apply. // We just limit everything to 1 second. var slackApiRateLimitPerChannelPerSecond = 1; var…
sommmen
  • 6,570
  • 2
  • 30
  • 51
3
votes
2 answers

Polly C# retry exponentially for 3 tries then switch to retrying every hour

I am trying to use polly to construct a policy that can retry exponentially for n tries and then switch to retrying every 1 hour. Can this be achieved? I tried policy Wrap but did not get the desired results
3
votes
0 answers

How to write unit test for Spring retry logic?

I have a service class as below, for which I am trying to test retry logic public class RemoteService { private RestTemplate restTemplate; @Inject public RemoteService(RestTemplate restTemplate) { this.restTemplate =…
Nichole
  • 189
  • 2
  • 7
3
votes
1 answer

retry using Polly

Do these 2 retry policies indicate the same? Policy .Handle() .WaitAndRetry( new[] { TimeSpan.FromMinutes(1), TimeSpan.FromMinutes(1), TimeSpan.FromMinutes(1) …
user989988
  • 3,006
  • 7
  • 44
  • 91
3
votes
1 answer

Stop Execution on certain condition on Polly 4.3

We started using the Polly library in our legacy WinForms project which still runs on the .NET 4.0 framework (is a requisite). The problem is that we have to use version 4.3 of the Polly library and it is difficult to find solutions to the problems…
3
votes
1 answer

Polly retry request with different request-body

I have never used Polly before and am not sure if this is a good scenario for Polly. I am calling an endpoint with a list of 1000 DTO in the POST body. Now the endpoint will perform some validations on each DTO and return a HTTP 400 Bad Request if…
ravi kumar
  • 1,548
  • 1
  • 13
  • 47
3
votes
1 answer

Catching the last exception in Polly in .Net Core?

I'm using Polly (Microsoft.Extensions.Http.Polly) with .net core with this configuration (with an invalid URL , for testing) : private static void RegisterServices() { var collection = new ServiceCollection(); var timeoutPolicy =…
Royi Namir
  • 144,742
  • 138
  • 468
  • 792
3
votes
2 answers

Exponential Backoff Algorithm with Full Jitter Java Implementation

I am trying to create a utility class in pure Java that will contain the logic needed for the Exponential Backoff Algorithm implementation with full jitter as there will be multiple clients sending requests. I have another class with a method that…
3
votes
1 answer

Polly log all requests with URL, Headers, Content and Response

I have a project that calls many rest APIs from other projects, and I have some problems to identify not only errors from those APIs but also correct responses but the information is not correct on the other system. I did this part, but it only log…
Luiz Bicalho
  • 813
  • 1
  • 12
  • 30
3
votes
1 answer

Polly retry not always catching HttpRequestException

My .NET Core 3.1 app uses Polly 7.1.0 retry and bulkhead policies for http resilience. The retry policy uses HandleTransientHttpError() to catch possible HttpRequestException. Now http requests fired with MyClient sometimes return an…
3
votes
1 answer

Tyk API Gateway keeps retrying the request every 60 sec

I have a request that sometimes needs more than a minute to execute. My service is behind Tyk API Gateway. What happens is that after the request is being executed by the service for 60 sec, Tyk sends the same request again to the service ignoring…
dvelopp
  • 4,095
  • 3
  • 31
  • 57
3
votes
2 answers

Polly: how to combine TimeoutPolicy and RetryPolicy to request a Func

I'm trying to combine TimeoutPolicy and RetryPolicy for a API call done in a Func, but I don't found a way to achieve this. If I only use the RetryPolicy, it's working fine. I've a GetRequest method that call the HttpClient and return the…
Gold.strike
  • 1,269
  • 13
  • 47
3
votes
1 answer

How to retry optimistic concurreny conflicts with ASP.NET core, EF core?

Let's say I have an Entity which has a concurrency token column configured in EF core. When an exception occours because data the changed in the database, I'd like to retry the whole transaction from a clean context. All of the examples use the…
3
votes
1 answer

"Retry" from tenacity module doesn't work with a generator

I have an issue using the "retry" tool from the tenacity library in python3. The "retry" decorator does not seem to work when I use a generator. I have a code sample to illustrate my situation: from tenacity import retry,…
Bibimrlt
  • 158
  • 1
  • 2
  • 10
3
votes
1 answer

How to implement lossless grpc-streaming calls?

I am using grpc-streaming in java. I have a long-lasting open stream where the client and server communicate simultaneously. When I call onNext to send a message, grpc buffers the message internally and will send it on the wire async'ly. Now, if the…
Nima
  • 854
  • 3
  • 11
  • 18