We are trying to split the process instance start that happens with RuntimeService.startProcessInstanceById(id) into two(create and start) to achieve starting process instance Async so that we can get the processInstanceId back without having to wait for process to run.
So we split the org.activiti.engine.impl.cmd.StartProcessInstanceCmd into two of our own commands CreateProcessInstanceCmd and RunProcessInstanceCmd.
<b>CreateProcessInstanceCmd.execute():</b>
DeploymentManager deploymentCache = Context.getProcessEngineConfiguration().getDeploymentManager();
ProcessDefinitionEntity processDefinition = deploymentCache.findDeployedProcessDefinitionById(processDefinitionId);
ExecutionEntity processInstance = processDefinition.createProcessInstance();
<b>RunProcessInstanceCmd.execute():</b>
ExecutionEntity processInstance = Context.getCommandContext().getExecutionEntityManager().findExecutionById(processInstanceId);
processInstance.start();
Everything seem to work fine, other then two issues we noticed that might be related:
1. Workflow completes but Start event remains unfinished and END_TIME and DURATION in ACT_HI_ACTINST table does not get populated.
2. If the first service task after Start was marked as "activiti:async="true" the workflow does not start and stays at start event.
Any help will be appreciated.