use of org.activiti.engine.impl.cmd.ExecuteJobsCmd in project Activiti by Activiti.
the class ExecuteJobsRunnable method handleSingleJob.
protected void handleSingleJob() {
final SingleJobExecutorContext jobExecutorContext = new SingleJobExecutorContext();
final List<JobEntity> currentProcessorJobQueue = jobExecutorContext.getCurrentProcessorJobQueue();
final CommandExecutor commandExecutor = jobExecutor.getCommandExecutor();
currentProcessorJobQueue.add(job);
Context.setJobExecutorContext(jobExecutorContext);
try {
while (!currentProcessorJobQueue.isEmpty()) {
JobEntity currentJob = currentProcessorJobQueue.remove(0);
try {
commandExecutor.execute(new ExecuteJobsCmd(currentJob));
} catch (Throwable e) {
log.error("exception during job execution: {}", e.getMessage(), e);
} finally {
jobExecutor.jobDone(currentJob);
}
}
} finally {
Context.removeJobExecutorContext();
}
}
use of org.activiti.engine.impl.cmd.ExecuteJobsCmd in project Activiti by Activiti.
the class ExecuteJobsRunnable method handleMultipleJobs.
protected void handleMultipleJobs() {
final MultipleJobsExecutorContext jobExecutorContext = new MultipleJobsExecutorContext();
final List<String> currentProcessorJobQueue = jobExecutorContext.getCurrentProcessorJobQueue();
final CommandExecutor commandExecutor = jobExecutor.getCommandExecutor();
currentProcessorJobQueue.addAll(jobIds);
Context.setJobExecutorContext(jobExecutorContext);
try {
while (!currentProcessorJobQueue.isEmpty()) {
String currentJobId = currentProcessorJobQueue.remove(0);
try {
commandExecutor.execute(new ExecuteJobsCmd(currentJobId));
} catch (Throwable e) {
log.error("exception during job execution: {}", e.getMessage(), e);
} finally {
jobExecutor.jobDone(currentJobId);
}
}
} finally {
Context.removeJobExecutorContext();
}
}
Aggregations