1

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");
}
Chris I
  • 43
  • 5
  • 1
    Have you looked at the histories of the parent and the child workflows? They should contain events that describe exactly in which state all of them are found. – Maxim Fateev Sep 18 '15 at 19:57
  • Can you share the code snippet where you are starting the child workflows. Suspect something is not right there – Rohit Sep 19 '15 at 09:42
  • @MaximFateev I have looked at the histories. The parent history shows one child execution starting and completing, then another replay of the parent workflow occurs where the last event is DecisionTaskCompleted, and that is it. It stays like that until the parent times out. The child workflow history is exactly what I expect it to be, with all activities completing and the last event is that the child workflow completes. – Chris I Sep 20 '15 at 15:51

1 Answers1

1

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.

Maxim Fateev
  • 6,458
  • 3
  • 20
  • 35
  • Sorry, I didn't show the instantiation of the client object. Yes, I am using the factory.getClient method. – Chris I Sep 21 '15 at 02:21
  • Are you using separate client instance for each child workflow? – Maxim Fateev Sep 21 '15 at 18:13
  • No I am not. Am I intended to? – Chris I Sep 21 '15 at 20:13
  • It apparently is not clear from the documentation, but for each child workflow execution a new client should be created. Look at the generated client interface. It contains methods that return data (like runId) that is specific per child workflow execution. – Maxim Fateev Sep 21 '15 at 20:57
  • Yup, that's all I needed. Thanks @MaximFateev! If you put it down as an answer, I can accept it. – Chris I Sep 22 '15 at 11:35