Avoid Job Retries on Non-Resolvable Errors

Dear Flowable Experts,

Is there a way to avoid unnecessary retries when a custom activity behavior or delegate throws an exception which will not be resolved by a retry?

By default, retries are set to 2 in our environment which we would like to preserve for e.g. optimistic locking exceptions etc. However, some activities would throw exceptions which will persist even if an activity is retried. In this case, it would be reasonable to avoid the retries.

Is there a clean way to achieve this?

To test our options, we have tried JobEntity#setRetries to 0 and JobService#moveJobToDeadLetterJob for the current job in an activity behavior as such. Unfortunately, this hasn’t worked out. Probably, we’ve missed something.

Thank you very much in advance!

Best regards,
Vasil

No, not with the out of the box logic: every exception in a job will lead to retries being decreased and a deadletter job being created on retries == 0.

Have a look at the FailedJobCommandFactory interface. You probably are able to set a custom Command there. The default logic with retries is implemented in the DefaultFailedJobCommandFactory: https://github.com/flowable/flowable-engine/blob/main/modules/flowable-engine/src/main/java/org/flowable/engine/impl/jobexecutor/DefaultFailedJobCommandFactory.java

1 Like