Class ExponentialBackoff
java.lang.Object
io.camunda.zeebe.client.impl.worker.ExponentialBackoff
- All Implemented Interfaces:
BackoffSupplier
An implementation of
BackoffSupplier
which 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
ConstructorDescriptionExponentialBackoff
(long maxDelay, long minDelay, double backoffFactor, double jitterFactor, Random random) -
Method Summary
Modifier and TypeMethodDescriptionlong
supplyRetryDelay
(long currentRetryDelay) Returns the delay before the next retry.
-
Constructor Details
-
ExponentialBackoff
public ExponentialBackoff(long maxDelay, long minDelay, double backoffFactor, double jitterFactor, Random random)
-
-
Method Details
-
supplyRetryDelay
public long supplyRetryDelay(long currentRetryDelay) Description copied from interface:BackoffSupplier
Returns the delay before the next retry. The delay should be specified in milliseconds.- Specified by:
supplyRetryDelay
in interfaceBackoffSupplier
- Parameters:
currentRetryDelay
- the last used retry delay- Returns:
- the new retry delay
-