Reputation: 43
I am attempting to start two parallel executions of a child workflow with differing starting parameters. However, I am noticing that only one of those child workflow executions is run. The parent workflow execution halts due to tasks not being scheduled which causes to not have any further activity in the execution history until it times out. No exceptions or errors are thrown, it just stops doing anything at all. Interestingly, it is always the second child workflow execution that completes.
If the parent runs only one execution of the child workflow, the child completes successfully, and the parent workflow continues to completion. My suspicion is that it has something to do with running multiple copies of the child workflow simultaneously and that they interfere with each other since they poll the same tasklist; I just don't know how I am supposed to approach the problem.
Code:
ProcessRunnerClient childWorkflowClient = factory.getClient();
List<Promise<T>> childWorkflowsDone = new ArrayList<Promise<T>>;
switch(condition){
case 1:
childWorkflowsDone.add(childWorkflowClient.method(case1Params));
// Works fine
break;
case 2:
childWorkflowsDone.add(childWorkflowClient.method(case2Params));
// Works fine
break;
case 3:
childWorkflowsDone.add(childWorkflowClient.method(case1Params));
childWorkflowsDone.add(childWorkflowClient.method(case2Params));
// The execution of the child workflow with case2Params completes,
// and parent execution suspends
break;
default:
throw new WorkflowException("Condition " + condition + " not supported");
}
Upvotes: 1
Views: 1095
Reputation: 6890
Make sure that each child workflow is started using its own instance of the generated client. So change your example to:
List<Promise<T>> childWorkflowsDone = new ArrayList<Promise<T>>;
ProcessRunnerClient childWorkflowClient1 = factory.getClient()
childWorkflowsDone1.add(childWorkflowClient.method(params1));
ProcessRunnerClient childWorkflowClient2 = factory.getClient()
childWorkflowsDone.add(childWorkflowClient2.method(params2));
It is done to support communication to the child workflow after it is started. For example the same client can be used to send signal or retrieve runId.
Upvotes: 1