guava-retrying icon indicating copy to clipboard operation
guava-retrying copied to clipboard

Getting attempt number on success

Open parxier opened this issue 10 years ago • 3 comments

Currently there is no way to retrieve last attempt number on success, only on error.

It'd be nice to either be able to have a method on Retryer instance that would give you back attempt number after successful call to call() method or modify call() to return attempt number as well as successful result wrapped in some sort of result object.

parxier avatar May 15 '14 06:05 parxier

@parxier Looking at Retryer#call implementation it looks like a registered RetryListener will be called once for every try. It is given an Attempt instance that holds the attempt count. Did you try using a listener?

JensRantil avatar Aug 24 '15 14:08 JensRantil

An alternative approach would be to add a onSuccess(RetryListener listener) method.

JensRantil avatar Sep 09 '15 09:09 JensRantil

Jens I am currently trying to fetch the retried count :) but still no luck .

  • RetryListener didn't help me because i don't know to fetch how many times retry listener is called. It seems retry listener is just for logging.
  • I couldn't find onSuccess method of Retryer. Maybe it is removed on newer versions.

bhdrgrpnr avatar Mar 15 '21 15:03 bhdrgrpnr