Package org.camunda.bpm.engine.impl.cmd
Class AcquireJobsCmd
- java.lang.Object
-
- org.camunda.bpm.engine.impl.cmd.AcquireJobsCmd
-
- All Implemented Interfaces:
OptimisticLockingListener
,Command<AcquiredJobs>
public class AcquireJobsCmd extends java.lang.Object implements Command<AcquiredJobs>, OptimisticLockingListener
- Author:
- Nick Burch, Daniel Meyer
-
-
Field Summary
Fields Modifier and Type Field Description protected AcquiredJobs
acquiredJobs
protected int
numJobsToAcquire
-
Constructor Summary
Constructors Constructor Description AcquireJobsCmd(JobExecutor jobExecutor)
AcquireJobsCmd(JobExecutor jobExecutor, int numJobsToAcquire)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description AcquiredJobs
execute(CommandContext commandContext)
OptimisticLockingResult
failedOperation(DbOperation operation)
Signifies that an operation failed due to optimistic locking.java.lang.Class<? extends DbEntity>
getEntityType()
The type of the entity for which this listener should be notified.boolean
isRetryable()
When CockroachDB is used, this command may be retried multiple times until it is successful, or the retries are exhausted.protected void
lockJob(AcquirableJobEntity job)
-
-
-
Field Detail
-
acquiredJobs
protected AcquiredJobs acquiredJobs
-
numJobsToAcquire
protected int numJobsToAcquire
-
-
Constructor Detail
-
AcquireJobsCmd
public AcquireJobsCmd(JobExecutor jobExecutor)
-
AcquireJobsCmd
public AcquireJobsCmd(JobExecutor jobExecutor, int numJobsToAcquire)
-
-
Method Detail
-
execute
public AcquiredJobs execute(CommandContext commandContext)
- Specified by:
execute
in interfaceCommand<AcquiredJobs>
-
isRetryable
public boolean isRetryable()
When CockroachDB is used, this command may be retried multiple times until it is successful, or the retries are exhausted. CockroachDB uses a stricter, SERIALIZABLE transaction isolation which ensures a serialized manner of transaction execution. A concurrent transaction that attempts to modify the same data as another transaction is required to abort, rollback and retry. This also makes our use-case of pessimistic locks redundant since we only use them as synchronization barriers, and not to lock actual data which would protect it from concurrent modifications. The AcquireJobs command only executes internal code, so we are certain that a retry of failed job locks will not impact user data, and may be performed multiple times.- Specified by:
isRetryable
in interfaceCommand<AcquiredJobs>
- Returns:
- true if the
CrdbTransactionRetryInterceptor
can make a transparent retry of this command upon failure with aCrdbTransactionRetryException
(only used when running on CockroachDB).
-
lockJob
protected void lockJob(AcquirableJobEntity job)
-
getEntityType
public java.lang.Class<? extends DbEntity> getEntityType()
Description copied from interface:OptimisticLockingListener
The type of the entity for which this listener should be notified. If the implementation returns 'null', the listener is notified for all entity types.- Specified by:
getEntityType
in interfaceOptimisticLockingListener
- Returns:
- the entity type for which the listener should be notified.
-
failedOperation
public OptimisticLockingResult failedOperation(DbOperation operation)
Description copied from interface:OptimisticLockingListener
Signifies that an operation failed due to optimistic locking.- Specified by:
failedOperation
in interfaceOptimisticLockingListener
- Parameters:
operation
- the failed operation.- Returns:
OptimisticLockingResult
that instructs the caller how to handle the result of the failed operation.
-
-