Annotation Type RetryOnFailure


  • @Documented
    @Retention(RUNTIME)
    @Target(METHOD)
    public @interface RetryOnFailure
    Retry the method in case of exception.

    For example, this load() method will retry to load the URL content if it fails at the first attempts:

     @RetryOnFailure(attempts = 2)
     String load(URL url) throws IOException {
       return url.getContent().toString();
     }
    Since:
    0.1.10
    See Also:
    http://aspects.jcabi.com/
    • Optional Element Summary

      Optional Elements 
      Modifier and Type Optional Element Description
      int attempts
      How many times to retry.
      long delay
      Delay between attempts, in time units.
      Class<? extends Throwable>[] ignore
      Exception types to ignore.
      boolean randomize
      Shall the time between retries by randomized.
      Class<? extends Throwable>[] types
      When to retry (in case of what exception types).
      TimeUnit unit
      Time unit.
      boolean verbose
      Shall it be fully verbose (show full exception trace) or just exception message?
    • Element Detail

      • attempts

        int attempts
        How many times to retry.
        Returns:
        Number of attempts
        Default:
        3
      • delay

        long delay
        Delay between attempts, in time units.
        Returns:
        Delay
        Default:
        50L
      • unit

        TimeUnit unit
        Time unit.
        Returns:
        Time unit.
        Default:
        java.util.concurrent.TimeUnit.MILLISECONDS
      • types

        Class<? extends Throwable>[] types
        When to retry (in case of what exception types).
        Returns:
        Array of types.
        Default:
        {java.lang.Throwable.class}
      • ignore

        Class<? extends Throwable>[] ignore
        Exception types to ignore.
        Returns:
        Array of types
        Default:
        {}
      • verbose

        boolean verbose
        Shall it be fully verbose (show full exception trace) or just exception message?
        Returns:
        Verbosity flag
        Default:
        true
      • randomize

        boolean randomize
        Shall the time between retries by randomized.
        Returns:
        Random retry time flag
        Default:
        true