Retry time cicle is not working

I have a cycle configuration but it does not work. When the bpmn exception is throw, I expected that Camunda will wait for the interval and try again but it does not happen.

@Component
@Slf4j
public class UserManagement implements JavaDelegate {

    @Override
    public void execute(DelegateExecution delegateExecution) throws InterruptedException {
        String userUamId = (String) delegateExecution.getVariable("userUamId");
        String userEsbId = (String) delegateExecution.getVariable("userEsbId");

        log.info("Uam ID {} and user Esb ID {}", userUamId, userEsbId);

        throw new BpmnError("FatalError");
    }

}

How you can see, the difference between the logs are of the miliseconds

*2021-09-28 10:32:02,318* INFO  [55cf6c01d7cbef8e] s.j.m.s.c.c.processor.UserManagement     |- Uam ID 5 and user Esb ID null 
*2021-09-28 10:32:02,398* INFO  [55cf6c01d7cbef8e] s.j.m.s.c.c.processor.LoggerDelegate     |- LoggerDelegate .... 
*2021-09-28 10:32:02,435* INFO  [55cf6c01d7cbef8e] s.j.m.s.c.c.processor.UserManagement     |- Uam ID 5 and user Esb ID null 

Hi @gabryellr,

Please have a look at below posts

Hi @hassang thank you for your reply

Sorry, I didn´t get it, in my process I’ll need to call an API and if I receive a 400 status code, I´ll need to try again in the 30 minutes, How Do I deal with it without throw an bpm exception? How will I say to camunda:

" Hey, how I received an 400 status code, you´ll need to call this task again"

The other solution is to set retry time cycle value, tick async before for the service task and throw a Java exception with the proper error message in your implementation in case of failure. (This way camunda will do the retry job as per the configured value for “retry time cycle” and once all retries get consumed an incident will be created so using cockpit, an admin can view the exception message and take the required action manually)

If you don’t want to throw a Java exception then you can proceed with your solution which is to model the error but you have to use a timer in your model to let execution token waits for the specified period before returning to the same service task. (retry strategy wouldn’t work in this case)

Then in this case


in my java code I need to throw an bpm exception and the camunda will try again according the retry time configuration.

    public void execute(DelegateExecution delegateExecution) throws InterruptedException {
        String userUamId = (String) delegateExecution.getVariable("userUamId");
        String userEsbId = (String) delegateExecution.getVariable("userEsbId");

        log.info("Uam ID {} and user Esb ID {}", userUamId, userEsbId);

        throw new BpmnError("FatalError");
    }

In the example, above, after 3 retries, an incident will be opened by Camunda, right?

A regular Java exception to be thrown

throw new Exception(“Fatal Error”);

With the value given for retry time cycle,

A total of 3 automatic retries to be consumed.
Each retry to be started every 30 seconds.
Once all consumed with no success then an incident to be created.

@hassang perfect, thank you so much for your help, just another question, Can I do this steps but without throw exception?

like this:

if (statusCode == 400) { 
tryPostAgain() 
}  3x

If after 3 times I receive an 400 status code, I finish the whole process but without open an incident.

Hi @gabryellr,

Without throwing Java exception, retry strategy wouldn’t work.

Thank you for your help :smiley: