How to use "Broker can delay failed tasks before reprocessing" (#5626)

Hi, #5626 has been available since Zeebe 1.3.0.

The idea is that a client (Java/Go/Zbctl) can specify an optional backoff time when sending a JobFailed command

How can this be utilized from the clients? Specifically interested in the java client / spring-starter.

Currently I don’t see any method in the fail job fluent builder for this.

Cheers,

JanneH

Okay, found the answer in https://github.com/camunda-cloud/zeebe/issues/5629: the client support isn’t there yet. Eagerly waiting for that to materialize. Thanks!

2 Likes

In the meantime, there is an API to specify a backoff when failing a job.

How can this be used in a Java client (job worker)? Do I have to use the zeebeClient to explicitly send the command (und return nothing from the job worker method)? Or can I just throw some kind of exception which will be then translated to such a command by zeebe-spring code?

Thank you.

Hi @fml2,

you have to disable autoComplete in Spring-Zeebe, catch your exception and send the fail command with the retryBackoff filled with a reasonable value.

As autoComplete is disabled, don’t forget to send the complete command to continue the process instance.

Hope this helps, Ingo

Hello @Ingo_Richtsmeier , thank you for the reply. Do you mean that, in order to fail a command at one place, I have to disable “autoComplete” globally and hence will have to complete all other jobs (in all other workers) explicitly? That would be quite inconvenient.

What if I don’t disable “autoComplete” and send a “fail job” command? The command would be issued first, then the worker would run to the end without an exception which would cause the spring-zeebe code to complete the job? Is my understanding correct? What would the end result look like then? Fail or complete?

Hi @fml2,

No. As autoComplete is by default set to true in the latest versions of Spring-Zeebe, you have to set it to false on single workers in the @JobWorker annotation: GitHub - camunda-community-hub/spring-zeebe: Easily use the Zeebe Java Client in your Spring or Spring Boot projects (in the example for explicit job completion, autoComplete=false is missing.)

I would expect, that the client first sends the fail command (from your code) and then send the complete command (from the framework). Hopefully, the framework is stable enough to log the exception that the task cannot be completed and continues to work on other tasks. I haven’t tested this by myself.

Hope this helps, Ingo

1 Like