private BpmnModelInstance prepareFailingServiceTask() { BpmnModelInstance modelInstance = Bpmn.createExecutableProcess(PROCESS_ID) .startEvent() .serviceTask() .camundaClass(FAILING_CLASS) .camundaAsyncBefore() .endEvent() .done(); return modelInstance; }
private BpmnModelInstance prepareProcessFailingServiceTask() { BpmnModelInstance modelInstance = Bpmn.createExecutableProcess(PROCESS_ID) .startEvent() .serviceTask() .camundaClass(FAILING_CLASS) .camundaAsyncBefore() .endEvent() .done(); return modelInstance; }
public void testPropagateTenantIdToFailedJobIncident() { deploymentForTenant(TENANT_ID, Bpmn.createExecutableProcess(PROCESS_DEFINITION_KEY) .startEvent() .serviceTask() .camundaExpression("${failing}") .camundaAsyncBefore() .endEvent() .done()); startProcessInstance(PROCESS_DEFINITION_KEY); executeAvailableJobs(); Incident incident = runtimeService.createIncidentQuery().singleResult(); assertThat(incident, is(notNullValue())); // inherit the tenant id from execution assertThat(incident.getTenantId(), is(TENANT_ID)); }
protected BpmnModelInstance createFailingProcess() { return Bpmn.createExecutableProcess("Process") .startEvent() .serviceTask("failing") .camundaAsyncAfter() .camundaAsyncBefore() .camundaClass(FailingDelegate.class) .endEvent() .done(); }
private BpmnModelInstance prepareFailingServiceTaskWithRetryCycle() { BpmnModelInstance modelInstance = Bpmn.createExecutableProcess(PROCESS_ID) .startEvent() .serviceTask() .camundaClass(FAILING_CLASS) .camundaAsyncBefore() .camundaFailedJobRetryTimeCycle("R10/PT5M") .endEvent() .done(); return modelInstance; }
protected BpmnModelInstance createFailingProcess() { return Bpmn.createExecutableProcess("Process") .startEvent() .serviceTask("failing") .camundaAsyncAfter() .camundaAsyncBefore() .camundaClass(FailingDelegate.class) .endEvent() .done(); }
private BpmnModelInstance prepareProcessFailingServiceTaskWithRetryCycle(String retryTimeCycle) { BpmnModelInstance modelInstance = Bpmn.createExecutableProcess(PROCESS_ID) .startEvent() .serviceTask() .camundaClass(FAILING_CLASS) .camundaAsyncBefore() .camundaFailedJobRetryTimeCycle(retryTimeCycle) .endEvent() .done(); return modelInstance; }
@Test public void dontSetAuthenticatedTenantForJobWithoutTenant() { testRule.deploy(Bpmn.createExecutableProcess("process") .startEvent() .serviceTask() .camundaAsyncBefore() .camundaClass(AssertingJavaDelegate.class.getName()) .endEvent() .done()); ProcessInstance processInstance = engineRule.getRuntimeService().startProcessInstanceByKey("process"); AssertingJavaDelegate.addAsserts(hasNoAuthenticatedTenantId()); testRule.waitForJobExecutorToProcessAllJobs(); testRule.assertProcessEnded(processInstance.getId()); }
@Test public void setAuthenticatedTenantForAsyncJob() { testRule.deployForTenant(TENANT_ID, Bpmn.createExecutableProcess("process") .startEvent() .serviceTask() .camundaAsyncBefore() .camundaClass(AssertingJavaDelegate.class.getName()) .endEvent() .done()); ProcessInstance processInstance = engineRule.getRuntimeService().startProcessInstanceByKey("process"); AssertingJavaDelegate.addAsserts(hasAuthenticatedTenantId(TENANT_ID)); testRule.waitForJobExecutorToProcessAllJobs(); testRule.assertProcessEnded(processInstance.getId()); }
@Test public void dontSetAuthenticatedTenantWhileManualJobExecution() { testRule.deployForTenant(TENANT_ID, Bpmn.createExecutableProcess("process") .startEvent() .serviceTask() .camundaAsyncBefore() .camundaClass(AssertingJavaDelegate.class.getName()) .endEvent() .done()); ProcessInstance processInstance = engineRule.getRuntimeService().startProcessInstanceByKey("process"); AssertingJavaDelegate.addAsserts(hasNoAuthenticatedTenantId()); testRule.executeAvailableJobs(); testRule.assertProcessEnded(processInstance.getId()); }
private BpmnModelInstance prepareFailingSubProcess() { BpmnModelInstance bpmnModelInstance = Bpmn.createExecutableProcess(PROCESS_ID) .startEvent() .subProcess() .embeddedSubProcess() .startEvent() .serviceTask() .camundaClass(FAILING_CLASS) .camundaAsyncBefore() .endEvent() .subProcessDone() .endEvent() .done(); return bpmnModelInstance; } }
@Test public void testRetryGlobalConfigurationWithExecutionListener() throws ParseException { // given engineRule.getProcessEngineConfiguration().setFailedJobRetryTimeCycle("PT5M"); BpmnModelInstance bpmnModelInstance = Bpmn.createExecutableProcess(PROCESS_ID) .startEvent() .serviceTask() .camundaClass(FAILING_CLASS) .camundaAsyncBefore() .camundaExecutionListenerClass(RecorderExecutionListener.EVENTNAME_START, RecorderExecutionListener.class.getName()) .endEvent() .done(); testRule.deploy(bpmnModelInstance); ClockUtil.setCurrentTime(SIMPLE_DATE_FORMAT.parse("2017-01-01T09:55:00")); ProcessInstance pi = runtimeService.startProcessInstanceByKey(PROCESS_ID); Date currentTime = SIMPLE_DATE_FORMAT.parse("2017-01-01T10:00:00"); ClockUtil.setCurrentTime(currentTime); String processInstanceId = pi.getProcessInstanceId(); int jobRetries = executeJob(processInstanceId); assertEquals(1, jobRetries); currentTime = DateUtils.addMinutes(currentTime, 5); assertLockExpirationTime(currentTime); ClockUtil.setCurrentTime(currentTime); jobRetries = executeJob(processInstanceId); assertEquals(0, jobRetries); }
@Test public void testCompetingJobExecutionDeleteJobDuringExecution() { //given a simple process with a async service task testRule.deploy(Bpmn .createExecutableProcess("process") .startEvent() .serviceTask("task") .camundaAsyncBefore() .camundaExpression("${true}") .endEvent() .done()); runtimeService.startProcessInstanceByKey("process"); Job currentJob = managementService.createJobQuery().singleResult(); // when a job is executed JobExecutionThread threadOne = new JobExecutionThread(currentJob.getId()); threadOne.startAndWaitUntilControlIsReturned(); //and deleted in parallel managementService.deleteJob(currentJob.getId()); // then the job fails with a OLE and the failed job listener throws no NPE LOG.debug("test thread notifies thread 1"); threadOne.proceedAndWaitTillDone(); assertTrue(threadOne.exception instanceof OptimisticLockingException); }
public void testFailingTransactionListener() { deployment(Bpmn.createExecutableProcess("testProcess") .startEvent() .serviceTask() .camundaClass(FailingTransactionListenerDelegate.class.getName()) .camundaAsyncBefore() .endEvent() .done()); runtimeService.startProcessInstanceByKey("testProcess"); // there should be 1 job created: Job job = managementService.createJobQuery().singleResult(); assertNotNull(job); // with 3 retries assertEquals(3, job.getRetries()); // if we execute the job waitForJobExecutorToProcessAllJobs(6000); // the job is still present job = managementService.createJobQuery().singleResult(); assertNotNull(job); // but has no more retires assertEquals(0, job.getRetries()); assertEquals("exception in transaction listener", job.getExceptionMessage()); String stacktrace = managementService.getJobExceptionStacktrace(job.getId()); assertNotNull(stacktrace); assertTrue("unexpected stacktrace, was <" + stacktrace + ">", stacktrace.contains("java.lang.RuntimeException: exception in transaction listener")); }
@Test public void testFailedCallActivity() { testRule.deploy( Bpmn.createExecutableProcess(PROCESS_ID) .startEvent() .callActivity() .calledElement("testProcess2") .endEvent() .done(), Bpmn.createExecutableProcess("testProcess2") .startEvent() .serviceTask() .camundaClass(FAILING_CLASS) .camundaAsyncBefore() .endEvent() .done()); ProcessInstance pi = runtimeService.startProcessInstanceByKey("testProcess2"); assertJobRetries(pi, 4); }
public void testFailedJobRetryTimeCycleWithUndefinedVar() { BpmnModelInstance bpmnModelInstance = Bpmn.createExecutableProcess("process") .startEvent() .serviceTask() .camundaClass("foo") .camundaAsyncBefore() .camundaFailedJobRetryTimeCycle("${var}") .endEvent() .done(); deployment(bpmnModelInstance); runtimeService.startProcessInstanceByKey("process"); Job job = managementService.createJobQuery().singleResult(); // when job fails try { managementService.executeJob(job.getId()); } catch (Exception e) { // ignore } // then job = managementService.createJobQuery().singleResult(); Assert.assertEquals(2, job.getRetries()); // default behaviour }
public void testFailedJobRetryTimeCycleWithExpression() { BpmnModelInstance bpmnModelInstance = Bpmn.createExecutableProcess("process") .startEvent() .serviceTask() .camundaClass("foo") .camundaAsyncBefore() .camundaFailedJobRetryTimeCycle("${var}") .endEvent() .done(); deployment(bpmnModelInstance); runtimeService.startProcessInstanceByKey("process", Variables.createVariables().putValue("var", "R10/PT5M")); Job job = managementService.createJobQuery().singleResult(); // when job fails try { managementService.executeJob(job.getId()); } catch (Exception e) { // ignore } // then job = managementService.createJobQuery().singleResult(); Assert.assertEquals(9, job.getRetries()); }
.serviceTask("task1") .camundaExpression("${true}") .camundaAsyncBefore() .serviceTask("task2") .camundaExpression("${true}") .camundaAsyncBefore() .endEvent() .done());
@Test public void testFailMigrateFailedJobIncident() { // given BpmnModelInstance model = ProcessModels.newModel() .startEvent() .serviceTask("serviceTask") .camundaAsyncBefore() .camundaClass(AlwaysFailingDelegate.class.getName()) .endEvent() .done(); ProcessDefinition sourceProcessDefinition = testHelper.deployAndGetDefinition(model); ProcessDefinition targetProcessDefinition = testHelper.deployAndGetDefinition(modify(model).changeElementId("serviceTask", "newServiceTask")); MigrationPlan migrationPlan = rule.getRuntimeService() .createMigrationPlan(sourceProcessDefinition.getId(), targetProcessDefinition.getId()) .mapEqualActivities() .build(); String processInstanceId = rule.getRuntimeService().startProcessInstanceById(sourceProcessDefinition.getId()).getId(); testHelper.executeAvailableJobs(); // when try { rule.getRuntimeService().newMigration(migrationPlan) .processInstanceIds(processInstanceId) .execute(); Assert.fail("should fail"); } catch (MigratingProcessInstanceValidationException e) { // then Assert.assertTrue(e instanceof MigratingProcessInstanceValidationException); } }
.startEvent() .serviceTask("serviceTask") .camundaAsyncBefore() .camundaClass(SignallableServiceTaskDelegate.class.getName()) .endEvent()