use of org.activiti.engine.impl.persistence.entity.TimerJobEntity in project Activiti by Activiti.
the class AcquireTimerJobsCmd method execute.
public AcquiredTimerJobEntities execute(CommandContext commandContext) {
AcquiredTimerJobEntities acquiredJobs = new AcquiredTimerJobEntities();
List<TimerJobEntity> timerJobs = commandContext.getTimerJobEntityManager().findTimerJobsToExecute(new Page(0, asyncExecutor.getMaxAsyncJobsDuePerAcquisition()));
for (TimerJobEntity job : timerJobs) {
lockJob(commandContext, job, asyncExecutor.getAsyncJobLockTimeInMillis());
acquiredJobs.addJob(job);
}
return acquiredJobs;
}
use of org.activiti.engine.impl.persistence.entity.TimerJobEntity in project Activiti by Activiti.
the class DefaultJobManager method activateSuspendedJob.
@Override
public AbstractJobEntity activateSuspendedJob(SuspendedJobEntity job) {
AbstractJobEntity activatedJob = null;
if (Job.JOB_TYPE_TIMER.equals(job.getJobType())) {
activatedJob = createTimerJobFromOtherJob(job);
processEngineConfiguration.getTimerJobEntityManager().insert((TimerJobEntity) activatedJob);
} else {
activatedJob = createExecutableJobFromOtherJob(job);
JobEntity jobEntity = (JobEntity) activatedJob;
processEngineConfiguration.getJobEntityManager().insert(jobEntity);
triggerExecutorIfNeeded(jobEntity);
}
processEngineConfiguration.getSuspendedJobEntityManager().delete(job);
return activatedJob;
}
use of org.activiti.engine.impl.persistence.entity.TimerJobEntity in project Activiti by Activiti.
the class DefaultJobManager method executeTimerJob.
protected void executeTimerJob(JobEntity timerEntity) {
TimerJobEntityManager timerJobEntityManager = processEngineConfiguration.getTimerJobEntityManager();
VariableScope variableScope = null;
if (timerEntity.getExecutionId() != null) {
variableScope = getExecutionEntityManager().findById(timerEntity.getExecutionId());
}
if (variableScope == null) {
variableScope = NoExecutionVariableScope.getSharedInstance();
}
// set endDate if it was set to the definition
restoreExtraData(timerEntity, variableScope);
if (timerEntity.getDuedate() != null && !isValidTime(timerEntity, timerEntity.getDuedate(), variableScope)) {
if (logger.isDebugEnabled()) {
logger.debug("Timer {} fired. but the dueDate is after the endDate. Deleting timer.", timerEntity.getId());
}
processEngineConfiguration.getJobEntityManager().delete(timerEntity);
return;
}
executeJobHandler(timerEntity);
processEngineConfiguration.getJobEntityManager().delete(timerEntity);
if (logger.isDebugEnabled()) {
logger.debug("Timer {} fired. Deleting timer.", timerEntity.getId());
}
if (timerEntity.getRepeat() != null) {
TimerJobEntity newTimerJobEntity = timerJobEntityManager.createAndCalculateNextTimer(timerEntity, variableScope);
if (newTimerJobEntity != null) {
scheduleTimerJob(newTimerJobEntity);
}
}
}
use of org.activiti.engine.impl.persistence.entity.TimerJobEntity in project Activiti by Activiti.
the class DefaultJobManager method moveJobToTimerJob.
@Override
public TimerJobEntity moveJobToTimerJob(AbstractJobEntity job) {
TimerJobEntity timerJob = createTimerJobFromOtherJob(job);
boolean insertSuccesful = processEngineConfiguration.getTimerJobEntityManager().insertTimerJobEntity(timerJob);
if (insertSuccesful) {
if (job instanceof JobEntity) {
processEngineConfiguration.getJobEntityManager().delete((JobEntity) job);
} else if (job instanceof SuspendedJobEntity) {
processEngineConfiguration.getSuspendedJobEntityManager().delete((SuspendedJobEntity) job);
}
return timerJob;
}
return null;
}
use of org.activiti.engine.impl.persistence.entity.TimerJobEntity in project Activiti by Activiti.
the class DefaultJobManager method moveJobToDeadLetterJob.
@Override
public DeadLetterJobEntity moveJobToDeadLetterJob(AbstractJobEntity job) {
DeadLetterJobEntity deadLetterJob = createDeadLetterJobFromOtherJob(job);
processEngineConfiguration.getDeadLetterJobEntityManager().insert(deadLetterJob);
if (job instanceof TimerJobEntity) {
processEngineConfiguration.getTimerJobEntityManager().delete((TimerJobEntity) job);
} else if (job instanceof JobEntity) {
processEngineConfiguration.getJobEntityManager().delete((JobEntity) job);
}
return deadLetterJob;
}
Aggregations