use of org.camunda.bpm.engine.impl.persistence.entity.JobEntity in project camunda-bpm-platform by camunda.
the class AcquireJobCmdUnitTest method exclusiveJobsDifferentInstance.
@Test
public void exclusiveJobsDifferentInstance() {
// given: two exclusive jobs for a different process instance
JobEntity job1 = createExclusiveJob(JOB_ID_1, PROCESS_INSTANCE_ID_1);
JobEntity job2 = createExclusiveJob(JOB_ID_2, PROCESS_INSTANCE_ID_2);
// when the job executor acquire new jobs
when(jobManager.findNextJobsToExecute(any(Page.class))).thenReturn(Arrays.asList(job1, job2));
// then the job executor should acquire job1 and job 2 in different batches
checkThatAcquiredJobsInDifferentBatches();
}
use of org.camunda.bpm.engine.impl.persistence.entity.JobEntity in project camunda-bpm-platform by camunda.
the class AcquireJobCmdUnitTest method createNonExclusiveJob.
protected JobEntity createNonExclusiveJob(String id, String processInstanceId) {
JobEntity job = mock(JobEntity.class);
when(job.getId()).thenReturn(id);
when(job.getProcessInstanceId()).thenReturn(processInstanceId);
return job;
}
use of org.camunda.bpm.engine.impl.persistence.entity.JobEntity in project camunda-bpm-platform by camunda.
the class DeploymentAwareJobExecutorTest method testTimerStartEvent.
@Deployment(resources = "org/camunda/bpm/engine/test/jobexecutor/processWithTimerStart.bpmn20.xml")
public void testTimerStartEvent() {
Set<String> registeredDeployments = processEngineConfiguration.getRegisteredDeployments();
Job existingJob = managementService.createJobQuery().singleResult();
ClockUtil.setCurrentTime(new Date(System.currentTimeMillis() + 1000));
List<JobEntity> acquirableJobs = findAcquirableJobs();
assertEquals(1, acquirableJobs.size());
assertEquals(existingJob.getId(), acquirableJobs.get(0).getId());
registeredDeployments.clear();
acquirableJobs = findAcquirableJobs();
assertEquals(0, acquirableJobs.size());
}
use of org.camunda.bpm.engine.impl.persistence.entity.JobEntity in project camunda-bpm-platform by camunda.
the class JobExecutorFollowUpTest method testExecuteExclusiveFollowUpJobInSameProcessInstance.
@Test
public void testExecuteExclusiveFollowUpJobInSameProcessInstance() {
testHelper.deploy(TWO_TASKS_PROCESS);
// given
// a process instance with a single job
ProcessInstance processInstance = engineRule.getRuntimeService().startProcessInstanceByKey("process");
jobExecutor.start();
// and first job acquisition that acquires the job
acquisitionThread.waitForSync();
acquisitionThread.makeContinueAndWaitForSync();
// and first job execution
acquisitionThread.makeContinue();
// waiting inside delegate
executionThread.waitForSync();
// completing delegate
executionThread.makeContinueAndWaitForSync();
// then
// the follow-up job should be executed right away
// i.e., there is a transition instance for the second service task
ActivityInstance activityInstance = engineRule.getRuntimeService().getActivityInstance(processInstance.getId());
Assert.assertEquals(1, activityInstance.getTransitionInstances("serviceTask2").length);
// and the corresponding job is locked
JobEntity followUpJob = (JobEntity) engineRule.getManagementService().createJobQuery().singleResult();
Assert.assertNotNull(followUpJob);
Assert.assertNotNull(followUpJob.getLockOwner());
Assert.assertNotNull(followUpJob.getLockExpirationTime());
// and the job can be completed successfully such that the process instance ends
executionThread.makeContinue();
acquisitionThread.waitForSync();
// and the process instance has finished
testHelper.assertProcessEnded(processInstance.getId());
}
use of org.camunda.bpm.engine.impl.persistence.entity.JobEntity in project camunda-bpm-platform by camunda.
the class JobExecutorAcquireJobsByDueDateTest method testOldJobsArePreferred.
@Test
@Deployment(resources = { "org/camunda/bpm/engine/test/jobexecutor/simpleAsyncProcess.bpmn20.xml", "org/camunda/bpm/engine/test/jobexecutor/processWithTimerCatch.bpmn20.xml" })
public void testOldJobsArePreferred() {
// first start process with timer job
ProcessInstance timerProcess1 = runtimeService.startProcessInstanceByKey("testProcess");
// then start process with async task
incrementClock(1);
ProcessInstance asyncProcess1 = runtimeService.startProcessInstanceByKey("simpleAsyncProcess");
// then start process with timer job
incrementClock(1);
ProcessInstance timerProcess2 = runtimeService.startProcessInstanceByKey("testProcess");
// and another process with async task after the timers are acquirable
incrementClock(61);
ProcessInstance asyncProcess2 = runtimeService.startProcessInstanceByKey("simpleAsyncProcess");
Job timerJob1 = managementService.createJobQuery().processInstanceId(timerProcess1.getId()).singleResult();
Job timerJob2 = managementService.createJobQuery().processInstanceId(timerProcess2.getId()).singleResult();
Job messageJob1 = managementService.createJobQuery().processInstanceId(asyncProcess1.getId()).singleResult();
Job messageJob2 = managementService.createJobQuery().processInstanceId(asyncProcess2.getId()).singleResult();
assertNotNull(timerJob1.getDuedate());
assertNotNull(timerJob2.getDuedate());
assertNotNull(messageJob1.getDuedate());
assertNotNull(messageJob2.getDuedate());
assertTrue(messageJob1.getDuedate().before(timerJob1.getDuedate()));
assertTrue(timerJob1.getDuedate().before(timerJob2.getDuedate()));
assertTrue(timerJob2.getDuedate().before(messageJob2.getDuedate()));
List<JobEntity> acquirableJobs = findAcquirableJobs();
assertEquals(4, acquirableJobs.size());
assertEquals(messageJob1.getId(), acquirableJobs.get(0).getId());
assertEquals(timerJob1.getId(), acquirableJobs.get(1).getId());
assertEquals(timerJob2.getId(), acquirableJobs.get(2).getId());
assertEquals(messageJob2.getId(), acquirableJobs.get(3).getId());
}
Aggregations