cancel
Showing results for 
Search instead for 
Did you mean: 

Set the failed job retry count to 0

arunshenbagaraj
Champ in-the-making
Champ in-the-making
Hi,

Am using the activiti-engine version 5.17. I use a datasource to build the engine, i do not use the spring beans xml to configure the engine properties.

I need to know, how to set the failed job retry count to 0 for all the jobs? Expecting a reply soon.

9 REPLIES 9

trademak
Star Contributor
Star Contributor
In the ProcessEngineConfigurationImpl you can set the failedJobCommandFactory, this will override the default behaviour.
Using wording like "Expecting a reply soon" really doesn't help. People offer their spare time to answer these questions, so please be respectful.

Best regards,

arunshenbagaraj
Champ in-the-making
Champ in-the-making
Thanks for the reply Tijs.

arunshenbagaraj
Champ in-the-making
Champ in-the-making
Hi,

I have overridden the execute method in the Command<Object> interface. Please find below my implementation.       

        @Override
public Object execute(CommandContext commandContext) {
  try {
   JobEntity job = Context.getCommandContext().getJobEntityManager()
     .findJobById(jobId);

   log.info("Process instance id = " + job.getProcessInstanceId());
   job.setRetries(0);
   job.setLockOwner(null);
   job.setLockExpirationTime(null);

   if (exception != null) {
    job.setExceptionMessage(exception.getMessage());
    job.setExceptionStacktrace(getExceptionStacktrace());
   }
  
   ActivitiEventDispatcher eventDispatcher = commandContext
     .getEventDispatcher();
   if (eventDispatcher.isEnabled()) {
    eventDispatcher.dispatchEvent(ActivitiEventBuilder
      .createEntityEvent(ActivitiEventType.ENTITY_UPDATED,
        job));
    eventDispatcher.dispatchEvent(ActivitiEventBuilder.createEntityEvent(
        ActivitiEventType.JOB_RETRIES_DECREMENTED, job));
   }

   return null;
  } catch (Throwable e) {
   throw new RuntimeException(e);
  }
}


This sets the job retry to zero, but the workflow is not moving forward, it stops at the node where the exception was caught. Please advice, let me know what i am missing. Thanks in advance.

trademak
Star Contributor
Star Contributor
I'm really in doubt what kind of functionality you are looking for. If you set the job retry to 0, it will not be picked up by the job executor anymore. So why do you want to set the value to 0?

Best regards,

arunshenbagaraj
Champ in-the-making
Champ in-the-making
Thanks for the reply Tijis.

If a job fails, it shouldn't be re-tried, is what am looking for!!

Please let me know how to do that, thanks in advance.

jbarrez
Star Contributor
Star Contributor
The job executor will retry until  the 'retries' number is 0, then it will never be picked up anymore.

mikuc
Champ in-the-making
Champ in-the-making
@jbarrez is there any possibility after the job executor will retry until the 'retries' number is 0, to go by another flow? For example after retry count is 0 it will trigger a mail task or something else?

martin_grofcik
Confirmed Champ
Confirmed Champ
Hi,

use JOB_RETRIES_DECREMENTED event listener.

Regards
Martin

martin_grofcik
Confirmed Champ
Confirmed Champ
To decide in the process definition what to do, use service task with timer and loop.