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:
org.drools.commands.ChainableRunner
,org.drools.commands.InternalLocalRunner
,org.kie.api.runtime.CommandExecutor
,org.kie.api.runtime.ExecutableRunner<org.kie.api.runtime.RequestContext>
public class OptimisticLockRetryInterceptor extends org.drools.commands.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 fororg.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 propertyorg.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)
-
-
Field Summary
Fields Modifier and Type Field Description protected java.lang.Class<?>
targetConstraintViolationExceptionClass
protected java.lang.Class<?>
targetExceptionClass
-
Constructor Summary
Constructors Constructor Description OptimisticLockRetryInterceptor()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description org.kie.api.runtime.RequestContext
execute(org.kie.api.runtime.Executable executable, org.kie.api.runtime.RequestContext ctx)
long
getDelay()
long
getDelayFactor()
int
getRetries()
java.lang.Class<?>
getTargetExceptionClass()
protected boolean
hasInterceptorInStack()
protected org.kie.api.runtime.RequestContext
internalExecute(org.kie.api.runtime.Executable executable, org.kie.api.runtime.RequestContext ctx)
protected boolean
isCausedByConstraintViolationFailure(java.lang.Throwable throwable)
protected boolean
isCausedByOptimisticLockingFailure(java.lang.Throwable throwable)
void
setDelay(long delay)
void
setDelayFactor(long delayFactor)
void
setRetries(int retries)
void
setTargetExceptionClass(java.lang.Class<?> targetExceptionClass)
-
Methods inherited from class org.drools.commands.impl.AbstractInterceptor
executeNext, getNext, setNext
-
-
-
-
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 interfaceorg.kie.api.runtime.ExecutableRunner<org.kie.api.runtime.RequestContext>
- Overrides:
execute
in classorg.drools.commands.fluent.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(java.lang.Throwable throwable)
-
isCausedByConstraintViolationFailure
protected boolean isCausedByConstraintViolationFailure(java.lang.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 java.lang.Class<?> getTargetExceptionClass()
-
setTargetExceptionClass
public void setTargetExceptionClass(java.lang.Class<?> targetExceptionClass)
-
hasInterceptorInStack
protected boolean hasInterceptorInStack()
-
-