use of org.camunda.bpm.engine.impl.persistence.entity.JobEntity in project camunda-bpm-platform by camunda.
the class DeploymentAwareJobExecutorTest method testIntermediateTimerEvent.
@Deployment(resources = "org/camunda/bpm/engine/test/jobexecutor/processWithTimerCatch.bpmn20.xml")
public void testIntermediateTimerEvent() {
runtimeService.startProcessInstanceByKey("testProcess");
Set<String> registeredDeployments = processEngineConfiguration.getRegisteredDeployments();
Job existingJob = managementService.createJobQuery().singleResult();
ClockUtil.setCurrentTime(new Date(System.currentTimeMillis() + 61 * 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 testExecuteExclusiveFollowUpJobInDifferentProcessInstance.
@Test
public void testExecuteExclusiveFollowUpJobInDifferentProcessInstance() {
testHelper.deploy(CALL_ACTIVITY_PROCESS, ONE_TASK_PROCESS);
// given
// a process instance with a single job
ProcessInstance processInstance = engineRule.getRuntimeService().startProcessInstanceByKey("callActivityProcess");
jobExecutor.start();
// and first job acquisition that acquires the job
acquisitionThread.waitForSync();
acquisitionThread.makeContinueAndWaitForSync();
// and job is executed
acquisitionThread.makeContinueAndWaitForSync();
// then
// the called instance has been created
ProcessInstance calledInstance = engineRule.getRuntimeService().createProcessInstanceQuery().superProcessInstanceId(processInstance.getId()).singleResult();
Assert.assertNotNull(calledInstance);
// and there is a transition instance for the service task
ActivityInstance activityInstance = engineRule.getRuntimeService().getActivityInstance(calledInstance.getId());
Assert.assertEquals(1, activityInstance.getTransitionInstances("serviceTask").length);
// but the corresponding job is not locked
JobEntity followUpJob = (JobEntity) engineRule.getManagementService().createJobQuery().singleResult();
Assert.assertNotNull(followUpJob);
Assert.assertNull(followUpJob.getLockOwner());
Assert.assertNull(followUpJob.getLockExpirationTime());
}
use of org.camunda.bpm.engine.impl.persistence.entity.JobEntity in project camunda-bpm-platform by camunda.
the class JobEntityTest method testInsertJobWithExceptionMessage.
/**
* Note: This does not test a message with 4-byte Unicode supplementary
* characters for two reasons:
* - MySQL 5.1 does not support 4-byte supplementary characters (support from 5.5.3 onwards)
* - {@link String#length()} counts these characters twice (since they are represented by two
* chars), so essentially the cutoff would be half the actual cutoff for such a string
*/
public void testInsertJobWithExceptionMessage() {
String fittingThreeByteMessage = repeatCharacter("\u9faf", JobEntity.MAX_EXCEPTION_MESSAGE_LENGTH);
JobEntity threeByteJobEntity = new MessageEntity();
threeByteJobEntity.setExceptionMessage(fittingThreeByteMessage);
// should not fail
insertJob(threeByteJobEntity);
deleteJob(threeByteJobEntity);
}
use of org.camunda.bpm.engine.impl.persistence.entity.JobEntity in project camunda-bpm-platform by camunda.
the class DeleteProcessInstancesJobHandler method createJobEntities.
protected void createJobEntities(BatchEntity batch, DeleteProcessInstanceBatchConfiguration configuration, String deploymentId, List<String> processInstancesToHandle, int invocationsPerBatchJob) {
CommandContext commandContext = Context.getCommandContext();
ByteArrayManager byteArrayManager = commandContext.getByteArrayManager();
JobManager jobManager = commandContext.getJobManager();
int createdJobs = 0;
while (!processInstancesToHandle.isEmpty()) {
int lastIdIndex = Math.min(invocationsPerBatchJob, processInstancesToHandle.size());
// view of process instances for this job
List<String> idsForJob = processInstancesToHandle.subList(0, lastIdIndex);
DeleteProcessInstanceBatchConfiguration jobConfiguration = createJobConfiguration(configuration, idsForJob);
ByteArrayEntity configurationEntity = saveConfiguration(byteArrayManager, jobConfiguration);
JobEntity job = createBatchJob(batch, configurationEntity);
job.setDeploymentId(deploymentId);
jobManager.insertAndHintJobExecutor(job);
createdJobs++;
idsForJob.clear();
}
// update created jobs for batch
batch.setJobsCreated(batch.getJobsCreated() + createdJobs);
// update batch configuration
batch.setConfigurationBytes(writeConfiguration(configuration));
}
use of org.camunda.bpm.engine.impl.persistence.entity.JobEntity in project camunda-bpm-platform by camunda.
the class AbstractBatchJobHandler method createJobs.
@Override
public boolean createJobs(BatchEntity batch) {
CommandContext commandContext = Context.getCommandContext();
ByteArrayManager byteArrayManager = commandContext.getByteArrayManager();
JobManager jobManager = commandContext.getJobManager();
T configuration = readConfiguration(batch.getConfigurationBytes());
int batchJobsPerSeed = batch.getBatchJobsPerSeed();
int invocationsPerBatchJob = batch.getInvocationsPerBatchJob();
List<String> ids = configuration.getIds();
int numberOfItemsToProcess = Math.min(invocationsPerBatchJob * batchJobsPerSeed, ids.size());
// view of process instances to process
List<String> processIds = ids.subList(0, numberOfItemsToProcess);
int createdJobs = 0;
while (!processIds.isEmpty()) {
int lastIdIndex = Math.min(invocationsPerBatchJob, processIds.size());
// view of process instances for this job
List<String> idsForJob = processIds.subList(0, lastIdIndex);
T jobConfiguration = createJobConfiguration(configuration, idsForJob);
ByteArrayEntity configurationEntity = saveConfiguration(byteArrayManager, jobConfiguration);
JobEntity job = createBatchJob(batch, configurationEntity);
postProcessJob(configuration, job);
jobManager.insertAndHintJobExecutor(job);
idsForJob.clear();
createdJobs++;
}
// update created jobs for batch
batch.setJobsCreated(batch.getJobsCreated() + createdJobs);
// update batch configuration
batch.setConfigurationBytes(writeConfiguration(configuration));
return ids.isEmpty();
}
Aggregations