How to add timeouts for each retry attempt? Will current code support that? #2448
-
Hi team, Apologies if this has been asked already but I was unable to find the answer. I am using Polly library to implement a retrial mechanism for a REST API call with timeouts using below code. I would like to know the whether the timeout I have added in the ResiliencePipeline using AddTimeout() is applicable at each retrial level or is it applicable for last retrial only?
For example: Case 1 OR Case 2 OR There is something else? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 7 replies
-
The registration order of the strategies does matter. In other words you will have very different resilience behaviour if you register your retry and timeout strategies like this var pipeline = new ResiliencePipelineBuilder()
.AddRetry(....)
.AddTimeout(...)
.Build(); or like that var pipeline = new ResiliencePipelineBuilder()
.AddTimeout(...)
.AddRetry(....)
.Build(); Here we have documented these scenarios: https://www.pollydocs.org/pipelines/index.html#diagrams I hope the documentation clarifies how you should register them. If not, please let me know. |
Beta Was this translation helpful? Give feedback.
No. Since you have called the
AddTimeout
after theAddRetry
that's why the timeout strategy is applied per retry attempt. So, in this particular case each retry attempt has a five minutes window to complete.In worst case scenario this means the following: