Say I have two workflows
Workflow1
final WorkflowOptions options =
WorkflowOptions.newBuilder()
.setTaskQueue("default")
.setWorkflowId("workflow1")
.build();
Workflow1 workflow1 = workflowClient.newWorkflowStub(Workflow1.class, options);
WorkflowClient.start(() -> workflow1.execute())
Workflow1 execute method calls workflow2
public Workflow1Impl implements Workflow1 {
SomeActivity someActivity = .....
public void execute() {
someActivity.startWorkflow2();
}
}
SomeActivityImpl
public class SomeActivityImpl implements someActivity {
public void startWorkflow2() {
final WorkflowOptions options =
WorkflowOptions.newBuilder()
.setTaskQueue("default")
.setWorkflowId("workflow2")
.build();
Workflow1 workflow2 = workflowClient.newWorkflowStub(Workflow2.class, options);
WorkflowClient.start(() -> workflow2.execute())
}
}
In most of the docs which I have read we are doing this by creating child workflows and using ChildWorkflowOptions.
How workflow2 will behave in above case
- workflow2 will be async?
- workflow 2 will act as child workflow by default? This means if parent workflow1 terminates then workflow2 will terminate immediately irrespective of if it has finished or not
- workflow2 will execute as synchronous and workflow2 will finish first before workflow 1 finishes (I don’t think this will be the case)
- Does above code guarantee if workflow2 will start for sure
- Is this recommended way to start nested workflow