Class OptimisticLockRetryPolicy


  • public class OptimisticLockRetryPolicy
    extends Object
    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 Detail

      • OptimisticLockRetryPolicy

        public OptimisticLockRetryPolicy()
    • Method Detail

      • shouldRetry

        public boolean shouldRetry​(int retryCounter)
      • getDelay

        public long getDelay​(int retryCounter)
      • getMaximumRetries

        public int getMaximumRetries()
      • setMaximumRetries

        public void setMaximumRetries​(int maximumRetries)
      • getRetryDelay

        public long getRetryDelay()
      • setRetryDelay

        public void setRetryDelay​(long retryDelay)
      • getMaximumRetryDelay

        public long getMaximumRetryDelay()
      • setMaximumRetryDelay

        public void setMaximumRetryDelay​(long maximumRetryDelay)
      • isExponentialBackOff

        public boolean isExponentialBackOff()
      • setExponentialBackOff

        public void setExponentialBackOff​(boolean exponentialBackOff)
      • isRandomBackOff

        public boolean isRandomBackOff()
      • setRandomBackOff

        public void setRandomBackOff​(boolean randomBackOff)