Class DefaultJobManager
java.lang.Object
org.flowable.job.service.impl.asyncexecutor.DefaultJobManager
- All Implemented Interfaces:
JobManager
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionTransforms aSuspendedJobEntity
back to anAbstractRuntimeJobEntity
(i.e.void
bulkMoveTimerJobsToExecutableJobs
(List<TimerJobEntity> timerJobEntities) Moves a collection ofTimerJobEntity
instances to become asyncJobEntity
instances (the timer is deleted and a new async job is inserted).protected void
callHistoryJobProcessors
(HistoryJobProcessorContext.Phase processorType, HistoryJobEntity historyJobEntity) protected void
callJobProcessors
(JobProcessorContext.Phase processorType, AbstractJobEntity abstractJobEntity) protected HistoryJobEntity
copyHistoryJobInfo
(HistoryJobEntity copyToJob, HistoryJobEntity copyFromJob) protected AbstractJobEntity
copyHistoryJobProperties
(AbstractJobEntity copyToJob, AbstractJobEntity copyFromJob) copyJobInfo
(AbstractRuntimeJobEntity copyToJob, AbstractRuntimeJobEntity copyFromJob) Copy job info from one job to the otherprotected void
createAsyncHistoryHintListeners
(HistoryJobEntity historyJobEntity, TransactionContext transactionContext) void
createAsyncJob
(JobEntity jobEntity, boolean exclusive) Creates an async job so that it can be continued later in a background thread.createDeadLetterJobFromHistoryJob
(HistoryJobEntity historyJobEntity) Create a dead letter job from a history job.Create a dead letter job from another jobCreate an executable job from another jobprotected JobEntity
createExecutableJobFromOtherJob
(AbstractRuntimeJobEntity job, boolean lockJob) Create an external worker job from another jobprotected void
createHintListeners
(AsyncExecutor asyncExecutor, JobInfoEntity job) Create a suspended job from another jobCreate a timer job from another jobvoid
void
Execute a job, which means that the logic (async logic, timer that fires, etc) is executed, typically by a background thread of an executor.protected void
executeHistoryJob
(HistoryJobEntity historyJobEntity) protected void
executeHistoryJobHandler
(HistoryJobEntity historyJobEntity) protected void
executeJobHandler
(JobEntity jobEntity) protected void
executeMessageJob
(JobEntity jobEntity) protected void
executeTimerJob
(JobEntity timerEntity) protected void
fillDefaultAsyncJobInfo
(JobEntity jobEntity, boolean exclusive) protected AsyncExecutor
protected AsyncExecutor
protected String
getBusinessCalendarName
(String calendarName, VariableScope variableScope) getBusinessCalendarName
(JobEntity timerEntity, VariableScope variableScope) Get the business calendar name of the job configurationprotected CommandContext
protected String
getExceptionStacktrace
(Throwable exception) protected void
protected void
hintAsyncHistoryExecutor
(HistoryJobEntity historyJobEntity, TransactionContext transactionContext) protected void
internalCreateAsyncJob
(JobEntity jobEntity, boolean exclusive) protected void
internalCreateLockedAsyncJob
(JobEntity jobEntity, boolean exclusive) protected boolean
protected boolean
isAsyncExecutorRemainingCapacitySufficient
(int neededCapacity) protected boolean
protected boolean
isExecutorActive
(AsyncExecutor asyncExecutor) protected boolean
isJobApplicableForExecutorExecution
(JobEntity jobEntity) protected boolean
isValidTime
(JobEntity timerEntity, Date newTimerDate, VariableScope variableScope) moveDeadLetterJobToExecutableJob
(DeadLetterJobEntity deadLetterJobEntity, int retries) Transforms aDeadLetterJobEntity
to aJob
, thus making it executable again.moveDeadLetterJobToHistoryJob
(DeadLetterJobEntity deadLetterJobEntity, int retries) Transforms aDeadLetterJobEntity
to aHistoryJob
, thus making it executable again (by the async history executor).moveExternalWorkerJobToExecutableJob
(ExternalWorkerJobEntity externalWorkerJob) Moves anExternalWorkerJobEntity
to become an asyncJobEntity
.Transforms anAbstractRuntimeJobEntity
to aDeadLetterJobEntity
.Moves anAbstractRuntimeJobEntity
to become aSuspendedJobEntity
, such that theAsyncExecutor
won't pick it up anymore for execution.Moves anAbstractRuntimeJobEntity
to become aTimerJobEntity
.moveTimerJobToExecutableJob
(TimerJobEntity timerJob) Moves aTimerJobEntity
to become an asyncJobEntity
.void
scheduleAsyncJob
(JobEntity jobEntity) Schedules and async job.scheduleHistoryJob
(HistoryJobEntity historyJobEntity, TransactionContext transactionContext) schedules aHistoryJobEntity
, meaning it will be scheduled (inserted in the database/put on a queue/...) to be executed at a later point in time.void
scheduleTimerJob
(TimerJobEntity timerJob) Schedules a timer, meaning it will be inserted in the datastore.protected void
void
setJobServiceConfiguration
(JobServiceConfiguration jobServiceConfiguration) The ProcessEngineConfiguration instance will be passed when the ProcessEngine is built.protected void
setLockTimeAndOwner
(AsyncExecutor asyncExecutor, JobInfoEntity jobInfoEntity) protected void
triggerAsyncHistoryExecutorIfNeeded
(HistoryJobEntity historyJobEntity, TransactionContext transactionContext) protected void
triggerExecutorIfNeeded
(JobEntity jobEntity) void
Unacquires a job, meaning that this job was previously locked, and it is now freed to be acquired by other executor nodes.void
unacquireWithDecrementRetries
(JobInfo job, Throwable exception) Unacquires a job, meaning that this job was previously locked, and it is now freed to be acquired by other executor nodes.
-
Field Details
-
CYCLE_TYPE
- See Also:
-
jobServiceConfiguration
-
-
Constructor Details
-
DefaultJobManager
-
-
Method Details
-
createAsyncJob
Description copied from interface:JobManager
Creates an async job so that it can be continued later in a background thread.- Specified by:
createAsyncJob
in interfaceJobManager
-
scheduleAsyncJob
Description copied from interface:JobManager
Schedules and async job. If theAsyncExecutor
is running, it can be executed immediately after the transaction. Otherwise it can be picked up by other executors.- Specified by:
scheduleAsyncJob
in interfaceJobManager
-
triggerExecutorIfNeeded
-
isJobApplicableForExecutorExecution
-
scheduleTimerJob
Description copied from interface:JobManager
Schedules a timer, meaning it will be inserted in the datastore.- Specified by:
scheduleTimerJob
in interfaceJobManager
-
moveTimerJobToExecutableJob
Description copied from interface:JobManager
Moves aTimerJobEntity
to become an asyncJobEntity
. This happens for example when the due date of a timer is reached, the timer entity then becomes a 'regular' async job that can be picked up by theAsyncExecutor
.- Specified by:
moveTimerJobToExecutableJob
in interfaceJobManager
-
bulkMoveTimerJobsToExecutableJobs
Description copied from interface:JobManager
Moves a collection ofTimerJobEntity
instances to become asyncJobEntity
instances (the timer is deleted and a new async job is inserted). Note that there are no revision checks happening on theTimerJobEntity
instances, this means this method should only be used when running with a global acquire lock.- Specified by:
bulkMoveTimerJobsToExecutableJobs
in interfaceJobManager
-
moveExternalWorkerJobToExecutableJob
Description copied from interface:JobManager
Moves anExternalWorkerJobEntity
to become an asyncJobEntity
. This happens when the external worker has completed the work and the external work job then becomes a 'regular' async job that can be picked up by theAsyncExecutor
.- Specified by:
moveExternalWorkerJobToExecutableJob
in interfaceJobManager
-
moveJobToTimerJob
Description copied from interface:JobManager
Moves anAbstractRuntimeJobEntity
to become aTimerJobEntity
. This happens for example when an async job is executed and fails. It then becomes a timer, as it needs to be retried later.- Specified by:
moveJobToTimerJob
in interfaceJobManager
-
moveJobToSuspendedJob
Description copied from interface:JobManager
Moves anAbstractRuntimeJobEntity
to become aSuspendedJobEntity
, such that theAsyncExecutor
won't pick it up anymore for execution.- Specified by:
moveJobToSuspendedJob
in interfaceJobManager
-
activateSuspendedJob
Description copied from interface:JobManager
Transforms aSuspendedJobEntity
back to anAbstractRuntimeJobEntity
(i.e. to what it was originally). The job will now again be able to picked up by theAsyncExecutor
.- Specified by:
activateSuspendedJob
in interfaceJobManager
-
moveJobToDeadLetterJob
Description copied from interface:JobManager
Transforms anAbstractRuntimeJobEntity
to aDeadLetterJobEntity
. This means that the job has been tried a configurable amount of times, but kept failing.- Specified by:
moveJobToDeadLetterJob
in interfaceJobManager
-
sendMoveToDeadletterEvent
-
moveDeadLetterJobToExecutableJob
Description copied from interface:JobManager
Transforms aDeadLetterJobEntity
to aJob
, thus making it executable again. Note that a 'retries' parameter needs to be passed, as the job got into the deadletter table because of it failed and retries became 0.- Specified by:
moveDeadLetterJobToExecutableJob
in interfaceJobManager
-
moveDeadLetterJobToHistoryJob
public HistoryJobEntity moveDeadLetterJobToHistoryJob(DeadLetterJobEntity deadLetterJobEntity, int retries) Description copied from interface:JobManager
Transforms aDeadLetterJobEntity
to aHistoryJob
, thus making it executable again (by the async history executor). Note that a 'retries' parameter needs to be passed, as the job got into the deadletter table because of it failed and retries became 0.- Specified by:
moveDeadLetterJobToHistoryJob
in interfaceJobManager
-
execute
Description copied from interface:JobManager
Execute a job, which means that the logic (async logic, timer that fires, etc) is executed, typically by a background thread of an executor.- Specified by:
execute
in interfaceJobManager
-
unacquire
Description copied from interface:JobManager
Unacquires a job, meaning that this job was previously locked, and it is now freed to be acquired by other executor nodes.- Specified by:
unacquire
in interfaceJobManager
-
unacquireWithDecrementRetries
Description copied from interface:JobManager
Unacquires a job, meaning that this job was previously locked, and it is now freed to be acquired by other executor nodes.- Specified by:
unacquireWithDecrementRetries
in interfaceJobManager
-
deleteExecutableJob
- Specified by:
deleteExecutableJob
in interfaceJobManager
-
getExceptionStacktrace
-
executeMessageJob
-
executeHistoryJob
-
executeTimerJob
-
executeJobHandler
-
executeHistoryJobHandler
-
isValidTime
protected boolean isValidTime(JobEntity timerEntity, Date newTimerDate, VariableScope variableScope) -
hintAsyncExecutor
-
createHintListeners
-
getBusinessCalendarName
Description copied from interface:JobManager
Get the business calendar name of the job configuration- Specified by:
getBusinessCalendarName
in interfaceJobManager
-
getBusinessCalendarName
-
scheduleHistoryJob
public HistoryJobEntity scheduleHistoryJob(HistoryJobEntity historyJobEntity, TransactionContext transactionContext) Description copied from interface:JobManager
schedules aHistoryJobEntity
, meaning it will be scheduled (inserted in the database/put on a queue/...) to be executed at a later point in time.- Specified by:
scheduleHistoryJob
in interfaceJobManager
-
triggerAsyncHistoryExecutorIfNeeded
protected void triggerAsyncHistoryExecutorIfNeeded(HistoryJobEntity historyJobEntity, TransactionContext transactionContext) -
hintAsyncHistoryExecutor
protected void hintAsyncHistoryExecutor(HistoryJobEntity historyJobEntity, TransactionContext transactionContext) -
createAsyncHistoryHintListeners
protected void createAsyncHistoryHintListeners(HistoryJobEntity historyJobEntity, TransactionContext transactionContext) -
internalCreateAsyncJob
-
internalCreateLockedAsyncJob
-
setLockTimeAndOwner
-
fillDefaultAsyncJobInfo
-
createExecutableJobFromOtherJob
Description copied from interface:JobManager
Create an executable job from another job- Specified by:
createExecutableJobFromOtherJob
in interfaceJobManager
-
createExecutableJobFromOtherJob
-
createTimerJobFromOtherJob
Description copied from interface:JobManager
Create a timer job from another job- Specified by:
createTimerJobFromOtherJob
in interfaceJobManager
-
createSuspendedJobFromOtherJob
Description copied from interface:JobManager
Create a suspended job from another job- Specified by:
createSuspendedJobFromOtherJob
in interfaceJobManager
-
createDeadLetterJobFromOtherJob
Description copied from interface:JobManager
Create a dead letter job from another job- Specified by:
createDeadLetterJobFromOtherJob
in interfaceJobManager
-
createDeadLetterJobFromHistoryJob
Description copied from interface:JobManager
Create a dead letter job from a history job. This is different fromJobManager.createDeadLetterJobFromOtherJob(AbstractRuntimeJobEntity)
, because history jobs have different data and cannot become timer/suspended/executable jobs.- Specified by:
createDeadLetterJobFromHistoryJob
in interfaceJobManager
-
createExternalWorkerJobFromOtherJob
public ExternalWorkerJobEntity createExternalWorkerJobFromOtherJob(AbstractRuntimeJobEntity otherJob) Description copied from interface:JobManager
Create an external worker job from another job- Specified by:
createExternalWorkerJobFromOtherJob
in interfaceJobManager
-
copyJobInfo
public AbstractRuntimeJobEntity copyJobInfo(AbstractRuntimeJobEntity copyToJob, AbstractRuntimeJobEntity copyFromJob) Description copied from interface:JobManager
Copy job info from one job to the other- Specified by:
copyJobInfo
in interfaceJobManager
-
copyHistoryJobInfo
protected HistoryJobEntity copyHistoryJobInfo(HistoryJobEntity copyToJob, HistoryJobEntity copyFromJob) -
copyHistoryJobProperties
protected AbstractJobEntity copyHistoryJobProperties(AbstractJobEntity copyToJob, AbstractJobEntity copyFromJob) -
getJobServiceConfiguration
-
setJobServiceConfiguration
Description copied from interface:JobManager
The ProcessEngineConfiguration instance will be passed when the ProcessEngine is built.- Specified by:
setJobServiceConfiguration
in interfaceJobManager
-
isAsyncExecutorActive
protected boolean isAsyncExecutorActive() -
isAsyncExecutorRemainingCapacitySufficient
protected boolean isAsyncExecutorRemainingCapacitySufficient(int neededCapacity) -
isAsyncHistoryExecutorActive
protected boolean isAsyncHistoryExecutorActive() -
isExecutorActive
-
getCommandContext
-
getAsyncExecutor
-
getAsyncHistoryExecutor
-
callJobProcessors
protected void callJobProcessors(JobProcessorContext.Phase processorType, AbstractJobEntity abstractJobEntity) -
callHistoryJobProcessors
protected void callHistoryJobProcessors(HistoryJobProcessorContext.Phase processorType, HistoryJobEntity historyJobEntity)
-