Skip to content

Commit fcabede

Browse files
authored
Update package (#2)
update java client package
1 parent d269060 commit fcabede

24 files changed

+71
-64
lines changed

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ repositories {
3333
}
3434

3535
dependencies {
36-
compile group: 'com.uber.cadence', name: 'cadence-client', version: '0.1.0'
36+
compile group: 'com.uber.cadence', name: 'cadence-client', version: '2.0.0'
3737
compile group: 'com.amazonaws', name: 'aws-java-sdk-s3', version: '1.11.274'
3838
compile group: 'commons-configuration', name: 'commons-configuration', version: '1.9'
3939
compile group: 'ch.qos.logback', name: 'logback-classic', version: '1.2.3'

src/main/java/com/uber/cadence/samples/common/QueryWorkflowExecutionLocalReplay.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,8 @@ public static void main(String[] args) throws Exception {
5353
@SuppressWarnings("unchecked")
5454
Class<Object> workflowImplementationType =
5555
(Class<Object>) Class.forName(implementationTypeName);
56-
Worker replayer = new Worker(cadenceService, DOMAIN, null, null);
56+
Worker.Factory factory = new Worker.Factory(cadenceService, DOMAIN);
57+
Worker replayer = factory.newWorker("ignored");
5758
replayer.registerWorkflowImplementationTypes(workflowImplementationType);
5859
System.out.println("Beginning query replay for " + workflowExecution);
5960
String queryResult =

src/main/java/com/uber/cadence/samples/fileprocessing/FileProcessingWorker.java

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -37,18 +37,20 @@ public static void main(String[] args) {
3737

3838
String hostSpecifiTaskList = ManagementFactory.getRuntimeMXBean().getName();
3939

40-
// Start worker to poll the common task list.
41-
final Worker workerForCommonTaskList = new Worker(DOMAIN, TASK_LIST);
40+
// Get worker to poll the common task list.
41+
Worker.Factory factory = new Worker.Factory(DOMAIN);
42+
final Worker workerForCommonTaskList = factory.newWorker(TASK_LIST);
4243
workerForCommonTaskList.registerWorkflowImplementationTypes(FileProcessingWorkflowImpl.class);
4344
StoreActivitiesImpl storeActivityImpl = new StoreActivitiesImpl(hostSpecifiTaskList);
4445
workerForCommonTaskList.registerActivitiesImplementations(storeActivityImpl);
45-
workerForCommonTaskList.start();
46-
System.out.println("Worker started for task list: " + TASK_LIST);
4746

48-
// Start worker to poll the host-specific task list.
49-
final Worker workerForHostSpecificTaskList = new Worker(DOMAIN, hostSpecifiTaskList);
47+
// Get worker to poll the host-specific task list.
48+
final Worker workerForHostSpecificTaskList =factory.newWorker(hostSpecifiTaskList);
5049
workerForHostSpecificTaskList.registerActivitiesImplementations(storeActivityImpl);
51-
workerForHostSpecificTaskList.start();
50+
51+
// Start all workers created by this factory.
52+
factory.start();
53+
System.out.println("Worker started for task list: " + TASK_LIST);
5254
System.out.println("Worker Started for activity task List: " + hostSpecifiTaskList);
5355
}
5456
}

src/main/java/com/uber/cadence/samples/hello/HelloActivity.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,13 +73,14 @@ public String composeGreeting(String greeting, String name) {
7373

7474
public static void main(String[] args) {
7575
// Start a worker that hosts both workflow and activity implementations.
76-
Worker worker = new Worker(DOMAIN, TASK_LIST);
76+
Worker.Factory factory = new Worker.Factory(DOMAIN);
77+
Worker worker = factory.newWorker(TASK_LIST);
7778
// Workflows are stateful. So you need a type to create instances.
7879
worker.registerWorkflowImplementationTypes(GreetingWorkflowImpl.class);
7980
// Activities are stateless and thread safe. So a shared instance is used.
8081
worker.registerActivitiesImplementations(new GreetingActivitiesImpl());
8182
// Start listening to the workflow and activity task lists.
82-
worker.start();
83+
factory.start();
8384

8485
// Start a workflow execution. Usually this is done from another program.
8586
WorkflowClient workflowClient = WorkflowClient.newInstance(DOMAIN);

src/main/java/com/uber/cadence/samples/hello/HelloActivityRetry.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,13 +100,14 @@ public synchronized String composeGreeting(String greeting, String name) {
100100

101101
public static void main(String[] args) {
102102
// Start a worker that hosts both workflow and activity implementations.
103-
Worker worker = new Worker(DOMAIN, TASK_LIST);
103+
Worker.Factory factory = new Worker.Factory(DOMAIN);
104+
Worker worker = factory.newWorker(TASK_LIST);
104105
// Workflows are stateful. So you need a type to create instances.
105106
worker.registerWorkflowImplementationTypes(GreetingWorkflowImpl.class);
106107
// Activities are stateless and thread safe. So a shared instance is used.
107108
worker.registerActivitiesImplementations(new GreetingActivitiesImpl());
108109
// Start listening to the workflow and activity task lists.
109-
worker.start();
110+
factory.start();
110111

111112
// Start a workflow execution. Usually this is done from another program.
112113
WorkflowClient workflowClient = WorkflowClient.newInstance(DOMAIN);

src/main/java/com/uber/cadence/samples/hello/HelloAsync.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,13 +80,14 @@ public String composeGreeting(String greeting, String name) {
8080

8181
public static void main(String[] args) {
8282
// Start a worker that hosts both workflow and activity implementations.
83-
Worker worker = new Worker(DOMAIN, TASK_LIST);
83+
Worker.Factory factory = new Worker.Factory(DOMAIN);
84+
Worker worker = factory.newWorker(TASK_LIST);
8485
// Workflows are stateful. So you need a type to create instances.
8586
worker.registerWorkflowImplementationTypes(GreetingWorkflowImpl.class);
8687
// Activities are stateless and thread safe. So a shared instance is used.
8788
worker.registerActivitiesImplementations(new GreetingActivitiesImpl());
8889
// Start listening to the workflow and activity task lists.
89-
worker.start();
90+
factory.start();
9091

9192
// Start a workflow execution. Usually this is done from another program.
9293
WorkflowClient workflowClient = WorkflowClient.newInstance(DOMAIN);

src/main/java/com/uber/cadence/samples/hello/HelloAsyncActivityCompletion.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,15 +105,16 @@ public static void main(String[] args) throws ExecutionException, InterruptedExc
105105
WorkflowClient workflowClient = WorkflowClient.newInstance(DOMAIN);
106106

107107
// Start a worker that hosts both workflow and activity implementations.
108-
Worker worker = new Worker(DOMAIN, TASK_LIST);
108+
Worker.Factory factory = new Worker.Factory(DOMAIN);
109+
Worker worker = factory.newWorker(TASK_LIST);
109110
// Workflows are stateful. So you need a type to create instances.
110111
worker.registerWorkflowImplementationTypes(GreetingWorkflowImpl.class);
111112
// Activities are stateless and thread safe. So a shared instance is used.
112113
// CompletionClient is passed to activity here only to support unit testing.
113114
ActivityCompletionClient completionClient = workflowClient.newActivityCompletionClient();
114115
worker.registerActivitiesImplementations(new GreetingActivitiesImpl(completionClient));
115116
// Start listening to the workflow and activity task lists.
116-
worker.start();
117+
factory.start();
117118

118119
// Get a workflow stub using the same task list the worker uses.
119120
GreetingWorkflow workflow = workflowClient.newWorkflowStub(GreetingWorkflow.class);

src/main/java/com/uber/cadence/samples/hello/HelloAsyncLambda.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,13 +101,14 @@ public String composeGreeting(String greeting, String name) {
101101

102102
public static void main(String[] args) {
103103
// Start a worker that hosts both workflow and activity implementations.
104-
Worker worker = new Worker(DOMAIN, TASK_LIST);
104+
Worker.Factory factory = new Worker.Factory(DOMAIN);
105+
Worker worker = factory.newWorker(TASK_LIST);
105106
// Workflows are stateful. So you need a type to create instances.
106107
worker.registerWorkflowImplementationTypes(GreetingWorkflowImpl.class);
107108
// Activities are stateless and thread safe. So a shared instance is used.
108109
worker.registerActivitiesImplementations(new GreetingActivitiesImpl());
109110
// Start listening to the workflow and activity task lists.
110-
worker.start();
111+
factory.start();
111112

112113
// Start a workflow execution. Usually this is done from another program.
113114
WorkflowClient workflowClient = WorkflowClient.newInstance(DOMAIN);

src/main/java/com/uber/cadence/samples/hello/HelloChild.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,10 +72,11 @@ public String composeGreeting(String greeting, String name) {
7272

7373
public static void main(String[] args) {
7474
// Start a worker that hosts both parent and child workflow implementations.
75-
Worker worker = new Worker(DOMAIN, TASK_LIST);
75+
Worker.Factory factory = new Worker.Factory(DOMAIN);
76+
Worker worker = factory.newWorker(TASK_LIST);
7677
worker.registerWorkflowImplementationTypes(GreetingWorkflowImpl.class, GreetingChildImpl.class);
7778
// Start listening to the workflow task list.
78-
worker.start();
79+
factory.start();
7980

8081
// Start a workflow execution. Usually this is done from another program.
8182
WorkflowClient workflowClient = WorkflowClient.newInstance(DOMAIN);

src/main/java/com/uber/cadence/samples/hello/HelloException.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -159,10 +159,11 @@ public String composeGreeting(String greeting, String name) {
159159
}
160160

161161
public static void main(String[] args) {
162-
Worker worker = new Worker(DOMAIN, TASK_LIST);
162+
Worker.Factory factory = new Worker.Factory(DOMAIN);
163+
Worker worker = factory.newWorker(TASK_LIST);
163164
worker.registerWorkflowImplementationTypes(GreetingWorkflowImpl.class, GreetingChildImpl.class);
164165
worker.registerActivitiesImplementations(new GreetingActivitiesImpl());
165-
worker.start();
166+
factory.start();
166167

167168
WorkflowClient workflowClient = WorkflowClient.newInstance(DOMAIN);
168169
WorkflowOptions workflowOptions =

0 commit comments

Comments
 (0)