org.activiti.engine.impl.jobexecutor.AsyncContinuationJobHandler Java Examples

The following examples show how to use org.activiti.engine.impl.jobexecutor.AsyncContinuationJobHandler. 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: AlfrescoProcessEngineConfiguration.java    From alfresco-repository with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Override
protected void initJobExecutor() 
{
    super.initJobExecutor();

    // Wrap timer-job handler to handle authentication
    JobHandler timerJobHandler = jobHandlers.get(TimerExecuteNestedActivityJobHandler.TYPE);
    JobHandler wrappingTimerJobHandler = new AuthenticatedTimerJobHandler(timerJobHandler, unprotectedNodeService);
    jobHandlers.put(TimerExecuteNestedActivityJobHandler.TYPE, wrappingTimerJobHandler);
    
    // Wrap async-job handler to handle authentication
    JobHandler asyncJobHandler = jobHandlers.get(AsyncContinuationJobHandler.TYPE);
    JobHandler wrappingAsyncJobHandler = new AuthenticatedAsyncJobHandler(asyncJobHandler);
    jobHandlers.put(AsyncContinuationJobHandler.TYPE, wrappingAsyncJobHandler);
    
    // Wrap intermediate-timer-job handler to handle authentication
    JobHandler intermediateJobHandler = jobHandlers.get(TimerCatchIntermediateEventJobHandler.TYPE);
    JobHandler wrappingIntermediateJobHandler = new AuthenticatedAsyncJobHandler(intermediateJobHandler);
    jobHandlers.put(TimerCatchIntermediateEventJobHandler.TYPE, wrappingIntermediateJobHandler);
    
}
 
Example #2
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 #3
Source File: ProcessEngineConfigurationImpl.java    From flowable-engine with Apache License 2.0 5 votes vote down vote up
protected void initJobHandlers() {
    jobHandlers = new HashMap<>();
    TimerExecuteNestedActivityJobHandler timerExecuteNestedActivityJobHandler = new TimerExecuteNestedActivityJobHandler();
    jobHandlers.put(timerExecuteNestedActivityJobHandler.getType(), timerExecuteNestedActivityJobHandler);

    TimerCatchIntermediateEventJobHandler timerCatchIntermediateEvent = new TimerCatchIntermediateEventJobHandler();
    jobHandlers.put(timerCatchIntermediateEvent.getType(), timerCatchIntermediateEvent);

    TimerStartEventJobHandler timerStartEvent = new TimerStartEventJobHandler();
    jobHandlers.put(timerStartEvent.getType(), timerStartEvent);

    AsyncContinuationJobHandler asyncContinuationJobHandler = new AsyncContinuationJobHandler();
    jobHandlers.put(asyncContinuationJobHandler.getType(), asyncContinuationJobHandler);

    ProcessEventJobHandler processEventJobHandler = new ProcessEventJobHandler();
    jobHandlers.put(processEventJobHandler.getType(), processEventJobHandler);

    TimerSuspendProcessDefinitionHandler suspendProcessDefinitionHandler = new TimerSuspendProcessDefinitionHandler();
    jobHandlers.put(suspendProcessDefinitionHandler.getType(), suspendProcessDefinitionHandler);

    TimerActivateProcessDefinitionHandler activateProcessDefinitionHandler = new TimerActivateProcessDefinitionHandler();
    jobHandlers.put(activateProcessDefinitionHandler.getType(), activateProcessDefinitionHandler);

    // if we have custom job handlers, register them
    if (getCustomJobHandlers() != null) {
        for (JobHandler customJobHandler : getCustomJobHandlers()) {
            jobHandlers.put(customJobHandler.getType(), customJobHandler);
        }
    }
}
 
Example #4
Source File: ExecutionEntity.java    From flowable-engine with Apache License 2.0 5 votes vote down vote up
protected void scheduleAtomicOperationAsync(AtomicOperation executionOperation) {
    JobEntity message = new JobEntity();
    message.setJobType(Job.JOB_TYPE_MESSAGE);
    message.setRevision(1);
    message.setExecution(this);
    message.setExclusive(getActivity().isExclusive());
    message.setJobHandlerType(AsyncContinuationJobHandler.TYPE);
    // At the moment, only AtomicOperationTransitionCreateScope can be performed asynchronously,
    // so there is no need to pass it to the handler

    ProcessEngineConfiguration processEngineConfig = Context.getCommandContext().getProcessEngineConfiguration();

    if (processEngineConfig.getAsyncExecutor().isActive()) {
        GregorianCalendar expireCal = new GregorianCalendar();
        expireCal.setTime(processEngineConfig.getClock().getCurrentTime());
        expireCal.add(Calendar.SECOND, processEngineConfig.getLockTimeAsyncJobWaitTime());
        message.setLockExpirationTime(expireCal.getTime());
    }

    // Inherit tenant id (if applicable)
    if (getTenantId() != null) {
        message.setTenantId(getTenantId());
    }

    callJobProcessors(JobProcessorContext.Phase.BEFORE_CREATE, message, Context.getProcessEngineConfiguration());
    Context.getCommandContext().getJobEntityManager().send(message);
}