|
19 | 19 |
|
20 | 20 | import static com.uber.cadence.samples.common.SampleConstants.DOMAIN;
|
21 | 21 |
|
| 22 | +import com.google.common.base.Strings; |
22 | 23 | import com.uber.cadence.activity.ActivityMethod;
|
23 | 24 | import com.uber.cadence.client.WorkflowClient;
|
| 25 | +import com.uber.cadence.serviceclient.IWorkflowService; |
| 26 | +import com.uber.cadence.serviceclient.WorkflowServiceTChannel; |
24 | 27 | import com.uber.cadence.worker.Worker;
|
25 | 28 | import com.uber.cadence.workflow.Workflow;
|
26 | 29 | import com.uber.cadence.workflow.WorkflowMethod;
|
@@ -73,7 +76,18 @@ public String composeGreeting(String greeting, String name) {
|
73 | 76 |
|
74 | 77 | public static void main(String[] args) {
|
75 | 78 | // Start a worker that hosts both workflow and activity implementations.
|
76 |
| - Worker.Factory factory = new Worker.Factory(DOMAIN); |
| 79 | + final WorkflowServiceTChannel.ClientOptions.Builder builder = |
| 80 | + new WorkflowServiceTChannel.ClientOptions.Builder(); |
| 81 | + // Use 5 seconds as RPC timeout |
| 82 | + builder.setRpcTimeout(5 * 1000); |
| 83 | + IWorkflowService wfService = |
| 84 | + new WorkflowServiceTChannel( |
| 85 | + Strings.isNullOrEmpty(System.getenv("CADENCE_SEEDS")) |
| 86 | + ? "127.0.0.1" |
| 87 | + : System.getenv("CADENCE_SEEDS"), |
| 88 | + 7933, |
| 89 | + builder.build()); |
| 90 | + Worker.Factory factory = new Worker.Factory(wfService, DOMAIN); |
77 | 91 | Worker worker = factory.newWorker(TASK_LIST);
|
78 | 92 | // Workflows are stateful. So you need a type to create instances.
|
79 | 93 | worker.registerWorkflowImplementationTypes(GreetingWorkflowImpl.class);
|
|
0 commit comments