Retry Time Cycle Configuration Not Working

Hi workflow team, we configure the retry mechanism as a global level and creating the incident after 3 retries but one specials case is there when 400 bad request come that time we should not retry and we have to create the incident , for that what we implemented we created the one class where we try to set the retry value

@Override

public Object execute(CommandContext commandContext) {
JobEntity job = Context.getCommandContext()
.getJobManager()
.findJobById(jobId);
if(this.exception.getCause().getMessage().startsWith(“400 Bad Request”)) {
job.setRetries(0);
}
else{
job.setRetries(3);
}
return commandContext;
}
but what we facing whenever 400 come that time it is working fine but apart from 400 it is retrying gain and again means calling same class again and retry value setting again and again means retries is not stopping . is there any way where we can set the retry when 400 come that time retry 0 and 500 or some other exception come that time it should retry 3 times.

Hello @Krishan_Pratap_Singh ,

to get an understanding of the JobRetryCommand, have a look at org.camunda.bpm.engine.impl.cmd.DefaultJobRetryCmd. You can extend this class and simply override the methods of which you want to change the behaviour of.

This extension needs to be returned by an implementation of org.camunda.bpm.engine.impl.jobexecutor.FailedJobCommandFactory, which then can be configured to be used by your process engine configuration as failedJobCommandFactory.

Hope this helps

Jonathan

1 Like

@jonathan.lukas Thanks it help

2 Likes