for activities with “asyncBefore = true” it is possible to specify the retry behaviour. Only after the max tries have failed will the engine create an incident.
Is it possible, inside a JavaDelegate, to get the number of tries left until the engine will vreate an incident? How?
Thank you for the hints.
Sure, you can specify a retry cycle form the modeler.
That would create a job with a certain retry cycle, why would you want to know within the JavaDelegate how many retries have been attempted?
I want to know how many tries are left. I’d like to catch any errors if it’s the last try so that no incident is created.
Have a look at this fail fast pattern…
Probably too late but here is what I used successfully:
Note: ManagementService is ProcessEngine’s ManagementService.
managementService.createJobQuery().activityId(<your activity Id here>)
.processInstanceId(<your process instance id here>).singleResult().getRetries();
How you can get activity Id and Process Instance Id from within the delegate?, here is how:
String currentActivityId = delegateExecution.getCurrentActivityId();
String processInstanceId = delegateExecution.getProcessInstanceId();