Java Code Examples for org.activiti.engine.impl.persistence.entity.JobEntity#setRetries()

The following examples show how to use org.activiti.engine.impl.persistence.entity.JobEntity#setRetries() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: DefaultJobManager.java    From activiti6-boot2 with Apache License 2.0 6 votes vote down vote up
@Override
public JobEntity moveDeadLetterJobToExecutableJob(DeadLetterJobEntity deadLetterJobEntity, int retries) {
  if (deadLetterJobEntity == null) {
    throw new ActivitiIllegalArgumentException("Null job provided");
  }
  
  JobEntity executableJob = createExecutableJobFromOtherJob(deadLetterJobEntity);
  executableJob.setRetries(retries);
  boolean insertSuccesful = processEngineConfiguration.getJobEntityManager().insertJobEntity(executableJob);
  if (insertSuccesful) {
    processEngineConfiguration.getDeadLetterJobEntityManager().delete(deadLetterJobEntity);
    triggerExecutorIfNeeded(executableJob);
    return executableJob;
  }
  return null;
}
 
Example 2
Source File: SetJobRetriesCmd.java    From flowable-engine with Apache License 2.0 6 votes vote down vote up
@Override
public Void execute(CommandContext commandContext) {
    JobEntity job = commandContext
            .getJobEntityManager()
            .findJobById(jobId);
    if (job != null) {
        job.setRetries(retries);

        if (commandContext.getEventDispatcher().isEnabled()) {
            commandContext.getEventDispatcher().dispatchEvent(
                    ActivitiEventBuilder.createEntityEvent(FlowableEngineEventType.ENTITY_UPDATED, job));
        }
    } else {
        throw new ActivitiObjectNotFoundException("No job found with id '" + jobId + "'.", Job.class);
    }
    return null;
}
 
Example 3
Source File: DefaultJobManager.java    From activiti6-boot2 with Apache License 2.0 5 votes vote down vote up
protected void fillDefaultAsyncJobInfo(JobEntity jobEntity, ExecutionEntity execution, boolean exclusive) {
  jobEntity.setJobType(JobEntity.JOB_TYPE_MESSAGE);
  jobEntity.setRevision(1);
  jobEntity.setRetries(processEngineConfiguration.getAsyncExecutorNumberOfRetries());
  jobEntity.setExecutionId(execution.getId());
  jobEntity.setProcessInstanceId(execution.getProcessInstanceId());
  jobEntity.setProcessDefinitionId(execution.getProcessDefinitionId());
  jobEntity.setExclusive(exclusive);
  jobEntity.setJobHandlerType(AsyncContinuationJobHandler.TYPE);
  
  // Inherit tenant id (if applicable)
  if (execution.getTenantId() != null) {
    jobEntity.setTenantId(execution.getTenantId());
  }
}
 
Example 4
Source File: SetJobRetriesCmd.java    From activiti6-boot2 with Apache License 2.0 5 votes vote down vote up
public Void execute(CommandContext commandContext) {
  JobEntity job = commandContext.getJobEntityManager().findById(jobId);
  if (job != null) {
    
    job.setRetries(retries);

    if (commandContext.getEventDispatcher().isEnabled()) {
      commandContext.getEventDispatcher().dispatchEvent(ActivitiEventBuilder.createEntityEvent(ActivitiEventType.ENTITY_UPDATED, job));
    }
  } else {
    throw new ActivitiObjectNotFoundException("No job found with id '" + jobId + "'.", Job.class);
  }
  return null;
}
 
Example 5
Source File: JobExecutorCmdExceptionTest.java    From activiti6-boot2 with Apache License 2.0 5 votes vote down vote up
protected JobEntity createTweetExceptionMessage() {
  JobEntity message = new JobEntityImpl();
  message.setJobType(JobEntity.JOB_TYPE_MESSAGE);
  message.setRetries(3);
  message.setJobHandlerType("tweet-exception");
  return message;
}
 
Example 6
Source File: JobExecutorCmdExceptionTest.java    From activiti6-boot2 with Apache License 2.0 5 votes vote down vote up
protected JobEntity createTweetExceptionMessage() {
  JobEntity message = processEngineConfiguration.getJobEntityManager().create();
  message.setJobType(JobEntity.JOB_TYPE_MESSAGE);
  message.setJobHandlerType("tweet-exception");
  message.setRetries(3);
  return message;
}