jobManager.reschedule(historyCleanupJob, newDueDate); jobManager.insertAndHintJobExecutor(job); historyCleanupJobs.add(job); while (iterator.hasNext()) { JobEntity job = (JobEntity) iterator.next(); jobManager.deleteJob(job); iterator.remove();
protected JobEntity getJob() { return Context .getCommandContext() .getJobManager() .findJobById(jobId); }
public void deleteMonitorJob() { List<JobEntity> monitorJobs = Context.getCommandContext() .getJobManager() .findJobsByJobDefinitionId(monitorJobDefinitionId); for (JobEntity monitorJob : monitorJobs) { monitorJob.delete(); } }
public void updateJobSuspensionStateById(String jobId, SuspensionState suspensionState) { Map<String, Object> parameters = new HashMap<String, Object>(); parameters.put("jobId", jobId); parameters.put("suspensionState", suspensionState.getStateCode()); getDbEntityManager().update(JobEntity.class, "updateJobSuspensionStateByParameters", configureParameterizedQuery(parameters)); }
public Object execute(CommandContext commandContext) { JobEntity job = commandContext.getJobManager().findJobById(jobId); if (job != null) { commandContext.getJobManager().delete(job); } return null; } });
public void deleteJob(JobEntity job) { deleteJob(job, true); }
@Override public List<JobEntity> execute(CommandContext commandContext) { return commandContext .getJobManager() .findNextJobsToExecute(new Page(0, 100)); } });
protected void scheduleEventAsync(Object payload, Object payloadLocal, String businessKey) { EventSubscriptionJobDeclaration asyncDeclaration = getJobDeclaration(); if (asyncDeclaration == null) { // fallback to sync if we couldn't find a job declaration processEventSync(payload, payloadLocal, businessKey); } else { MessageEntity message = asyncDeclaration.createJobInstance(this); CommandContext commandContext = Context.getCommandContext(); commandContext.getJobManager().send(message); } }
public JobEntity createSeedJob() { JobEntity seedJob = BATCH_SEED_JOB_DECLARATION.createJobInstance(this); Context.getCommandContext().getJobManager().insertAndHintJobExecutor(seedJob); return seedJob; }
protected void scheduleTimer(TimerEntity timer) { Context .getCommandContext() .getJobManager() .schedule(timer); }
protected List<JobEntity> fetchJobs(CommandContext commandContext, String processInstanceId) { return commandContext.getJobManager().findJobsByProcessInstanceId(processInstanceId); }
public Void execute(CommandContext commandContext) { JobManager jobManager = commandContext.getJobManager(); jobManager.send(createTweetMessage("message-one")); jobManager.send(createTweetMessage("message-two")); jobManager.send(createTweetMessage("message-three")); jobManager.send(createTweetMessage("message-four")); jobManager.schedule(createTweetTimer("timer-one", new Date())); jobManager.schedule(createTweetTimer("timer-two", new Date())); return null; } });
public Void execute(CommandContext commandContext) { JobManager jobManager = commandContext.getJobManager(); List<JobEntity> executableJobs = jobManager.findNextJobsToExecute(new Page(0, 1)); assertEquals(1, executableJobs.size()); assertEquals(myCustomTimerEntity, executableJobs.get(0).getJobHandlerConfigurationRaw()); assertEquals(SuspensionState.ACTIVE.getStateCode(), executableJobs.get(0).getSuspensionState()); executableJobs = jobManager.findJobsByProcessInstanceId(processInstanceId); assertEquals(1, executableJobs.size()); assertEquals(myCustomTimerEntity, executableJobs.get(0).getJobHandlerConfigurationRaw()); assertEquals(SuspensionState.ACTIVE.getStateCode(), executableJobs.get(0).getSuspensionState()); return null; } });
protected void hintJobExecutor(JobEntity job) { JobExecutor jobExecutor = Context.getProcessEngineConfiguration().getJobExecutor(); if (!jobExecutor.isActive()) { return; } JobExecutorContext jobExecutorContext = Context.getJobExecutorContext(); TransactionListener transactionListener = null; if(!job.isSuspended() && job.isExclusive() && jobExecutorContext != null && jobExecutorContext.isExecutingExclusiveJob() && areInSameProcessInstance(job, jobExecutorContext.getCurrentJob())) { // lock job & add to the queue of the current processor Date currentTime = ClockUtil.getCurrentTime(); job.setLockExpirationTime(new Date(currentTime.getTime() + jobExecutor.getLockTimeInMillis())); job.setLockOwner(jobExecutor.getLockOwner()); transactionListener = new ExclusiveJobAddedNotification(job.getId(), jobExecutorContext); } else { // notify job executor: transactionListener = new MessageAddedNotification(jobExecutor); } Context.getCommandContext() .getTransactionContext() .addTransactionListener(TransactionState.COMMITTED, transactionListener); }
public void updateJobSuspensionStateByProcessDefinitionKey(String processDefinitionKey, SuspensionState suspensionState) { Map<String, Object> parameters = new HashMap<String, Object>(); parameters.put("processDefinitionKey", processDefinitionKey); parameters.put("isProcessDefinitionTenantIdSet", false); parameters.put("suspensionState", suspensionState.getStateCode()); getDbEntityManager().update(JobEntity.class, "updateJobSuspensionStateByParameters", configureParameterizedQuery(parameters)); }
public Void execute(CommandContext commandContext) { commandContext.getJobManager().deleteJob((JobEntity) job); return null; } });
@Override public List<JobEntity> execute(CommandContext commandContext) { return commandContext .getJobManager() .findNextJobsToExecute(new Page(0, 100)); } });
protected void scheduleEventAsync(Object payload, Object payloadLocal, String businessKey) { EventSubscriptionJobDeclaration asyncDeclaration = getJobDeclaration(); if (asyncDeclaration == null) { // fallback to sync if we couldn't find a job declaration processEventSync(payload, payloadLocal, businessKey); } else { MessageEntity message = asyncDeclaration.createJobInstance(this); CommandContext commandContext = Context.getCommandContext(); commandContext.getJobManager().send(message); } }
public JobEntity createSeedJob() { JobEntity seedJob = BATCH_SEED_JOB_DECLARATION.createJobInstance(this); Context.getCommandContext().getJobManager().insertAndHintJobExecutor(seedJob); return seedJob; }
protected void scheduleTimer(TimerEntity timer) { Context .getCommandContext() .getJobManager() .schedule(timer); }