File tree 1 file changed +15
-0
lines changed
src/main/java/com/uber/cadence/samples/hello
1 file changed +15
-0
lines changed Original file line number Diff line number Diff line change 19
19
20
20
import static com .uber .cadence .samples .common .SampleConstants .DOMAIN ;
21
21
22
+ import com .uber .cadence .WorkflowExecution ;
22
23
import com .uber .cadence .client .WorkflowClient ;
23
24
import com .uber .cadence .worker .Worker ;
24
25
import com .uber .cadence .workflow .Async ;
@@ -58,6 +59,20 @@ public String getGreeting(String name) {
58
59
// Do something else here.
59
60
return greeting .get (); // blocks waiting for the child to complete.
60
61
}
62
+
63
+ // This example shows how parent workflow return right after starting a child workflow,
64
+ // and let the child run itself.
65
+ private String demoAsyncChildRun (String name ) {
66
+ GreetingChild child = Workflow .newChildWorkflowStub (GreetingChild .class );
67
+ // non blocking call that initiated child workflow
68
+ Async .function (child ::composeGreeting , "Hello" , name );
69
+ // instead of using greeting.get() to block till child complete,
70
+ // sometimes we just want to return parent immediately and keep child running
71
+ Promise <WorkflowExecution > childPromise = Workflow .getWorkflowExecution (child );
72
+ childPromise .get (); // block until child started,
73
+ // otherwise child may not start because parent complete first.
74
+ return "let child run, parent just return" ;
75
+ }
61
76
}
62
77
63
78
/**
You can’t perform that action at this time.
0 commit comments