Change number of retries for a job based on a condition

Hello Everyone!

I am currently working on a project where we have a service task in which we call an external service.
I have setup a Retry time cycle for the task (PT1M, PT10M, PT60M) which is working as expected. However, I now must change the implementation in the following way:

  • if the external service responds with an error code that is different from 400, the application continues with the current implementation of retrying 3 times; if all 3 retries fail, an Incident is created in cockpit

  • if the service responds with error code 400, the application will no longer do the retries, an Incident is created immediately

I have tried multiple methods, but none of them seem to do the trick.

My question is: what would be an optimal solution a problem like this? Is there a way to set the number of retries for a Job in spring boot?

Thank you in advance!

Hi @Matyas,

if you implement your service task as an external task, then you can (or even have to) send the number of retries and the retryInterval for the next activation from your own code.

Hope this helps, Ingo