org.activiti.engine.runtime.Job.getId()方法的使用及代码示例

x33g5p2x  于2022-01-22 转载在 其他  
字(10.3k)|赞(0)|评价(0)|浏览(76)

本文整理了Java中org.activiti.engine.runtime.Job.getId()方法的一些代码示例,展示了Job.getId()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Job.getId()方法的具体详情如下:
包路径:org.activiti.engine.runtime.Job
类名称:Job
方法名:getId

Job.getId介绍

[英]Returns the unique identifier for this job.
[中]返回此作业的唯一标识符。

代码示例

代码示例来源:origin: Activiti/Activiti

public ExecuteAsyncRunnable(Job job, ProcessEngineConfigurationImpl processEngineConfiguration) {
 this.job = job;
 this.jobId = job.getId();
 this.processEngineConfiguration = processEngineConfiguration;
}

代码示例来源:origin: Activiti/Activiti

public void jobRejected(AsyncExecutor asyncExecutor, Job job) {
 try {
  // execute rejected work in caller thread (potentially blocking job
  // acquisition)
  new ExecuteAsyncRunnable((JobEntity) job, asyncExecutor.getProcessEngineConfiguration()).run();
 } catch (Exception e) {
  log.error("Failed to execute rejected job " + job.getId(), e);
 }
}

代码示例来源:origin: Activiti/Activiti

protected void unlockJobIfNeeded() {
 try {
  if (job.isExclusive()) {
   processEngineConfiguration.getCommandExecutor().execute(new UnlockExclusiveJobCmd(job));
  }
 } catch (ActivitiOptimisticLockingException optimisticLockingException) {
  if (log.isDebugEnabled()) {
   log.debug("Optimistic locking exception while unlocking the job. If you have multiple async executors running against the same database, "
     + "this exception means that this thread tried to acquire an exclusive job, which already was changed by another async executor thread."
     + "This is expected behavior in a clustered environment. " + "You can ignore this message if you indeed have multiple job executor acquisition threads running against the same database. "
     + "Exception message: {}", optimisticLockingException.getMessage());
  }
 } catch (Throwable t) {
  log.error("Error while unlocking exclusive job " + job.getId(), t);
 }
}

代码示例来源:origin: Activiti/Activiti

@Override
public void closeFailure(CommandContext commandContext) {
 if (commandContext.getEventDispatcher().isEnabled()) {
  commandContext.getEventDispatcher().dispatchEvent(ActivitiEventBuilder.createEntityExceptionEvent(
   ActivitiEventType.JOB_EXECUTION_FAILURE, job, commandContext.getException()));
 }
 
 CommandConfig commandConfig = commandExecutor.getDefaultConfig().transactionRequiresNew();
 FailedJobCommandFactory failedJobCommandFactory = commandContext.getFailedJobCommandFactory();
 Command<Object> cmd = failedJobCommandFactory.getCommand(job.getId(), commandContext.getException());
 log.trace("Using FailedJobCommandFactory '" + failedJobCommandFactory.getClass() + "' and command of type '" + cmd.getClass() + "'");
 commandExecutor.execute(commandConfig, cmd);
}

代码示例来源:origin: Activiti/Activiti

@Override
public Void execute(CommandContext commandContext) {
 CommandConfig commandConfig = processEngineConfiguration.getCommandExecutor().getDefaultConfig().transactionRequiresNew();
 FailedJobCommandFactory failedJobCommandFactory = commandContext.getFailedJobCommandFactory();
 Command<Object> cmd = failedJobCommandFactory.getCommand(job.getId(), exception);
 log.trace("Using FailedJobCommandFactory '" + failedJobCommandFactory.getClass() + "' and command of type '" + cmd.getClass() + "'");
 processEngineConfiguration.getCommandExecutor().execute(commandConfig, cmd);
 // Dispatch an event, indicating job execution failed in a
 // try-catch block, to prevent the original exception to be swallowed
 if (commandContext.getEventDispatcher().isEnabled()) {
  try {
   commandContext.getEventDispatcher().dispatchEvent(ActivitiEventBuilder.createEntityExceptionEvent(ActivitiEventType.JOB_EXECUTION_FAILURE, job, exception));
  } catch (Throwable ignore) {
   log.warn("Exception occurred while dispatching job failure event, ignoring.", ignore);
  }
 }
 return null;
}

代码示例来源:origin: Activiti/Activiti

public Object execute(CommandContext commandContext) {

  if (job == null) {
   throw new ActivitiIllegalArgumentException("job is null");
  }

  if (log.isDebugEnabled()) {
   log.debug("Unlocking exclusive job {}", job.getId());
  }

  if (job.isExclusive()) {
   if (job.getProcessInstanceId() != null) {
    ExecutionEntity execution = commandContext.getExecutionEntityManager().findById(job.getProcessInstanceId());
    if (execution != null) {
     commandContext.getExecutionEntityManager().clearProcessInstanceLockTime(execution.getId());
    } 
   }
  }

  return null;
 }
}

代码示例来源:origin: Activiti/Activiti

public Object execute(CommandContext commandContext) {

  if (job == null) {
   throw new ActivitiIllegalArgumentException("job is null");
  }

  if (log.isDebugEnabled()) {
   log.debug("Executing lock exclusive job {} {}", job.getId(), job.getExecutionId());
  }

  if (job.isExclusive()) {
   if (job.getExecutionId() != null) {
    ExecutionEntity execution = commandContext.getExecutionEntityManager().findById(job.getExecutionId());
    if (execution != null) {
     commandContext.getExecutionEntityManager().updateProcessInstanceLockTime(execution.getProcessInstanceId());
    }
   }
  }

  return null;
 }
}

代码示例来源:origin: Activiti/Activiti

log.debug("Executing async job {}", job.getId());

代码示例来源:origin: Activiti/Activiti

public Object execute(CommandContext commandContext) {
 if (jobId == null) {
  throw new ActivitiIllegalArgumentException("jobId and job is null");
 }
 Job job = commandContext.getJobEntityManager().findById(jobId);
 if (job == null) {
  throw new JobNotFoundException(jobId);
 }
 if (log.isDebugEnabled()) {
  log.debug("Executing job {}", job.getId());
 }
 
 commandContext.addCloseListener(new FailedJobListener(commandContext.getProcessEngineConfiguration().getCommandExecutor(), job));
 try {
  commandContext.getJobManager().execute(job);
 } catch (Throwable exception) {
  // Finally, Throw the exception to indicate the ExecuteJobCmd failed
  throw new ActivitiException("Job " + jobId + " failed", exception);
 }
 return null;
}

代码示例来源:origin: Activiti/Activiti

@Override
public void unacquire(Job job) {
 
 // Deleting the old job and inserting it again with another id,
 // will avoid that the job is immediately is picked up again (for example
 // when doing lots of exclusive jobs for the same process instance)
 if (job instanceof JobEntity) {
  JobEntity jobEntity = (JobEntity) job;
  processEngineConfiguration.getJobEntityManager().delete(jobEntity.getId());
  
  JobEntity newJobEntity = processEngineConfiguration.getJobEntityManager().create();
  copyJobInfo(newJobEntity, jobEntity);
  newJobEntity.setId(null); // We want a new id to be assigned to this job
  newJobEntity.setLockExpirationTime(null);
  newJobEntity.setLockOwner(null);
  processEngineConfiguration.getJobEntityManager().insert(newJobEntity);
  
  // We're not calling triggerExecutorIfNeeded here after the inser. The unacquire happened
  // for a reason (eg queue full or exclusive lock failure). No need to try it immediately again,
  // as the chance of failure will be high.
  
 } else {
  // It could be a v5 job, so simply unlock it.
  processEngineConfiguration.getJobEntityManager().resetExpiredJob(job.getId());
 }
 
}

代码示例来源:origin: org.activiti/activiti-engine

public ExecuteAsyncRunnable(Job job, ProcessEngineConfigurationImpl processEngineConfiguration) {
 this.job = job;
 this.jobId = job.getId();
 this.processEngineConfiguration = processEngineConfiguration;
}

代码示例来源:origin: org.activiti/activiti-explorer

private String getName(Job theJob) {
 if(theJob instanceof TimerEntity) {
  return "Timer job " + theJob.getId();
 } else if (theJob instanceof MessageEntity) {
  return "Message job " + theJob.getId();
 } else {
  return "Job " + theJob.getId();
 }
}

代码示例来源:origin: stackoverflow.com

public class JobResponseWriter extends FileWriter{
  private final File myFile;
  public JobResponseWriter(Job job) throws IOException {
    this(File.createTempFile("JobResponse" + job.getId() ,"tmp"));
  }
  public JobResponseWriter(File f) throws IOException {
    super(f);
    myFile = f;
  }
  /* your code here */
}

代码示例来源:origin: org.activiti/activiti-explorer

protected String getJobLabel(Job theJob) {
 // Try figuring out the type
 if(theJob instanceof TimerEntity) {
  return i18nManager.getMessage(Messages.JOB_TIMER, theJob.getId());
 } else if (theJob instanceof MessageEntity) {
  return i18nManager.getMessage(Messages.JOB_MESSAGE, theJob.getId());
 } else {
  return i18nManager.getMessage(Messages.JOB_DEFAULT_NAME, theJob.getId());
 }
}

代码示例来源:origin: org.activiti/activiti-explorer

public void buttonClick(ClickEvent event) {
  managementService.deleteJob(job.getId());
  
  notificationManager.showInformationNotification(Messages.JOB_DELETED);
  jobPage.refreshSelectNext();
 }
});

代码示例来源:origin: org.activiti/activiti-explorer

public void buttonClick(ClickEvent event) {
  try {
   managementService.executeJob(job.getId());
   jobPage.refreshSelectNext();
  } catch (ActivitiException ae) {
   String errorMessage = ae.getMessage() + (ae.getCause() != null ? " (" + ae.getCause().getClass().getName() + ")" : "");
   notificationManager.showErrorNotification(Messages.JOB_ERROR, errorMessage);
   // Refresh the current job
   jobPage.refreshCurrentJobDetails();
  }
 }
});

代码示例来源:origin: org.activiti/activiti-engine

@Override
public void closeFailure(CommandContext commandContext) {
 if (commandContext.getEventDispatcher().isEnabled()) {
  commandContext.getEventDispatcher().dispatchEvent(ActivitiEventBuilder.createEntityExceptionEvent(
   ActivitiEventType.JOB_EXECUTION_FAILURE, job, commandContext.getException()));
 }
 
 CommandConfig commandConfig = commandExecutor.getDefaultConfig().transactionRequiresNew();
 FailedJobCommandFactory failedJobCommandFactory = commandContext.getFailedJobCommandFactory();
 Command<Object> cmd = failedJobCommandFactory.getCommand(job.getId(), commandContext.getException());
 log.trace("Using FailedJobCommandFactory '" + failedJobCommandFactory.getClass() + "' and command of type '" + cmd.getClass() + "'");
 commandExecutor.execute(commandConfig, cmd);
}

代码示例来源:origin: com.bbossgroups.activiti/activiti-engine

protected void removeObsoleteTimers(ProcessDefinitionEntity processDefinition) {
 List<Job> jobsToDelete = Context
  .getCommandContext()
  .getJobEntityManager()
  .findJobsByConfiguration(TimerStartEventJobHandler.TYPE, processDefinition.getKey());
 
 for (Job job :jobsToDelete) {
   new DeleteJobsCmd(job.getId()).execute(Context.getCommandContext());
 }
}

代码示例来源:origin: org.activiti/activiti-explorer

public JobListItem(Job job) {
 addItemProperty("id", new ObjectProperty<String>(job.getId(), String.class));
 addItemProperty("dueDate", new ObjectProperty<Date>(job.getDuedate(), Date.class));
 addItemProperty("name", new ObjectProperty<String>(getName(job), String.class));
}

代码示例来源:origin: com.sap.cloud.lm.sl/com.sap.cloud.lm.sl.slp

public void executeJob(String userId, String processInstanceId) {
  Job job = getJob(processInstanceId);
  if (job != null) {
    try {
      engine.getIdentityService().setAuthenticatedUserId(userId);
      setStatusVariable(processInstanceId, job);
      engine.getManagementService().executeJob(job.getId());
    } finally {
      engine.getIdentityService().setAuthenticatedUserId(null);
    }
  }
}

相关文章