Greets! I’ve got a very simple process which consists of a single service task with custom retry configuration (infinite number of retries with 1 minute intervals) and async before flag:
@Slf4j
@Component
public class PrintHelloDelegate implements JavaDelegate {
@Override
public void execute(DelegateExecution execution) throws Exception {
log.info("Hello!");
throw new RuntimeException();
}
}
It’s all good and works as expected, the next thing I’m trying to achieve is to cause an incident under certain circumstances. Say I have a particular case when retrying is useless and I just want to trigger an incident and see a red token on that task in Cockpit with no further retries.
I’ve tried setting job retries to zero before throwing an exception:
Job currentJob = managementService.createJobQuery()
.processInstanceId(execution.getProcessInstanceId())
.singleResult();
managementService.setJobRetries(currentJob.getId(), 0);
// proceed to throw an exception
But it seems to completely ignore job retries set to 0 and keeps retrying starting with Integer.MAX_VALUE
retries left
I also played around org.camunda.bpm.engine.RuntimeService#createIncident, which just gives me an instance of org.camunda.bpm.engine.runtime.Incident class and still nothing happens:
Incident failedJob = execution.getProcessEngineServices()
.getRuntimeService()
.createIncident("failedJob", execution.getProcessInstanceId(), execution.getId(), "some message");
I feel like I am probably missing something, any advice is appreciated. I am using Camunda 7.19 in Spring Boot environment, no fancy configs, just a Get started with Camunda and the Spring Boot | docs.camunda.org project.