I’m currently using flowable-engine and flowable-spring version 5.22.0.
I have successfully implemented in the engine a custom JobRetry and DefaultFailedJobCommandFactory overriding :
The reason behind it was to implement a exponential time of retry (with more than 3 retries) or no retry at all, depending on the scenario. At that point, all is working fine as expected.
Be able to pursue the BPMN proccess with a boundary error event, if a technical exception has been thrown and if it’s the last retry.
The class BpmnError was designed to be only thrown in JavaDelegate and expressions (if i’m not mistaken). So it can’t be used in the custom JobRetryCmd.
In JavaDelegate classes, you don’t have access to job information like retries, for architecture reasons.
I have read flowable and activiti (forums and docs) without finding any information about the subject.
So, I’d like to know some of your insights about what possibilies could work to your mind.
thanks in advance.
Here is some additional information about the bpmn model used (all service tasks are asynchronous), with an example of scenario :
PS: in my opinion, it wouldn’t seem to be such a good idea to model the retries in the bpmn since this is kind of technical and it would overcharge the bpmn model.
Your analysis is correct, I checked the source, and the BpmnError is indeed designed to be thrown from delegates/expressions (as the javadoc also states).
However, the only thing that happens, is that this particular exception is catched later on, followed by calling a method on the ErrorPropagation class.
I haven’t tested it, but from a quick glance it looks like you could call ErrorPropagation.propagateError(errorCode, Execution) instead of throwing the BpmnError. That logic will use the info in the Execution and pass it to the matching error boundary event. The job normally has the executionId, which can be used to fetch the Execution to pass.
Thank you for you quick answer. It works like a charm, following your advice.
Here, the code used in the custom JobRetryCmd class, for next users who would implement the same mecanism :
ActivityExecution execution = (ActivityExecution) processEngineConfig.getRuntimeService().createExecutionQuery()