public class OptimisticLockRetryPolicy extends Object
randomBackOff
is enabled and a value is supplied for retryDelay
the value will be ignored.
If randomBackOff
is enabled and no value is set for maximumRetryDelay
, a default value of 1000ms will
be used, the random delay will be between 0 and 1000 milliseconds.
If both randomBackOff
and exponentialBackOff
are enabled, exponentialBackOff
will take precedence.
If exponentialBackOff
is enabled and a value is set for maximumRetryDelay
, the retry delay will keep
doubling in value until it reaches or exceeds maximumRetryDelay
. After it has reached or exceeded maximumRetryDelay
the value of maximumRetryDelay
will be used as the retry delay.
If both exponentialBackOff
and randomBackOff
are disabled, the value of retryDelay
will be used
as the retry delay and remain constant through all the retry attempts.
If the value of maximumRetries
is set above zero, retry attempts will stop at the value specified.
The default behaviour of this policy is to retry forever and exponentially increase the back-off delay starting with 50ms.Constructor and Description |
---|
OptimisticLockRetryPolicy() |
Modifier and Type | Method and Description |
---|---|
void |
doDelay(int retryCounter) |
OptimisticLockRetryPolicy |
exponentialBackOff() |
int |
getMaximumRetries() |
long |
getMaximumRetryDelay() |
long |
getRetryDelay() |
boolean |
isExponentialBackOff() |
boolean |
isRandomBackOff() |
OptimisticLockRetryPolicy |
maximumRetries(int maximumRetries) |
OptimisticLockRetryPolicy |
maximumRetryDelay(long maximumRetryDelay) |
OptimisticLockRetryPolicy |
randomBackOff() |
OptimisticLockRetryPolicy |
retryDelay(long retryDelay) |
void |
setExponentialBackOff(boolean exponentialBackOff) |
void |
setMaximumRetries(int maximumRetries) |
void |
setMaximumRetryDelay(long maximumRetryDelay) |
void |
setRandomBackOff(boolean randomBackOff) |
void |
setRetryDelay(long retryDelay) |
boolean |
shouldRetry(int retryCounter) |
String |
toString() |
public OptimisticLockRetryPolicy()
public boolean shouldRetry(int retryCounter)
public void doDelay(int retryCounter) throws InterruptedException
InterruptedException
public int getMaximumRetries()
public void setMaximumRetries(int maximumRetries)
public OptimisticLockRetryPolicy maximumRetries(int maximumRetries)
public long getRetryDelay()
public void setRetryDelay(long retryDelay)
public OptimisticLockRetryPolicy retryDelay(long retryDelay)
public long getMaximumRetryDelay()
public void setMaximumRetryDelay(long maximumRetryDelay)
public OptimisticLockRetryPolicy maximumRetryDelay(long maximumRetryDelay)
public boolean isExponentialBackOff()
public void setExponentialBackOff(boolean exponentialBackOff)
public OptimisticLockRetryPolicy exponentialBackOff()
public boolean isRandomBackOff()
public void setRandomBackOff(boolean randomBackOff)
public OptimisticLockRetryPolicy randomBackOff()
Apache Camel