Set custom retries based on type of exception

Hello,

I am using Service Task with JavaDelegate to call an external web service.
As per my understanding, the task is automatically retried 3 times if any exception is thrown from JavaDelegate. I want to override this logic based on the type of error/exception.

For example:

  1. If I get 500 Server error back from the web service call, I want to retry once after X mins.
  2. If I get 4XX HTTP error back from the web service, I want to do zero retries and create incident right away.

How can this be achieved in the JavaDelegate? Is there anyway to set the retry count based on some logic implemented in JavaDelegate?

Regards,
Yogesh

@Niall @Ingo_Richtsmeier or anyone can please answer this?

Hi @yogeshrnaik,

I think, (but I’m nor sure) that it is not possible to influence the retry behavior once the Java delegate is invoked.

It’s different with external tasks, as you have to return the retries from your business logic: https://docs.camunda.org/manual/7.14/user-guide/process-engine/external-tasks/#reporting-task-failure. You can have a look into the REST endpoint here: https://docs.camunda.org/manual/7.14/reference/rest/external-task/post-failure/

Hope this helps, Ingo