AnsweredAssumed Answered

Retry failed job and duedate/lockExpirationDate

Question asked by mapor on May 5, 2014
Latest reply on Jul 9, 2014 by trademak
Hello,

I'm trying to write a class in order to retry failed job with a delay, in my command i use the following lines :


public Object execute(CommandContext commandContext) {
     if(this.jobId==null){
        LOGGER.error("no job id given");
        throw new IllegalArgumentException();
     }
      JobEntity job = Context
      .getCommandContext()
      .getJobEntityManager()
      .findJobById(jobId);
    job.setLockOwner(null);
    Date date = Calendar.getInstance().getTime();
    date.setTime(date.getTime()+TEN_MN_IN_MS);
   
    job.setLockExpirationTime(date);
    job.setDuedate(date);
    if(LOGGER.isDebugEnabled()){
       LOGGER.debug("Job "+jobId+" has been delayed to "+date.getTime());
    }

    if(exception != null) {
      job.setExceptionMessage(exception.getMessage());
      job.setExceptionStacktrace(getExceptionStacktrace());
    }
    return null;
  }


However i can still see a value in lock owner in the jobs that should not have one anymore, and duedate is only update for timer entites, not message.

The purpose is to retry any kind of job with a delay like 10mn or 1h any amount of times it's required (due to external systems not very friendly…) .

I know about a JIRA that solved the case by patching activiti but i'm not allowed to patch Activiti and as it has been said in the JIRA, it should be enough to replace a FailedJobCommandFactory in order to do that, but it doesn't work.

Any idea of what doesn't work or other way to handle that are welcome.

Outcomes