cancel
Showing results for 
Search instead for 
Did you mean: 

Issue with starting process instance Async

kapil00
Champ in-the-making
Champ in-the-making
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.
1 REPLY 1

martin_grofcik
Confirmed Champ
Confirmed Champ
Hi,

starting process instance Async so that we can get the processInstanceId back without having to wait for process to run.

I would set the first activity after the start event asynchronous. It should start the process and create the job for already started process instance. Execution will start process and create a job.

For your problem -> Could you create jUnit test for it?
http://forums.activiti.org/content/sticky-how-write-unit-test

Regards
Martin