Skip to content

Commit fdf3938

Browse files
authored
Merge pull request #74 from uber/client-helloworld
Add hello world client java sample
2 parents 2732c6b + fcf4300 commit fdf3938

File tree

2 files changed

+76
-0
lines changed

2 files changed

+76
-0
lines changed
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
/*
2+
* Copyright 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
3+
*
4+
* Modifications copyright (C) 2017 Uber Technologies, Inc.
5+
*
6+
* Licensed under the Apache License, Version 2.0 (the "License"). You may not
7+
* use this file except in compliance with the License. A copy of the License is
8+
* located at
9+
*
10+
* http://aws.amazon.com/apache2.0
11+
*
12+
* or in the "license" file accompanying this file. This file is distributed on
13+
* an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
14+
* express or implied. See the License for the specific language governing
15+
* permissions and limitations under the License.
16+
*/
17+
18+
package com.uber.cadence.samples.clientsamples;
19+
20+
import static com.uber.cadence.samples.common.SampleConstants.DOMAIN;
21+
22+
import com.uber.cadence.client.WorkflowClient;
23+
import com.uber.cadence.client.WorkflowClientOptions;
24+
import com.uber.cadence.serviceclient.ClientOptions;
25+
import com.uber.cadence.serviceclient.WorkflowServiceTChannel;
26+
27+
public class CadenceUtil {
28+
public static WorkflowClient getWorkflowClient() {
29+
return WorkflowClient.newInstance(
30+
new WorkflowServiceTChannel(ClientOptions.defaultInstance()),
31+
WorkflowClientOptions.newBuilder().setDomain(DOMAIN).build());
32+
}
33+
}
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
/*
2+
* Copyright 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
3+
*
4+
* Modifications copyright (C) 2017 Uber Technologies, Inc.
5+
*
6+
* Licensed under the Apache License, Version 2.0 (the "License"). You may not
7+
* use this file except in compliance with the License. A copy of the License is
8+
* located at
9+
*
10+
* http://aws.amazon.com/apache2.0
11+
*
12+
* or in the "license" file accompanying this file. This file is distributed on
13+
* an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
14+
* express or implied. See the License for the specific language governing
15+
* permissions and limitations under the License.
16+
*/
17+
18+
package com.uber.cadence.samples.clientsamples;
19+
20+
import com.uber.cadence.WorkflowExecution;
21+
import com.uber.cadence.client.WorkflowClient;
22+
import com.uber.cadence.client.WorkflowOptions;
23+
import com.uber.cadence.samples.spring.common.Constant;
24+
import com.uber.cadence.samples.spring.models.SampleMessage;
25+
import com.uber.cadence.samples.spring.workflows.HelloWorldWorkflow;
26+
import java.time.Duration;
27+
28+
public class HelloWorldSample {
29+
public static void main(String[] args) {
30+
WorkflowClient workflowClient = CadenceUtil.getWorkflowClient();
31+
WorkflowOptions workflowOptions =
32+
new WorkflowOptions.Builder()
33+
.setExecutionStartToCloseTimeout(Duration.ofSeconds(30))
34+
.setTaskList(Constant.TASK_LIST)
35+
.build();
36+
37+
HelloWorldWorkflow helloWorldWorkflow =
38+
workflowClient.newWorkflowStub(HelloWorldWorkflow.class, workflowOptions);
39+
WorkflowExecution execution =
40+
WorkflowClient.start(helloWorldWorkflow::sayHello, new SampleMessage("Uber"));
41+
System.out.printf("WorkflowID: %s, RunID: %s", execution.getWorkflowId(), execution.getRunId());
42+
}
43+
}

0 commit comments

Comments
 (0)