public static boolean areJobsAvailable(ManagementService managementService) { return !managementService.createJobQuery().list().isEmpty(); }
@Override public Job getJob(String processInstanceId) { return managementService.createJobQuery().processInstanceId(processInstanceId).singleResult(); }
/** * This method tests the timer execution in a workflow. */ @Test public void testTimerJob() throws Exception { // Create and start the workflow. jobDefinitionServiceTestHelper.createJobDefinition(ACTIVITI_XML_HERD_TIMER_WITH_CLASSPATH); Job job = jobService.createAndStartJob(jobServiceTestHelper.createJobCreateRequest(TEST_ACTIVITI_NAMESPACE_CD, TEST_ACTIVITI_JOB_NAME)); assertNotNull(job); // This workflow would normally automatically start a timer which would eventually complete the workflow, however, since // this test method is running within our own transaction, the timer would never go off since it is run in a different thread which is outside of // our transaction which didn't commit yet. As a result, we need to manually run the timer job to simulate what would happen if the timer // went off by itself. org.activiti.engine.runtime.Job timer = activitiManagementService.createJobQuery().processInstanceId(job.getId()).timers().singleResult(); if (timer != null) { activitiManagementService.executeJob(timer.getId()); } }
@Override public List<Job> getJobsWithExceptionByProcessInstanceId(String processInstanceId) { return activitiManagementService.createJobQuery().withException().processInstanceId(processInstanceId).list(); }
private void waitForTimersToBeExecuted(String workflowInstanceId) throws Exception { String processInstanceId = BPMEngineRegistry.getLocalId(workflowInstanceId); // Job-executor should finish the job, no timers should be available for WF List<Job> timers = null; int numberOfRetries = 5; for (int i=0; i< numberOfRetries; i++) { Thread.sleep(1500); timers = activitiProcessEngine.getManagementService().createJobQuery() .timers() .processInstanceId(processInstanceId) .list(); if (timers.size() == 0) { break; } } if(timers.size() > 0) { fail("There are still timers available for the process: " + processInstanceId); } }
query.jobId(allRequestParams.get("id")); query.processInstanceId(allRequestParams.get("processInstanceId")); query.executionId(allRequestParams.get("executionId")); query.processDefinitionId(allRequestParams.get("processDefinitionId")); query.timers(); query.messages(); query.duedateLowerThan(RequestUtil.getDate(allRequestParams, "dueBefore")); query.duedateHigherThan(RequestUtil.getDate(allRequestParams, "dueAfter")); query.withException(); query.exceptionMessage(allRequestParams.get("exceptionMessage")); query.jobTenantId(allRequestParams.get("tenantId")); query.jobTenantIdLike(allRequestParams.get("tenantIdLike")); query.jobWithoutTenantId(); query.locked(); query.unlocked();
@Override public long getJobsWithExceptionCountByProcessInstanceId(String processInstanceId) { return activitiManagementService.createJobQuery().withException().processInstanceId(processInstanceId).count(); }
public List<Item> loadItems(int start, int count) { List<Job> jobs = managementService.createJobQuery() .orderByJobDuedate().asc() .orderByJobId().asc() .list(); List<Item> items = new ArrayList<Item>(); for (Job job : jobs) { items.add(new JobListItem(job)); } return items; }
public Item loadSingleResult(String id) { Job job = managementService.createJobQuery().jobId(id).singleResult(); if (job != null) { return new JobListItem(job); } return null; }
.createJobQuery().processDefinitionId(processDefinition.getId()).list(); for (Job job : jobs) {
protected void initSuspensionStateInformation() { List<Job> jobs = managementService.createJobQuery() .processDefinitionId(processDefinition.getId()).orderByJobDuedate().asc().list(); List<JobEntity> suspensionStateJobs = new ArrayList<JobEntity>();
public boolean areJobsAvailable() { return !managementService .createJobQuery() .executable() .list() .isEmpty(); }
activitiManagementService.createJobQuery().executionId(processInstance.getProcessInstanceId()).singleResult().getExceptionMessage());
public int size() { return (int) managementService.createJobQuery().count(); }
/** * This method tests the scenario when an error that is not workflow related is throws while workflow is executing an Async type task like Timer. This error * is logged as ERROR. */ @Test(expected = ActivitiException.class) public void testActivitiReportableError() throws Exception { BpmnModel bpmnModel = getBpmnModelForXmlResource(ACTIVITI_XML_HERD_TIMER_WITH_CLASSPATH); ServiceTask serviceTask = (ServiceTask) bpmnModel.getProcesses().get(0).getFlowElement("servicetask1"); FieldExtension exceptionField = new FieldExtension(); exceptionField.setFieldName("exceptionToThrow"); exceptionField.setExpression("${exceptionToThrow}"); serviceTask.getFieldExtensions().add(exceptionField); jobDefinitionServiceTestHelper.createJobDefinitionForActivitiXml(getActivitiXmlFromBpmnModel(bpmnModel)); List<Parameter> parameters = new ArrayList<>(); Parameter parameter = new Parameter("exceptionToThrow", MockJavaDelegate.EXCEPTION_BPMN_ERROR); parameters.add(parameter); Job job = jobService.createAndStartJob(jobServiceTestHelper.createJobCreateRequest(TEST_ACTIVITI_NAMESPACE_CD, TEST_ACTIVITI_JOB_NAME, parameters)); org.activiti.engine.runtime.Job timer = activitiManagementService.createJobQuery().processInstanceId(job.getId()).timers().singleResult(); if (timer != null) { executeWithoutLogging(Arrays.asList(ActivitiRuntimeHelper.class, TimerExecuteNestedActivityJobHandler.class), () -> { activitiManagementService.executeJob(timer.getId()); }); } }
@Override public List<Job> getJobsWithExceptionByProcessInstanceId(String processInstanceId) { return activitiManagementService.createJobQuery().withException().processInstanceId(processInstanceId).list(); }
.processInstanceId(processInstanceId) .timers() .list();
@Override public long getJobsWithExceptionCountByProcessInstanceId(String processInstanceId) { return activitiManagementService.createJobQuery().withException().processInstanceId(processInstanceId).count(); }
@ApiOperation(value = "Get a single job", tags = {"Jobs"}) @ApiResponses(value = { @ApiResponse(code = 200, message = "Indicates the job exists and is returned."), @ApiResponse(code = 404, message = "Indicates the requested job does not exist.") }) @RequestMapping(value = "/management/jobs/{jobId}", method = RequestMethod.GET, produces = "application/json") public JobResponse getJob(@ApiParam(name = "jobId", value="The id of the job to get.") @PathVariable String jobId, HttpServletRequest request) { Job job = managementService.createJobQuery().jobId(jobId).singleResult(); if (job == null) { throw new ActivitiObjectNotFoundException("Could not find a job with id '" + jobId + "'.", Job.class); } return restResponseFactory.createJobResponse(job); }
.createJobQuery().processDefinitionId(processDefinition.getId()).list(); for (Job job : jobs) {