Class ExponentialBackoff
- java.lang.Object
-
- io.camunda.zeebe.client.impl.worker.ExponentialBackoff
-
- All Implemented Interfaces:
BackoffSupplier
public final class ExponentialBackoff extends Object implements BackoffSupplier
An implementation ofBackoffSupplierwhich uses a simple formula, multiplying the previous delay with an increasing multiplier and adding some jitter to avoid multiple clients polling at the same time even with back off.The next delay is calculated as:
max(min(maxDelay, currentDelay * backoffFactor), minDelay) + (rand(0.0, 1.0) * (currentDelay * jitterFactor) + (currentDelay * -jitterFactor))
-
-
Constructor Summary
Constructors Constructor Description ExponentialBackoff(long maxDelay, long minDelay, double backoffFactor, double jitterFactor, Random random)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description longsupplyRetryDelay(long currentRetryDelay)Returns the delay before the next retry.
-
-
-
Constructor Detail
-
ExponentialBackoff
public ExponentialBackoff(long maxDelay, long minDelay, double backoffFactor, double jitterFactor, Random random)
-
-
Method Detail
-
supplyRetryDelay
public long supplyRetryDelay(long currentRetryDelay)
Description copied from interface:BackoffSupplierReturns the delay before the next retry. The delay should be specified in milliseconds.- Specified by:
supplyRetryDelayin interfaceBackoffSupplier- Parameters:
currentRetryDelay- the last used retry delay- Returns:
- the new retry delay
-
-