Package io.camunda.client.impl.worker
Class ExponentialBackoff
java.lang.Object
io.camunda.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
ConstructorsConstructorDescriptionExponentialBackoff(long maxDelay, long minDelay, double backoffFactor, double jitterFactor, Random random) -
Method Summary
Modifier and TypeMethodDescriptionlongsupplyRetryDelay(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: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
-