Hello everyone,
I am not sure if this belongs to the Workflow Execution or Zeebe Client category. I have the following use case:
A multi-instance subprocess is used to process a list of elements. The first task within the subprocess can throw different exceptions in the worker implementation. For most exceptions, the job is failed, using the built-in retry mechanism of Zeebe.
However, for a specific exception, id like to have my own retry mechanism. Therefore, if this specific exception occurs, a business error is thrown with the Zeebe client to trigger the alternate workflow. Each of the instances needs its own retries
counter that is decreased by one each time the business error is thrown so that the handler is called when no retries are left.
To ensure that each of the instances has its own retry counter, the subprocess has an input mapping that sets the initial value of retries
. If i get the documentation right, this ensures that each instance has its own value.
My question is: How can i decrease the retries
value for a specific subprocess instance? My idea was to use the Zeebe client before throwing the business error to set the retries
process variable to a lower value (using ZeebeClient.newSetVariablesCommand
), but i can only get the elementInstanceKey
and processInstanceKey
of the current job. It seems like both are not able to set the variable for the subprocess instance.
Simplified code:
public void handle(JobClient client, ActivatedJob job) {
try {
...
} catch(SpecificException se) {
client.newThrowErrorCommand(job).errorCode("my-code").send().join();
// Decrease the 'retries' variable here
} catch(Exception exception) {
client.newFailCommand(job.getKey())/...
}
}
Is there any way to get the key of the scope of the subprocess instance to set its retries
variable? Or should i model my BPMN differently?
Thanks in advance,
Janek