Class KiwiRetryer<T>


  • public class KiwiRetryer<T>
    extends Object
    This is a wrapper class for Retryer; it wraps methods so that the RetryException and ExecutionException that are generated from the Retryer.call(Callable) method are converted to KiwiRetryerException.

    It also provides some kiwi-flavored default values, an identifier that can be used to distinguish between retryer instances in logs, logging of retry attempts, and some factories for creating retryer instances with common behavior.

    You can construct a KiwiRetryer using the builder obtained via KiwiRetryer.builder().

    Available configuration options for KiwiRetryer:
    Name Default Description
    retryerId UUID generated by UUIDs.randomUUIDString() The identifier for the retryer
    initialSleepTimeAmount 100 The initial sleep amount for the default incrementing wait strategy. This value will be ignored if an explicit WaitStrategy is defined.
    initialSleepTimeUnit TimeUnit.MILLISECONDS The initial sleep TimeUnit for the default incrementing wait strategy. This value will be ignored if an explicit WaitStrategy is defined.
    retryIncrementTimeAmount 200 The subsequent retry increment amount for the default incrementing wait strategy. This value will be ignored if an explicit WaitStrategy is defined.
    retryIncrementTimeUnit TimeUnit.MILLISECONDS The subsequent retry increment TimeUnit for the default incrementing wait strategy. This value will be ignored if an explicit WaitStrategy is defined.
    maxAttempts 5 The maximum number of attempts to use for the default stop strategy. This value will be ignored if an explicit StopStrategy is defined.
    processingLogLevel Level.DEBUG This log level controls the "happy path" messages that are logged by this retryer.
    exceptionLogLevel Level.WARN This log level controls the "sad path" messages (i.e. exceptions) that are logged by this retryer.
    retryOnAllExceptions false Tells the retryer to retry on any exception. NOTE: This supersedes any exceptions added to the exceptionPredicates list or if retryOnAllRuntimeExceptions is set to true
    retryOnAllRuntimeExceptions false Tells the retryer to retry on all RuntimeExceptions. NOTE: This supersedes any exceptions added to the exceptionPredicates list.
    exceptionPredicates empty list Defines the Throwables that should cause KiwiRetryer to retry its specified Callable if encountered during processing. Note these are Guava Predicate objects not JDK Predicate objects; the reason is that the underlying guava-retrying library uses Guava's predicate class.
    resultPredicates empty list Defines the T objects that should cause KiwiRetryer to retry its specified Callable if returned by the Callable during processing. Note these are Guava Predicate objects not JDK Predicate objects; the reason is that the underlying guava-retrying library uses Guava's predicate class.
    stopStrategy null An explicit stopStrategy which will override the default stop after attempts stop strategy.
    waitStrategy null An explicit waitStrategy which will override the default incrementing wait strategy.

    NOTE: The guava-retrying library must be available at runtime.