Class OptimisticLockRetryInterceptor

  • All Implemented Interfaces:
    org.drools.core.runtime.ChainableRunner, org.drools.core.runtime.InternalLocalRunner, org.kie.api.runtime.CommandExecutor, org.kie.api.runtime.ExecutableRunner<org.kie.api.runtime.RequestContext>

    public class OptimisticLockRetryInterceptor
    extends org.drools.core.command.impl.AbstractInterceptor
    ExecutableInterceptor that is capable of retrying command execution. It is intended to retry only if right exception has been thrown. By default it will look for org.hibernate.StaleObjectStateException and only then attempt to retry. Since this is Hibernate specific class another can be given as system property to override default. Name of the system property org.kie.optlock.exclass and its value should be fully qualified class name of the exception that indicates OptimisticLocking. By default it will:
    • Retry 3 times
    • First retry will be attempted after 50 milliseconds
    • next retries will be calculated as last sleep time multiplied by a factor (default factor is 4)
    In case all retries failed origin exception will be thrown.
    • Field Detail

      • targetExceptionClass

        protected Class<?> targetExceptionClass
      • targetConstraintViolationExceptionClass

        protected Class<?> targetConstraintViolationExceptionClass
    • Constructor Detail

      • OptimisticLockRetryInterceptor

        public OptimisticLockRetryInterceptor()
    • Method Detail

      • execute

        public final org.kie.api.runtime.RequestContext execute​(org.kie.api.runtime.Executable executable,
                                                                org.kie.api.runtime.RequestContext ctx)
        Specified by:
        execute in interface org.kie.api.runtime.ExecutableRunner<org.kie.api.runtime.RequestContext>
        Overrides:
        execute in class org.drools.core.fluent.impl.PseudoClockRunner
      • internalExecute

        protected org.kie.api.runtime.RequestContext internalExecute​(org.kie.api.runtime.Executable executable,
                                                                     org.kie.api.runtime.RequestContext ctx)
      • isCausedByOptimisticLockingFailure

        protected boolean isCausedByOptimisticLockingFailure​(Throwable throwable)
      • isCausedByConstraintViolationFailure

        protected boolean isCausedByConstraintViolationFailure​(Throwable throwable)
      • getRetries

        public int getRetries()
      • setRetries

        public void setRetries​(int retries)
      • getDelay

        public long getDelay()
      • setDelay

        public void setDelay​(long delay)
      • getDelayFactor

        public long getDelayFactor()
      • setDelayFactor

        public void setDelayFactor​(long delayFactor)
      • getTargetExceptionClass

        public Class<?> getTargetExceptionClass()
      • setTargetExceptionClass

        public void setTargetExceptionClass​(Class<?> targetExceptionClass)
      • hasInterceptorInStack

        protected boolean hasInterceptorInStack()