Class RecoveryDelayHandler.ExponentialBackoffDelayHandler

  • All Implemented Interfaces:
    RecoveryDelayHandler
    Enclosing interface:
    RecoveryDelayHandler

    public static class RecoveryDelayHandler.ExponentialBackoffDelayHandler
    extends java.lang.Object
    implements RecoveryDelayHandler
    Backoff implementation of RecoveryDelayHandler that uses the Fibonacci sequence (by default) to increase the recovery delay time after each failed attempt. You can optionally use your own backoff sequence.
    • Field Detail

      • sequence

        private final java.util.List<java.lang.Long> sequence
    • Constructor Detail

      • ExponentialBackoffDelayHandler

        public ExponentialBackoffDelayHandler()
        Default Constructor. Uses the following sequence: 2000, 3000, 5000, 8000, 13000, 21000, 34000
      • ExponentialBackoffDelayHandler

        public ExponentialBackoffDelayHandler​(java.util.List<java.lang.Long> sequence)
        Constructor for passing your own backoff sequence
        Parameters:
        sequence - List of recovery delay values in milliseconds.
        Throws:
        java.lang.IllegalArgumentException - if the sequence is null or empty
    • Method Detail

      • getDelay

        public long getDelay​(int recoveryAttempts)
        Description copied from interface: RecoveryDelayHandler
        Get the time to sleep (in milliseconds) before attempting to reconnect and recover again. This method will be called with recoveryAttempts=0 before the first recovery attempt and then again after each failed recovery.
        Specified by:
        getDelay in interface RecoveryDelayHandler
        Parameters:
        recoveryAttempts - The number of recovery attempts so far.
        Returns:
        the delay in milliseconds