# Behavior for Nested workflow started without ChildWorkflowOptions

**URL:** <https://community.temporal.io/t/behavior-for-nested-workflow-started-without-childworkflowoptions/9468>\
**Category:** Community Support\
**Tags:** java-sdk, child-workflow\
**Created:** [September 14, 2023, 12:22am UTC](https://community.temporal.io/t/behavior-for-nested-workflow-started-without-childworkflowoptions/9468 "2023-09-14T00:22:12Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![shivamtiwari2009](https://avatars.discourse-cdn.com/v4/letter/s/d26b3c/32.png) [@shivamtiwari2009](https://community.temporal.io/u/shivamtiwari2009)\
**Post date:** [September 14, 2023, 12:22am UTC](https://community.temporal.io/t/behavior-for-nested-workflow-started-without-childworkflowoptions/9468/1 "2023-09-14T00:22:12Z")

</div>

Say I have two workflows  
**Workflow1**

```auto
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**

```auto
public Workflow1Impl implements Workflow1 {

  SomeActivity someActivity = .....
  
  public void execute() {
       someActivity.startWorkflow2();
  }
}

```

SomeActivityImpl

```auto
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

1. workflow2 will be async?
2. 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
3. workflow2 will execute as synchronous and workflow2 will finish first before workflow 1 finishes (I don’t think this will be the case)
4. Does above code guarantee if workflow2 will start for sure
5. Is this recommended way to start nested workflow

---

<div class="post-metadata">

**Author:** ![tihomir](https://sea2.discourse-cdn.com/flex016/user_avatar/community.temporal.io/tihomir/32/6580_2.png) [@tihomir](https://community.temporal.io/u/tihomir)\
**Post date:** [September 19, 2023, 3:37am UTC](https://community.temporal.io/t/behavior-for-nested-workflow-started-without-childworkflowoptions/9468/2 "2023-09-19T03:37:46Z")

</div>

1. You are invoking this workflow async from activity using WorkflowClient.start, so yes this api unblocks as soon as workflow2 is created. Would make sure you handle exceptions here in case a workflow execution with this set workflow id is already running, or set workflow id reuse policy to “terminate” if thats your use case.

2. No, this created workflow is independent (not a child), same as when you create it from client.

3. Either will not affect the execution of the other. Completion of workflow2 is not recorded in workflow1 event history

4. If WorkflowClient.start in your activity code does not fail, yes

5. That is up to you, if you need to have the parent-child relationship and parent close policy defined then use child workflow.

---

<div class="post-metadata">

**Author:** ![shivamtiwari2009](https://avatars.discourse-cdn.com/v4/letter/s/d26b3c/32.png) [@shivamtiwari2009](https://community.temporal.io/u/shivamtiwari2009)\
**Post date:** [September 20, 2023, 1:52pm UTC](https://community.temporal.io/t/behavior-for-nested-workflow-started-without-childworkflowoptions/9468/3 "2023-09-20T13:52:06Z")

</div>

Thanks @tihomir
