0

I'm new to the Polly for building the retry policy and what I noticed that is, Polly will execute the same method over and over again if it meets specific exception. However, is it possible that Polly could retry with different method recursively? Here is one example of my current work flow:

  • I have a list of items to write into database as a batch operation, but I don't know the total data size of my list.
  • My database writing operation would have a limitation of certain size, say its max size of 2 MB.
  • Suppose my input list contains 5,000 items, then when it exceed my database write operation limitation, throws an exception. What I'd like to do is to divide the 5000 items into half as 2 subsets with each of 2,500 items. Then try to write with those two subset again...
  • If my two subset of 2,500 items still exceed the limitation, I will divide the 2500 into half as 2 subsets with each of 1,250 items, then try same thing again.

So basically my retry-policy will be executed based on recursive way, when meet an exception, split dataset and retry, and going on...However, with Polly I can't find a way to call my execution method recursively...

Drex
  • 3,346
  • 9
  • 33
  • 58
  • Polly is really for "transient-fault-handling". You should implement your own logic for the described non-transient behavior and use Polly to handle transient faults. Also, surely after the first few times wouldn't you want to remember what values of N worked and start from that rather than trying to discover it each time? – Ian Mercer Sep 06 '19 at 04:53

1 Answers1

0

Polly's retry policy is designed for retrying the same delegate call. Recursion is not a use case Polly targets.

mountain traveller
  • 7,591
  • 33
  • 38