Class OptimisticLockRetryPolicy
java.lang.Object
org.apache.camel.processor.aggregate.OptimisticLockRetryPolicy
Class to control how failed optimistic locks are tried. This policy supports random and exponential back-off delays.
If
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 Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
doDelay
(int retryCounter) long
getDelay
(int retryCounter) int
long
long
boolean
boolean
maximumRetries
(int maximumRetries) maximumRetryDelay
(long maximumRetryDelay) 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) toString()
-
Constructor Details
-
OptimisticLockRetryPolicy
public OptimisticLockRetryPolicy()
-
-
Method Details
-
shouldRetry
public boolean shouldRetry(int retryCounter) -
doDelay
- Throws:
InterruptedException
-
getDelay
public long getDelay(int retryCounter) -
getMaximumRetries
public int getMaximumRetries() -
setMaximumRetries
public void setMaximumRetries(int maximumRetries) -
maximumRetries
-
getRetryDelay
public long getRetryDelay() -
setRetryDelay
public void setRetryDelay(long retryDelay) -
retryDelay
-
getMaximumRetryDelay
public long getMaximumRetryDelay() -
setMaximumRetryDelay
public void setMaximumRetryDelay(long maximumRetryDelay) -
maximumRetryDelay
-
isExponentialBackOff
public boolean isExponentialBackOff() -
setExponentialBackOff
public void setExponentialBackOff(boolean exponentialBackOff) -
exponentialBackOff
-
isRandomBackOff
public boolean isRandomBackOff() -
setRandomBackOff
public void setRandomBackOff(boolean randomBackOff) -
randomBackOff
-
toString
-