processEngineConfiguration.getEventDispatcher().addEventListener(listener, ActivitiEventType.JOB_EXECUTION_FAILURE);
ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("testSignal");
assertNotNull(processInstance);
Job signalJob = managementService.createJobQuery()
.processInstanceId(processInstance.getId())
.singleResult();
try {
managementService.executeJob(signalJob.getId());
fail("Exception expected");
} catch(ActivitiException ae) {
// Ignore, expected exception
}
Job failedJob = managementService.createJobQuery()
.withException()
.processInstanceId(processInstance.getId())
.singleResult();
assertNotNull(failedJob);
assertEquals(2, failedJob.getRetries());
// Three retries should each have triggered dispatching of a retry-decrement event
assertEquals(0, taskService.createTaskQuery().processInstanceId(processInstance.getId()).count());
try {
managementService.executeJob(failedJob.getId());
fail("Exception expected");
} catch(ActivitiException ae) {
// Ignore, expected exception
assertEquals(0, taskService.createTaskQuery().processInstanceId(processInstance.getId()).count());
}