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 aSuspendedJobEntityback to anAbstractRuntimeJobEntity(i.e.voidbulkMoveTimerJobsToExecutableJobs(List<TimerJobEntity> timerJobEntities) Moves a collection ofTimerJobEntityinstances to become asyncJobEntityinstances (the timer is deleted and a new async job is inserted).protected voidcallHistoryJobProcessors(HistoryJobProcessorContext.Phase processorType, HistoryJobEntity historyJobEntity) protected voidcallJobProcessors(JobProcessorContext.Phase processorType, AbstractJobEntity abstractJobEntity) protected HistoryJobEntitycopyHistoryJobInfo(HistoryJobEntity copyToJob, HistoryJobEntity copyFromJob) protected AbstractJobEntitycopyHistoryJobProperties(AbstractJobEntity copyToJob, AbstractJobEntity copyFromJob) copyJobInfo(AbstractRuntimeJobEntity copyToJob, AbstractRuntimeJobEntity copyFromJob) Copy job info from one job to the otherprotected voidcreateAsyncHistoryHintListeners(HistoryJobEntity historyJobEntity, TransactionContext transactionContext) voidcreateAsyncJob(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 JobEntitycreateExecutableJobFromOtherJob(AbstractRuntimeJobEntity job, boolean lockJob) Create an external worker job from another jobprotected voidcreateHintListeners(AsyncExecutor asyncExecutor, JobInfoEntity job) Create a suspended job from another jobCreate a timer job from another jobvoidvoidExecute a job, which means that the logic (async logic, timer that fires, etc) is executed, typically by a background thread of an executor.protected voidexecuteHistoryJob(HistoryJobEntity historyJobEntity) protected voidexecuteHistoryJobHandler(HistoryJobEntity historyJobEntity) protected voidexecuteJobHandler(JobEntity jobEntity) protected voidexecuteMessageJob(JobEntity jobEntity) protected voidexecuteTimerJob(JobEntity timerEntity) protected voidfillDefaultAsyncJobInfo(JobEntity jobEntity, boolean exclusive) protected AsyncExecutorprotected AsyncExecutorprotected StringgetBusinessCalendarName(String calendarName, VariableScope variableScope) getBusinessCalendarName(JobEntity timerEntity, VariableScope variableScope) Get the business calendar name of the job configurationprotected CommandContextprotected StringgetExceptionStacktrace(Throwable exception) protected voidprotected voidhintAsyncHistoryExecutor(HistoryJobEntity historyJobEntity, TransactionContext transactionContext) protected voidinternalCreateAsyncJob(JobEntity jobEntity, boolean exclusive) protected voidinternalCreateLockedAsyncJob(JobEntity jobEntity, boolean exclusive) protected booleanprotected booleanisAsyncExecutorRemainingCapacitySufficient(int neededCapacity) protected booleanprotected booleanisExecutorActive(AsyncExecutor asyncExecutor) protected booleanisJobApplicableForExecutorExecution(JobEntity jobEntity) protected booleanisValidTime(JobEntity timerEntity, Date newTimerDate, VariableScope variableScope) moveDeadLetterJobToExecutableJob(DeadLetterJobEntity deadLetterJobEntity, int retries) Transforms aDeadLetterJobEntityto aJob, thus making it executable again.moveDeadLetterJobToHistoryJob(DeadLetterJobEntity deadLetterJobEntity, int retries) Transforms aDeadLetterJobEntityto aHistoryJob, thus making it executable again (by the async history executor).moveExternalWorkerJobToExecutableJob(ExternalWorkerJobEntity externalWorkerJob) Moves anExternalWorkerJobEntityto become an asyncJobEntity.Transforms anAbstractRuntimeJobEntityto aDeadLetterJobEntity.Moves anAbstractRuntimeJobEntityto become aSuspendedJobEntity, such that theAsyncExecutorwon't pick it up anymore for execution.Moves anAbstractRuntimeJobEntityto become aTimerJobEntity.moveTimerJobToExecutableJob(TimerJobEntity timerJob) Moves aTimerJobEntityto become an asyncJobEntity.voidscheduleAsyncJob(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.voidscheduleTimerJob(TimerJobEntity timerJob) Schedules a timer, meaning it will be inserted in the datastore.protected voidvoidsetJobServiceConfiguration(JobServiceConfiguration jobServiceConfiguration) The ProcessEngineConfiguration instance will be passed when the ProcessEngine is built.protected voidsetLockTimeAndOwner(AsyncExecutor asyncExecutor, JobInfoEntity jobInfoEntity) protected voidtriggerAsyncHistoryExecutorIfNeeded(HistoryJobEntity historyJobEntity, TransactionContext transactionContext) protected voidtriggerExecutorIfNeeded(JobEntity jobEntity) voidUnacquires a job, meaning that this job was previously locked, and it is now freed to be acquired by other executor nodes.voidunacquireWithDecrementRetries(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:JobManagerCreates an async job so that it can be continued later in a background thread.- Specified by:
createAsyncJobin interfaceJobManager
-
scheduleAsyncJob
Description copied from interface:JobManagerSchedules and async job. If theAsyncExecutoris running, it can be executed immediately after the transaction. Otherwise it can be picked up by other executors.- Specified by:
scheduleAsyncJobin interfaceJobManager
-
triggerExecutorIfNeeded
-
isJobApplicableForExecutorExecution
-
scheduleTimerJob
Description copied from interface:JobManagerSchedules a timer, meaning it will be inserted in the datastore.- Specified by:
scheduleTimerJobin interfaceJobManager
-
moveTimerJobToExecutableJob
Description copied from interface:JobManagerMoves aTimerJobEntityto 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:
moveTimerJobToExecutableJobin interfaceJobManager
-
bulkMoveTimerJobsToExecutableJobs
Description copied from interface:JobManagerMoves a collection ofTimerJobEntityinstances to become asyncJobEntityinstances (the timer is deleted and a new async job is inserted). Note that there are no revision checks happening on theTimerJobEntityinstances, this means this method should only be used when running with a global acquire lock.- Specified by:
bulkMoveTimerJobsToExecutableJobsin interfaceJobManager
-
moveExternalWorkerJobToExecutableJob
Description copied from interface:JobManagerMoves anExternalWorkerJobEntityto 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:
moveExternalWorkerJobToExecutableJobin interfaceJobManager
-
moveJobToTimerJob
Description copied from interface:JobManagerMoves anAbstractRuntimeJobEntityto 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:
moveJobToTimerJobin interfaceJobManager
-
moveJobToSuspendedJob
Description copied from interface:JobManagerMoves anAbstractRuntimeJobEntityto become aSuspendedJobEntity, such that theAsyncExecutorwon't pick it up anymore for execution.- Specified by:
moveJobToSuspendedJobin interfaceJobManager
-
activateSuspendedJob
Description copied from interface:JobManagerTransforms aSuspendedJobEntityback to anAbstractRuntimeJobEntity(i.e. to what it was originally). The job will now again be able to picked up by theAsyncExecutor.- Specified by:
activateSuspendedJobin interfaceJobManager
-
moveJobToDeadLetterJob
Description copied from interface:JobManagerTransforms anAbstractRuntimeJobEntityto aDeadLetterJobEntity. This means that the job has been tried a configurable amount of times, but kept failing.- Specified by:
moveJobToDeadLetterJobin interfaceJobManager
-
sendMoveToDeadletterEvent
-
moveDeadLetterJobToExecutableJob
Description copied from interface:JobManagerTransforms aDeadLetterJobEntityto 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:
moveDeadLetterJobToExecutableJobin interfaceJobManager
-
moveDeadLetterJobToHistoryJob
public HistoryJobEntity moveDeadLetterJobToHistoryJob(DeadLetterJobEntity deadLetterJobEntity, int retries) Description copied from interface:JobManagerTransforms aDeadLetterJobEntityto 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:
moveDeadLetterJobToHistoryJobin interfaceJobManager
-
execute
Description copied from interface:JobManagerExecute 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:
executein interfaceJobManager
-
unacquire
Description copied from interface:JobManagerUnacquires a job, meaning that this job was previously locked, and it is now freed to be acquired by other executor nodes.- Specified by:
unacquirein interfaceJobManager
-
unacquireWithDecrementRetries
Description copied from interface:JobManagerUnacquires a job, meaning that this job was previously locked, and it is now freed to be acquired by other executor nodes.- Specified by:
unacquireWithDecrementRetriesin interfaceJobManager
-
deleteExecutableJob
- Specified by:
deleteExecutableJobin interfaceJobManager
-
getExceptionStacktrace
-
executeMessageJob
-
executeHistoryJob
-
executeTimerJob
-
executeJobHandler
-
executeHistoryJobHandler
-
isValidTime
protected boolean isValidTime(JobEntity timerEntity, Date newTimerDate, VariableScope variableScope) -
hintAsyncExecutor
-
createHintListeners
-
getBusinessCalendarName
Description copied from interface:JobManagerGet the business calendar name of the job configuration- Specified by:
getBusinessCalendarNamein interfaceJobManager
-
getBusinessCalendarName
-
scheduleHistoryJob
public HistoryJobEntity scheduleHistoryJob(HistoryJobEntity historyJobEntity, TransactionContext transactionContext) Description copied from interface:JobManagerschedules 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:
scheduleHistoryJobin 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:JobManagerCreate an executable job from another job- Specified by:
createExecutableJobFromOtherJobin interfaceJobManager
-
createExecutableJobFromOtherJob
-
createTimerJobFromOtherJob
Description copied from interface:JobManagerCreate a timer job from another job- Specified by:
createTimerJobFromOtherJobin interfaceJobManager
-
createSuspendedJobFromOtherJob
Description copied from interface:JobManagerCreate a suspended job from another job- Specified by:
createSuspendedJobFromOtherJobin interfaceJobManager
-
createDeadLetterJobFromOtherJob
Description copied from interface:JobManagerCreate a dead letter job from another job- Specified by:
createDeadLetterJobFromOtherJobin interfaceJobManager
-
createDeadLetterJobFromHistoryJob
Description copied from interface:JobManagerCreate 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:
createDeadLetterJobFromHistoryJobin interfaceJobManager
-
createExternalWorkerJobFromOtherJob
public ExternalWorkerJobEntity createExternalWorkerJobFromOtherJob(AbstractRuntimeJobEntity otherJob) Description copied from interface:JobManagerCreate an external worker job from another job- Specified by:
createExternalWorkerJobFromOtherJobin interfaceJobManager
-
copyJobInfo
public AbstractRuntimeJobEntity copyJobInfo(AbstractRuntimeJobEntity copyToJob, AbstractRuntimeJobEntity copyFromJob) Description copied from interface:JobManagerCopy job info from one job to the other- Specified by:
copyJobInfoin interfaceJobManager
-
copyHistoryJobInfo
protected HistoryJobEntity copyHistoryJobInfo(HistoryJobEntity copyToJob, HistoryJobEntity copyFromJob) -
copyHistoryJobProperties
protected AbstractJobEntity copyHistoryJobProperties(AbstractJobEntity copyToJob, AbstractJobEntity copyFromJob) -
getJobServiceConfiguration
-
setJobServiceConfiguration
Description copied from interface:JobManagerThe ProcessEngineConfiguration instance will be passed when the ProcessEngine is built.- Specified by:
setJobServiceConfigurationin 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)
-