Class OptimisticLockRetryPolicy
- java.lang.Object
-
- org.apache.camel.processor.aggregate.OptimisticLockRetryPolicy
-
public class OptimisticLockRetryPolicy extends Object
Class to control how failed optimistic locks are tried. This policy supports random and exponential back-off delays. IfrandomBackOff
is enabled and a value is supplied forretryDelay
the value will be ignored. IfrandomBackOff
is enabled and no value is set formaximumRetryDelay
, a default value of 1000ms will be used, the random delay will be between 0 and 1000 milliseconds. If bothrandomBackOff
andexponentialBackOff
are enabled,exponentialBackOff
will take precedence. IfexponentialBackOff
is enabled and a value is set formaximumRetryDelay
, the retry delay will keep doubling in value until it reaches or exceedsmaximumRetryDelay
. After it has reached or exceededmaximumRetryDelay
the value ofmaximumRetryDelay
will be used as the retry delay. If bothexponentialBackOff
andrandomBackOff
are disabled, the value ofretryDelay
will be used as the retry delay and remain constant through all the retry attempts. If the value ofmaximumRetries
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 Summary
Constructors Constructor Description OptimisticLockRetryPolicy()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
doDelay(int retryCounter)
OptimisticLockRetryPolicy
exponentialBackOff()
long
getDelay(int retryCounter)
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()
-
-
-
Method Detail
-
shouldRetry
public boolean shouldRetry(int retryCounter)
-
doDelay
public void doDelay(int retryCounter) throws InterruptedException
- Throws:
InterruptedException
-
getDelay
public long getDelay(int retryCounter)
-
getMaximumRetries
public int getMaximumRetries()
-
setMaximumRetries
public void setMaximumRetries(int maximumRetries)
-
maximumRetries
public OptimisticLockRetryPolicy maximumRetries(int maximumRetries)
-
getRetryDelay
public long getRetryDelay()
-
setRetryDelay
public void setRetryDelay(long retryDelay)
-
retryDelay
public OptimisticLockRetryPolicy retryDelay(long retryDelay)
-
getMaximumRetryDelay
public long getMaximumRetryDelay()
-
setMaximumRetryDelay
public void setMaximumRetryDelay(long maximumRetryDelay)
-
maximumRetryDelay
public OptimisticLockRetryPolicy maximumRetryDelay(long maximumRetryDelay)
-
isExponentialBackOff
public boolean isExponentialBackOff()
-
setExponentialBackOff
public void setExponentialBackOff(boolean exponentialBackOff)
-
exponentialBackOff
public OptimisticLockRetryPolicy exponentialBackOff()
-
isRandomBackOff
public boolean isRandomBackOff()
-
setRandomBackOff
public void setRandomBackOff(boolean randomBackOff)
-
randomBackOff
public OptimisticLockRetryPolicy randomBackOff()
-
-