Package org.drools.persistence.jpa
Class OptimisticLockRetryInterceptor
java.lang.Object
org.drools.commands.fluent.PseudoClockRunner
org.drools.commands.impl.AbstractInterceptor
org.drools.persistence.jpa.OptimisticLockRetryInterceptor
- All Implemented Interfaces:
ChainableRunner,InternalLocalRunner,CommandExecutor,ExecutableRunner<RequestContext>
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)
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.drools.commands.InternalLocalRunner
InternalLocalRunner.SingleBatchExecutable, InternalLocalRunner.SingleCommandExecutable -
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionfinal RequestContextexecute(Executable executable, RequestContext ctx) longgetDelay()longintClass<?>protected booleanprotected RequestContextinternalExecute(Executable executable, RequestContext ctx) protected booleanisCausedByConstraintViolationFailure(Throwable throwable) protected booleanisCausedByOptimisticLockingFailure(Throwable throwable) voidsetDelay(long delay) voidsetDelayFactor(long delayFactor) voidsetRetries(int retries) voidsetTargetExceptionClass(Class<?> targetExceptionClass) Methods inherited from class org.drools.commands.impl.AbstractInterceptor
executeNext, getNext, setNextMethods inherited from class org.drools.commands.fluent.PseudoClockRunner
createContextMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.kie.api.runtime.ExecutableRunner
createContextMethods inherited from interface org.drools.commands.InternalLocalRunner
execute, execute, execute
-
Field Details
-
targetExceptionClass
-
targetConstraintViolationExceptionClass
-
-
Constructor Details
-
OptimisticLockRetryInterceptor
public OptimisticLockRetryInterceptor()
-
-
Method Details
-
execute
- Specified by:
executein interfaceExecutableRunner<RequestContext>- Overrides:
executein classPseudoClockRunner
-
internalExecute
-
isCausedByOptimisticLockingFailure
-
isCausedByConstraintViolationFailure
-
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
-
setTargetExceptionClass
-
hasInterceptorInStack
protected boolean hasInterceptorInStack()
-