How do I set the retries of an external-task for a service task

I’m using the Camunda BPM REST API to implement a service task (worker) using the external-task functionality (Fetch and Lock External Tasks | docs.camunda.org). This provides a field called ‘retries’ that you can decrement if you ‘fail’ the task. But how do I set that initially e.g. to 3, it looks like you can do this in the Zeebe modeller but I can’t see the same option in the Camunda BPM modeller (v3.7.1)?

Thanks,
Andrew

Hi @sesameburt,

you cannot set the initial number of retries in the bpmn model. You have to set them in the handler of the external task in the external task worker. Could be something like (it’s pseudocode):

if (externaltask.getRetries() is null) {
   retries = 3;
} else {
   retries = externaltask.getRetries() - 1;
}
externaltaskService.failure("Reason", retries);

Hope this helps, Ingo

Thank you @Ingo_Richtsmeier for the detail and prompt response.

I am using Golang and had setup my struct such that I could not tell the difference between null and zero! I’ve now corrected and followed your pattern and it works perfectly.

Thank you,

Andrew