public ExecuteAsyncRunnable(Job job, ProcessEngineConfigurationImpl processEngineConfiguration) { this.job = job; this.jobId = job.getId(); this.processEngineConfiguration = processEngineConfiguration; }
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; } }
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; } }
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); } }
public JobResponse createJobResponse(Job job, RestUrlBuilder urlBuilder) { JobResponse response = new JobResponse(); response.setId(job.getId()); response.setDueDate(job.getDuedate()); response.setExceptionMessage(job.getExceptionMessage()); response.setExecutionId(job.getExecutionId()); response.setProcessDefinitionId(job.getProcessDefinitionId()); response.setProcessInstanceId(job.getProcessInstanceId()); response.setRetries(job.getRetries()); response.setTenantId(job.getTenantId()); response.setUrl(urlBuilder.buildUrl(RestUrls.URL_JOB, job.getId())); if (job.getProcessDefinitionId() != null) { response.setProcessDefinitionUrl(urlBuilder.buildUrl(RestUrls.URL_PROCESS_DEFINITION, job.getProcessDefinitionId())); } if (job.getProcessInstanceId() != null) { response.setProcessInstanceUrl(urlBuilder.buildUrl(RestUrls.URL_PROCESS_INSTANCE, job.getProcessInstanceId())); } if (job.getExecutionId() != null) { response.setExecutionUrl(urlBuilder.buildUrl(RestUrls.URL_EXECUTION, job.getExecutionId())); } return response; }
.executionId(job.getExecutionId()).singleResult(); WorkflowTimer workflowTimer = factory.createWorkflowTimer(job.getId(), job.getId(), job.getExceptionMessage(), job.getDuedate(), path, workflowTask); timers.add(workflowTimer);
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)); }
workflowError.setErrorMessage(erroredJob.getExceptionMessage()); workflowError.setRetriesLeft(erroredJob.getRetries()); workflowError.setErrorStackTrace(activitiService.getJobExceptionStacktrace(erroredJob.getId())); workflowErrors.add(workflowError);
if(job.getExceptionMessage() != null) { + ": " + job.getExceptionMessage()); exceptionMessageLabel.addStyleName(ExplorerLayout.STYLE_JOB_EXCEPTION_MESSAGE); layout.addComponent(exceptionMessageLabel); String stack = managementService.getJobExceptionStacktrace(job.getId()); } else { if (job.getProcessDefinitionId() != null) {
String globalJobId = BPMEngineRegistry.createGlobalId(ActivitiConstants.ENGINE_ID, timerJob.getId()); assertEquals(timerJob.getDuedate(), timer.getDueDate()); String expectedTimerPathId = BPMEngineRegistry.createGlobalId(ActivitiConstants.ENGINE_ID, timerJob.getExecutionId()); assertNotNull(timer.getPath()); assertEquals(expectedTimerPathId, timer.getPath().getId());
@Override public Void execute(CommandContext commandContext) { if (job.getProcessDefinitionId() != null && Activiti5Util.isActiviti5ProcessDefinitionId(commandContext, job.getProcessDefinitionId())) { Activiti5CompatibilityHandler activiti5CompatibilityHandler = Activiti5Util.getActiviti5CompatibilityHandler(); activiti5CompatibilityHandler.handleFailedJob(job, exception); return null; } 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; }
Object persistedObject = ((ActivitiEntityEvent) event).getEntity(); if (persistedObject instanceof Job) { event.setExecutionId(((Job) persistedObject).getExecutionId()); event.setProcessInstanceId(((Job) persistedObject).getProcessInstanceId()); event.setProcessDefinitionId(((Job) persistedObject).getProcessDefinitionId()); } else if (persistedObject instanceof DelegateExecution) { event.setExecutionId(((DelegateExecution) persistedObject).getId());
private boolean isInError(DelegateExecution context) { Job job = getJob(context); if (job == null) { return false; } String exceptionMessage = job.getExceptionMessage(); return exceptionMessage != null && !exceptionMessage.isEmpty(); }
private WorkflowTask getTaskForTimer(Job job, ProcessInstance processInstance, Execution jobExecution) { if (job instanceof TimerEntity) { ReadOnlyProcessDefinition def = activitiUtil.getDeployedProcessDefinition(processInstance.getProcessDefinitionId()); List<String> activeActivityIds = runtimeService.getActiveActivityIds(jobExecution.getId()); if(activeActivityIds.size() == 1) { PvmActivity targetActivity = def.findActivity(activeActivityIds.get(0)); if(targetActivity != null) { // Only get tasks of active activity is a user-task String activityType = (String) targetActivity.getProperty(ActivitiConstants.NODE_TYPE); if(ActivitiConstants.USER_TASK_NODE_TYPE.equals(activityType)) { Task task = taskService.createTaskQuery().executionId(job.getExecutionId()).singleResult(); return typeConverter.convert(task); } } } } return null; }
public void buttonClick(ClickEvent event) { if (isSuspendedProcessDefinition) { ExplorerApp.get().getViewManager().showSuspendedProcessDefinitionsPage(job.getProcessDefinitionId()); } else { ExplorerApp.get().getViewManager().showActiveProcessDefinitionsPage(job.getProcessDefinitionId()); } } });
protected void addHeader() { GridLayout jobDetails = new GridLayout(3, 2); jobDetails.setWidth(100, UNITS_PERCENTAGE); jobDetails.addStyleName(ExplorerLayout.STYLE_TITLE_BLOCK); jobDetails.setSpacing(true); jobDetails.setMargin(false, false, true, false); // Add image Embedded image = new Embedded(null, Images.JOB_50); jobDetails.addComponent(image, 0, 0, 0, 1); // Add job name Label nameLabel = new Label(getJobLabel(job)); nameLabel.addStyleName(Reindeer.LABEL_H2); jobDetails.addComponent(nameLabel, 1, 0, 2, 0); // Add due date PrettyTimeLabel dueDateLabel = new PrettyTimeLabel(i18nManager.getMessage(Messages.JOB_DUEDATE), job.getDuedate(), i18nManager.getMessage(Messages.JOB_NO_DUEDATE), false); dueDateLabel.addStyleName(ExplorerLayout.STYLE_JOB_HEADER_DUE_DATE); jobDetails.addComponent(dueDateLabel, 1, 1); jobDetails.setColumnExpandRatio(1, 1.0f); jobDetails.setColumnExpandRatio(2, 1.0f); addDetailComponent(jobDetails); }
protected String getRetriesLabel(Job theJob) { String retriesString; if(theJob.getRetries() <= 0) { retriesString = i18nManager.getMessage(Messages.JOB_NO_RETRIES); } else { retriesString = i18nManager.getMessage(Messages.JOB_RETRIES, theJob.getRetries()); } return retriesString; } }
.executionId(job.getExecutionId()).singleResult(); WorkflowTimer workflowTimer = factory.createWorkflowTimer(job.getId(), job.getId(), job.getExceptionMessage(), job.getDuedate(), path, workflowTask); timers.add(workflowTimer);
processEngineConfiguration.getClock().setCurrentTime(jobs.get(i).getDuedate()); managementService.executeJob(jobs.get(i).getId());
workflowError.setErrorMessage(erroredJob.getExceptionMessage()); workflowError.setRetriesLeft(erroredJob.getRetries()); workflowError.setErrorStackTrace(activitiService.getJobExceptionStacktrace(erroredJob.getId())); workflowErrors.add(workflowError);