Class RecoveryDelayHandler.ExponentialBackoffDelayHandler

java.lang.Object
com.rabbitmq.client.RecoveryDelayHandler.ExponentialBackoffDelayHandler
All Implemented Interfaces:
RecoveryDelayHandler
Enclosing interface:
RecoveryDelayHandler

public static class RecoveryDelayHandler.ExponentialBackoffDelayHandler extends 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.
  • Constructor Details

    • ExponentialBackoffDelayHandler

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

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

    • 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