Skip to content

Commit 878cfe0

Browse files
authored
Add child workflow implementation under the new worker config for cadence samples
Add child workflow implementation under the new worker config
2 parents fdf3938 + 3989491 commit 878cfe0

File tree

5 files changed

+50
-1
lines changed

5 files changed

+50
-1
lines changed

src/main/java/com/uber/cadence/samples/spring/cadence/CadenceAutoConfiguration.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,9 @@
2222

2323
import com.uber.cadence.client.WorkflowClient;
2424
import com.uber.cadence.client.WorkflowClientOptions;
25+
import com.uber.cadence.samples.spring.workflows.impl.ChildWorkflowImpl;
2526
import com.uber.cadence.samples.spring.workflows.impl.HelloWorldWorkflowImpl;
27+
import com.uber.cadence.samples.spring.workflows.impl.ParentWorkflowImpl;
2628
import com.uber.cadence.samples.spring.workflows.impl.SignalWorkflowImpl;
2729
import com.uber.cadence.serviceclient.ClientOptions;
2830
import com.uber.cadence.serviceclient.WorkflowServiceTChannel;
@@ -53,7 +55,10 @@ public void startWorker(ApplicationStartedEvent event) {
5355
Worker worker = factory.newWorker(TASK_LIST);
5456

5557
worker.registerWorkflowImplementationTypes(
56-
HelloWorldWorkflowImpl.class, SignalWorkflowImpl.class);
58+
HelloWorldWorkflowImpl.class,
59+
SignalWorkflowImpl.class,
60+
ParentWorkflowImpl.class,
61+
ChildWorkflowImpl.class);
5762
factory.start();
5863
}
5964
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
package com.uber.cadence.samples.spring.workflows;
2+
3+
import com.uber.cadence.workflow.WorkflowMethod;
4+
5+
public interface ChildWorkflow {
6+
@WorkflowMethod
7+
String greetInChild(String msg);
8+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
package com.uber.cadence.samples.spring.workflows;
2+
3+
import static com.uber.cadence.samples.spring.common.Constant.TASK_LIST;
4+
5+
import com.uber.cadence.samples.spring.models.SampleMessage;
6+
import com.uber.cadence.workflow.WorkflowMethod;
7+
8+
public interface ParentWorkflow {
9+
@WorkflowMethod(executionStartToCloseTimeoutSeconds = 10, taskList = TASK_LIST)
10+
String getGreetingInParent(SampleMessage sampleMessage);
11+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
package com.uber.cadence.samples.spring.workflows.impl;
2+
3+
import com.uber.cadence.samples.spring.workflows.ChildWorkflow;
4+
5+
public class ChildWorkflowImpl implements ChildWorkflow {
6+
@Override
7+
public String greetInChild(String msg) {
8+
return "Hello, " + msg + "!";
9+
}
10+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
package com.uber.cadence.samples.spring.workflows.impl;
2+
3+
import com.uber.cadence.samples.spring.models.SampleMessage;
4+
import com.uber.cadence.samples.spring.workflows.ChildWorkflow;
5+
import com.uber.cadence.samples.spring.workflows.ParentWorkflow;
6+
import com.uber.cadence.workflow.Workflow;
7+
8+
public class ParentWorkflowImpl implements ParentWorkflow {
9+
@Override
10+
public String getGreetingInParent(SampleMessage sampleMessage) {
11+
// Workflows are stateful. So a new stub must be created for each new child.
12+
ChildWorkflow childWorkflow = Workflow.newChildWorkflowStub(ChildWorkflow.class);
13+
return childWorkflow.greetInChild(sampleMessage.GetMessage());
14+
}
15+
}

0 commit comments

Comments
 (0)