use of org.camunda.bpm.engine.impl.interceptor.CommandExecutor in project camunda-bpm-platform by camunda.
the class SequentialJobAcquisitionRunnable method acquireJobs.
protected AcquiredJobs acquireJobs(JobAcquisitionContext context, JobAcquisitionStrategy acquisitionStrategy, ProcessEngineImpl currentProcessEngine) {
CommandExecutor commandExecutor = currentProcessEngine.getProcessEngineConfiguration().getCommandExecutorTxRequired();
int numJobsToAcquire = acquisitionStrategy.getNumJobsToAcquire(currentProcessEngine.getName());
AcquiredJobs acquiredJobs = null;
if (numJobsToAcquire > 0) {
jobExecutor.logAcquisitionAttempt(currentProcessEngine);
acquiredJobs = commandExecutor.execute(jobExecutor.getAcquireJobsCmd(numJobsToAcquire));
} else {
acquiredJobs = new AcquiredJobs(numJobsToAcquire);
}
context.submitAcquiredJobs(currentProcessEngine.getName(), acquiredJobs);
jobExecutor.logAcquiredJobs(currentProcessEngine, acquiredJobs.size());
jobExecutor.logAcquisitionFailureJobs(currentProcessEngine, acquiredJobs.getNumberOfJobsFailedToLock());
LOG.acquiredJobs(currentProcessEngine.getName(), acquiredJobs);
return acquiredJobs;
}
use of org.camunda.bpm.engine.impl.interceptor.CommandExecutor in project camunda-bpm-platform by camunda.
the class TimerEntity method preExecute.
@Override
protected void preExecute(CommandContext commandContext) {
if (getJobHandler() instanceof TimerEventJobHandler) {
TimerJobConfiguration configuration = (TimerJobConfiguration) getJobHandlerConfiguration();
if (repeat != null && !configuration.isFollowUpJobCreated()) {
// this timer is a repeating timer and
// a follow up timer job has not been scheduled yet
Date newDueDate = calculateRepeat();
if (newDueDate != null) {
// the listener is added to the transaction as SYNC on ROLLABCK,
// when it is necessary to schedule a new timer job invocation.
// If the transaction does not rollback, it is ignored.
ProcessEngineConfigurationImpl processEngineConfiguration = Context.getProcessEngineConfiguration();
CommandExecutor commandExecutor = processEngineConfiguration.getCommandExecutorTxRequiresNew();
RepeatingFailedJobListener listener = createRepeatingFailedJobListener(commandExecutor);
commandContext.getTransactionContext().addTransactionListener(TransactionState.ROLLED_BACK, listener);
// create a new timer job
createNewTimerJob(newDueDate);
}
}
}
}
use of org.camunda.bpm.engine.impl.interceptor.CommandExecutor in project camunda-bpm-platform by camunda.
the class HistoricIncidentAuthorizationTest method clearDatabase.
protected void clearDatabase() {
CommandExecutor commandExecutor = processEngineConfiguration.getCommandExecutorTxRequired();
commandExecutor.execute(new Command<Object>() {
public Object execute(CommandContext commandContext) {
commandContext.getHistoricJobLogManager().deleteHistoricJobLogsByHandlerType(TimerSuspendProcessDefinitionHandler.TYPE);
List<HistoricIncident> incidents = Context.getProcessEngineConfiguration().getHistoryService().createHistoricIncidentQuery().list();
for (HistoricIncident incident : incidents) {
commandContext.getHistoricIncidentManager().delete((HistoricIncidentEntity) incident);
}
return null;
}
});
}
use of org.camunda.bpm.engine.impl.interceptor.CommandExecutor in project camunda-bpm-platform by camunda.
the class ManagementServiceTest method deleteJobAndIncidents.
protected void deleteJobAndIncidents(final Job job) {
final List<HistoricIncident> incidents = historyService.createHistoricIncidentQuery().incidentType(Incident.FAILED_JOB_HANDLER_TYPE).list();
CommandExecutor commandExecutor = processEngineConfiguration.getCommandExecutorTxRequired();
commandExecutor.execute(new Command<Void>() {
@Override
public Void execute(CommandContext commandContext) {
((JobEntity) job).delete();
HistoricIncidentManager historicIncidentManager = commandContext.getHistoricIncidentManager();
for (HistoricIncident incident : incidents) {
HistoricIncidentEntity incidentEntity = (HistoricIncidentEntity) incident;
historicIncidentManager.delete(incidentEntity);
}
commandContext.getHistoricJobLogManager().deleteHistoricJobLogByJobId(job.getId());
return null;
}
});
}
use of org.camunda.bpm.engine.impl.interceptor.CommandExecutor in project camunda-bpm-platform by camunda.
the class ManagementServiceTest method createJob.
protected void createJob(final int retries, final String owner, final Date lockExpirationTime) {
CommandExecutor commandExecutor = processEngineConfiguration.getCommandExecutorTxRequired();
commandExecutor.execute(new Command<Void>() {
@Override
public Void execute(CommandContext commandContext) {
JobManager jobManager = commandContext.getJobManager();
MessageEntity job = new MessageEntity();
job.setJobHandlerType("any");
job.setLockOwner(owner);
job.setLockExpirationTime(lockExpirationTime);
job.setRetries(retries);
jobManager.send(job);
return null;
}
});
}
Aggregations