public class DefaultJobManager extends Object implements JobManager
| Modifier and Type | Field and Description |
|---|---|
static String |
CYCLE_TYPE |
protected JobServiceConfiguration |
jobServiceConfiguration |
| Constructor and Description |
|---|
DefaultJobManager(JobServiceConfiguration jobServiceConfiguration) |
| Modifier and Type | Method and Description |
|---|---|
AbstractRuntimeJobEntity |
activateSuspendedJob(SuspendedJobEntity job)
Transforms a
SuspendedJobEntity back to an AbstractRuntimeJobEntity (i.e. |
void |
bulkMoveTimerJobsToExecutableJobs(List<TimerJobEntity> timerJobEntities)
Moves a collection of
TimerJobEntity instances to become async JobEntity 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) |
AbstractRuntimeJobEntity |
copyJobInfo(AbstractRuntimeJobEntity copyToJob,
AbstractRuntimeJobEntity copyFromJob)
Copy job info from one job to the other
|
protected void |
createAsyncHistoryHintListeners(HistoryJobEntity historyJobEntity) |
void |
createAsyncJob(JobEntity jobEntity,
boolean exclusive)
Creates an async job so that it can be continued later in a background thread.
|
DeadLetterJobEntity |
createDeadLetterJobFromHistoryJob(HistoryJobEntity historyJobEntity)
Create a dead letter job from a history job.
|
DeadLetterJobEntity |
createDeadLetterJobFromOtherJob(AbstractRuntimeJobEntity otherJob)
Create a dead letter job from another job
|
JobEntity |
createExecutableJobFromOtherJob(AbstractRuntimeJobEntity job)
Create an executable job from another job
|
protected JobEntity |
createExecutableJobFromOtherJob(AbstractRuntimeJobEntity job,
boolean lockJob) |
ExternalWorkerJobEntity |
createExternalWorkerJobFromOtherJob(AbstractRuntimeJobEntity otherJob)
Create an external worker job from another job
|
protected void |
createHintListeners(AsyncExecutor asyncExecutor,
JobInfoEntity job) |
SuspendedJobEntity |
createSuspendedJobFromOtherJob(AbstractRuntimeJobEntity otherJob)
Create a suspended job from another job
|
TimerJobEntity |
createTimerJobFromOtherJob(AbstractRuntimeJobEntity otherJob)
Create a timer job from another job
|
void |
execute(JobInfo job)
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 |
getAsyncExecutor() |
protected AsyncExecutor |
getAsyncHistoryExecutor() |
String |
getBusinessCalendarName(JobEntity timerEntity,
org.flowable.variable.api.delegate.VariableScope variableScope)
Get the business calendar name of the job configuration
|
protected String |
getBusinessCalendarName(String calendarName,
org.flowable.variable.api.delegate.VariableScope variableScope) |
protected CommandContext |
getCommandContext() |
protected String |
getExceptionStacktrace(Throwable exception) |
JobServiceConfiguration |
getJobServiceConfiguration() |
protected void |
hintAsyncExecutor(JobEntity job) |
protected void |
hintAsyncHistoryExecutor(HistoryJobEntity historyJobEntity) |
protected void |
internalCreateAsyncJob(JobEntity jobEntity,
boolean exclusive) |
protected void |
internalCreateLockedAsyncJob(JobEntity jobEntity,
boolean exclusive) |
protected boolean |
isAsyncExecutorActive() |
protected boolean |
isAsyncExecutorRemainingCapacitySufficient(int neededCapacity) |
protected boolean |
isAsyncHistoryExecutorActive() |
protected boolean |
isExecutorActive(AsyncExecutor asyncExecutor) |
protected boolean |
isValidTime(JobEntity timerEntity,
Date newTimerDate,
org.flowable.variable.api.delegate.VariableScope variableScope) |
Job |
moveDeadLetterJobToExecutableJob(DeadLetterJobEntity deadLetterJobEntity,
int retries)
Transforms a
DeadLetterJobEntity to a Job, thus making it executable again. |
HistoryJobEntity |
moveDeadLetterJobToHistoryJob(DeadLetterJobEntity deadLetterJobEntity,
int retries)
Transforms a
DeadLetterJobEntity to a HistoryJob, thus making it executable again (by the async history executor). |
JobEntity |
moveExternalWorkerJobToExecutableJob(ExternalWorkerJobEntity externalWorkerJob)
Moves an
ExternalWorkerJobEntity to become an async JobEntity. |
DeadLetterJobEntity |
moveJobToDeadLetterJob(AbstractRuntimeJobEntity job)
Transforms an
AbstractRuntimeJobEntity to a DeadLetterJobEntity. |
SuspendedJobEntity |
moveJobToSuspendedJob(AbstractRuntimeJobEntity job)
Moves an
AbstractRuntimeJobEntity to become a SuspendedJobEntity, such that the AsyncExecutor won't pick it up anymore for execution. |
TimerJobEntity |
moveJobToTimerJob(AbstractRuntimeJobEntity job)
Moves an
AbstractRuntimeJobEntity to become a TimerJobEntity. |
JobEntity |
moveTimerJobToExecutableJob(TimerJobEntity timerJob)
Moves a
TimerJobEntity to become an async JobEntity. |
void |
scheduleAsyncJob(JobEntity jobEntity)
Schedules and async job.
|
HistoryJobEntity |
scheduleHistoryJob(HistoryJobEntity historyJobEntity)
schedules a
HistoryJobEntity, 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 |
sendMoveToDeadletterEvent(JobInfo job) |
protected void |
sendTimerScheduledEvent(TimerJobEntity timerJob) |
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) |
protected void |
triggerExecutorIfNeeded(JobEntity jobEntity) |
void |
unacquire(JobInfo job)
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.
|
public static final String CYCLE_TYPE
protected JobServiceConfiguration jobServiceConfiguration
public DefaultJobManager(JobServiceConfiguration jobServiceConfiguration)
public void createAsyncJob(JobEntity jobEntity, boolean exclusive)
JobManagercreateAsyncJob in interface JobManagerpublic void scheduleAsyncJob(JobEntity jobEntity)
JobManagerAsyncExecutor is running, it can be executed immediately after the transaction. Otherwise it can be picked up by other executors.scheduleAsyncJob in interface JobManagerprotected void triggerExecutorIfNeeded(JobEntity jobEntity)
public void scheduleTimerJob(TimerJobEntity timerJob)
JobManagerscheduleTimerJob in interface JobManagerprotected void sendTimerScheduledEvent(TimerJobEntity timerJob)
public JobEntity moveTimerJobToExecutableJob(TimerJobEntity timerJob)
JobManagerTimerJobEntity to become an async JobEntity.
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 the AsyncExecutor.moveTimerJobToExecutableJob in interface JobManagerpublic void bulkMoveTimerJobsToExecutableJobs(List<TimerJobEntity> timerJobEntities)
JobManagerTimerJobEntity instances to become async JobEntity instances
(the timer is deleted and a new async job is inserted).
Note that there are no revision checks happening on the TimerJobEntity instances,
this means this method should only be used when running with a global acquire lock.bulkMoveTimerJobsToExecutableJobs in interface JobManagerpublic JobEntity moveExternalWorkerJobToExecutableJob(ExternalWorkerJobEntity externalWorkerJob)
JobManagerExternalWorkerJobEntity to become an async JobEntity.
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 the AsyncExecutor.moveExternalWorkerJobToExecutableJob in interface JobManagerpublic TimerJobEntity moveJobToTimerJob(AbstractRuntimeJobEntity job)
JobManagerAbstractRuntimeJobEntity to become a TimerJobEntity.
This happens for example when an async job is executed and fails. It then becomes a timer, as it needs to be retried later.moveJobToTimerJob in interface JobManagerpublic SuspendedJobEntity moveJobToSuspendedJob(AbstractRuntimeJobEntity job)
JobManagerAbstractRuntimeJobEntity to become a SuspendedJobEntity, such that the AsyncExecutor won't pick it up anymore for execution.moveJobToSuspendedJob in interface JobManagerpublic AbstractRuntimeJobEntity activateSuspendedJob(SuspendedJobEntity job)
JobManagerSuspendedJobEntity back to an AbstractRuntimeJobEntity (i.e. to what it was originally). The job will now again be able to picked up by the AsyncExecutor.activateSuspendedJob in interface JobManagerpublic DeadLetterJobEntity moveJobToDeadLetterJob(AbstractRuntimeJobEntity job)
JobManagerAbstractRuntimeJobEntity to a DeadLetterJobEntity. This means that the job has been tried a configurable amount of times, but kept failing.moveJobToDeadLetterJob in interface JobManagerprotected void sendMoveToDeadletterEvent(JobInfo job)
public Job moveDeadLetterJobToExecutableJob(DeadLetterJobEntity deadLetterJobEntity, int retries)
JobManagerDeadLetterJobEntity to a Job, 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.moveDeadLetterJobToExecutableJob in interface JobManagerpublic HistoryJobEntity moveDeadLetterJobToHistoryJob(DeadLetterJobEntity deadLetterJobEntity, int retries)
JobManagerDeadLetterJobEntity to a HistoryJob, 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.moveDeadLetterJobToHistoryJob in interface JobManagerpublic void execute(JobInfo job)
JobManagerexecute in interface JobManagerpublic void unacquire(JobInfo job)
JobManagerunacquire in interface JobManagerpublic void unacquireWithDecrementRetries(JobInfo job, Throwable exception)
JobManagerunacquireWithDecrementRetries in interface JobManagerprotected void executeMessageJob(JobEntity jobEntity)
protected void executeHistoryJob(HistoryJobEntity historyJobEntity)
protected void executeTimerJob(JobEntity timerEntity)
protected void executeJobHandler(JobEntity jobEntity)
protected void executeHistoryJobHandler(HistoryJobEntity historyJobEntity)
protected boolean isValidTime(JobEntity timerEntity, Date newTimerDate, org.flowable.variable.api.delegate.VariableScope variableScope)
protected void hintAsyncExecutor(JobEntity job)
protected void createHintListeners(AsyncExecutor asyncExecutor, JobInfoEntity job)
public String getBusinessCalendarName(JobEntity timerEntity, org.flowable.variable.api.delegate.VariableScope variableScope)
JobManagergetBusinessCalendarName in interface JobManagerprotected String getBusinessCalendarName(String calendarName, org.flowable.variable.api.delegate.VariableScope variableScope)
public HistoryJobEntity scheduleHistoryJob(HistoryJobEntity historyJobEntity)
JobManagerHistoryJobEntity, meaning it will be scheduled (inserted in the database/put on a queue/...) to be executed at a later point in time.scheduleHistoryJob in interface JobManagerprotected void triggerAsyncHistoryExecutorIfNeeded(HistoryJobEntity historyJobEntity)
protected void hintAsyncHistoryExecutor(HistoryJobEntity historyJobEntity)
protected void createAsyncHistoryHintListeners(HistoryJobEntity historyJobEntity)
protected void internalCreateAsyncJob(JobEntity jobEntity, boolean exclusive)
protected void internalCreateLockedAsyncJob(JobEntity jobEntity, boolean exclusive)
protected void setLockTimeAndOwner(AsyncExecutor asyncExecutor, JobInfoEntity jobInfoEntity)
protected void fillDefaultAsyncJobInfo(JobEntity jobEntity, boolean exclusive)
public JobEntity createExecutableJobFromOtherJob(AbstractRuntimeJobEntity job)
JobManagercreateExecutableJobFromOtherJob in interface JobManagerprotected JobEntity createExecutableJobFromOtherJob(AbstractRuntimeJobEntity job, boolean lockJob)
public TimerJobEntity createTimerJobFromOtherJob(AbstractRuntimeJobEntity otherJob)
JobManagercreateTimerJobFromOtherJob in interface JobManagerpublic SuspendedJobEntity createSuspendedJobFromOtherJob(AbstractRuntimeJobEntity otherJob)
JobManagercreateSuspendedJobFromOtherJob in interface JobManagerpublic DeadLetterJobEntity createDeadLetterJobFromOtherJob(AbstractRuntimeJobEntity otherJob)
JobManagercreateDeadLetterJobFromOtherJob in interface JobManagerpublic DeadLetterJobEntity createDeadLetterJobFromHistoryJob(HistoryJobEntity historyJobEntity)
JobManagerJobManager.createDeadLetterJobFromOtherJob(AbstractRuntimeJobEntity),
because history jobs have different data and cannot become timer/suspended/executable jobs.createDeadLetterJobFromHistoryJob in interface JobManagerpublic ExternalWorkerJobEntity createExternalWorkerJobFromOtherJob(AbstractRuntimeJobEntity otherJob)
JobManagercreateExternalWorkerJobFromOtherJob in interface JobManagerpublic AbstractRuntimeJobEntity copyJobInfo(AbstractRuntimeJobEntity copyToJob, AbstractRuntimeJobEntity copyFromJob)
JobManagercopyJobInfo in interface JobManagerprotected HistoryJobEntity copyHistoryJobInfo(HistoryJobEntity copyToJob, HistoryJobEntity copyFromJob)
protected AbstractJobEntity copyHistoryJobProperties(AbstractJobEntity copyToJob, AbstractJobEntity copyFromJob)
public JobServiceConfiguration getJobServiceConfiguration()
public void setJobServiceConfiguration(JobServiceConfiguration jobServiceConfiguration)
JobManagersetJobServiceConfiguration in interface JobManagerprotected boolean isAsyncExecutorActive()
protected boolean isAsyncExecutorRemainingCapacitySufficient(int neededCapacity)
protected boolean isAsyncHistoryExecutorActive()
protected boolean isExecutorActive(AsyncExecutor asyncExecutor)
protected CommandContext getCommandContext()
protected AsyncExecutor getAsyncExecutor()
protected AsyncExecutor getAsyncHistoryExecutor()
protected void callJobProcessors(JobProcessorContext.Phase processorType, AbstractJobEntity abstractJobEntity)
protected void callHistoryJobProcessors(HistoryJobProcessorContext.Phase processorType, HistoryJobEntity historyJobEntity)
Copyright © 2021 Flowable. All rights reserved.