guava-retrying
guava-retrying copied to clipboard
Getting attempt number on success
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 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?
An alternative approach would be to add a onSuccess(RetryListener listener)
method.
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.