How to set Parent Close Policy in Java
Set Parent Close Policy on an instance of ChildWorkflowOptions using ChildWorkflowOptions.newBuilder().setParentClosePolicy.
- Type: ChildWorkflowOptions.Builder
- Default: None.
   public void parentWorkflow() {
       ChildWorkflowOptions options =
          ChildWorkflowOptions.newBuilder()
              .setParentClosePolicy(ParentClosePolicy.PARENT_CLOSE_POLICY_ABANDON)
              .build();
       MyChildWorkflow child = Workflow.newChildWorkflowStub(MyChildWorkflow.class, options);
       Async.procedure(child::<workflowMethod>, <args>...);
       Promise<WorkflowExecution> childExecution = Workflow.getWorkflowExecution(child);
       // Wait for child to start
       childExecution.get()
  }
In this example, we are:
- Setting ChildWorkflowOptions.ParentClosePolicytoABANDONwhen creating a Child Workflow stub.
- Starting Child Workflow Execution asynchronously using Async.functionorAsync.procedure.
- Calling Workflow.getWorkflowExecution(…)on the child stub.
- Waiting for the Promisereturned bygetWorkflowExecutionto complete. This indicates whether the Child Workflow started successfully (or failed).
- Completing parent Workflow Execution asynchronously.
Steps 3 and 4 are needed to ensure that a Child Workflow Execution starts before the parent closes. If the parent initiates a Child Workflow Execution and then completes immediately after, the Child Workflow will never execute.