Skip to content

Commit 52a99c3

Browse files
authored
Updated to reflect SDK changes (#6)
* Fixes due to proto changes * Updated to the latest version of Java library
1 parent 409b3d2 commit 52a99c3

23 files changed

Lines changed: 129 additions & 49 deletions

build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ googleJavaFormat {
1515
}
1616

1717
group = 'com.uber'
18-
version = '0.10.0-SNAPSHOT'
18+
version = '0.20.0-SNAPSHOT'
1919

2020
description = "Temporal Java SDK Samples"
2121

@@ -36,7 +36,7 @@ repositories {
3636
}
3737

3838
dependencies {
39-
compile group: 'io.temporal', name: 'temporal-sdk', version: '0.10.0-SNAPSHOT'
39+
compile group: 'io.temporal', name: 'temporal-sdk', version: '0.20.0-SNAPSHOT'
4040

4141
compile group: 'commons-configuration', name: 'commons-configuration', version: '1.9'
4242
compile group: 'ch.qos.logback', name: 'logback-classic', version: '1.2.3'

src/main/java/io/temporal/samples/bookingsaga/TripBookingActivities.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@
1919

2020
package io.temporal.samples.bookingsaga;
2121

22+
import io.temporal.activity.ActivityInterface;
23+
24+
@ActivityInterface
2225
public interface TripBookingActivities {
2326

2427
/**

src/main/java/io/temporal/samples/bookingsaga/TripBookingWorkflow.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,10 @@
2121

2222
import static io.temporal.samples.bookingsaga.TripBookingSaga.TASK_LIST;
2323

24+
import io.temporal.workflow.WorkflowInterface;
2425
import io.temporal.workflow.WorkflowMethod;
2526

27+
@WorkflowInterface
2628
public interface TripBookingWorkflow {
2729

2830
@WorkflowMethod(executionStartToCloseTimeoutSeconds = 3600, taskList = TASK_LIST)

src/main/java/io/temporal/samples/common/QueryWorkflowExecution.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121

2222
import io.temporal.client.WorkflowClient;
2323
import io.temporal.client.WorkflowStub;
24-
import io.temporal.proto.common.WorkflowExecution;
24+
import io.temporal.proto.execution.WorkflowExecution;
2525
import io.temporal.serviceclient.WorkflowServiceStubs;
2626
import java.util.Optional;
2727

src/main/java/io/temporal/samples/fileprocessing/FileProcessingWorkflow.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,12 @@
1919

2020
package io.temporal.samples.fileprocessing;
2121

22+
import io.temporal.workflow.WorkflowInterface;
2223
import io.temporal.workflow.WorkflowMethod;
2324
import java.net.URL;
2425

2526
/** Contract for file processing workflow. */
27+
@WorkflowInterface
2628
public interface FileProcessingWorkflow {
2729

2830
@WorkflowMethod(

src/main/java/io/temporal/samples/fileprocessing/StoreActivities.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,10 @@
1919

2020
package io.temporal.samples.fileprocessing;
2121

22+
import io.temporal.activity.ActivityInterface;
2223
import java.net.URL;
2324

25+
@ActivityInterface
2426
public interface StoreActivities {
2527

2628
final class TaskListFileNamePair {

src/main/java/io/temporal/samples/hello/HelloActivity.java

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,17 @@
1919

2020
package io.temporal.samples.hello;
2121

22+
import io.temporal.activity.ActivityInterface;
2223
import io.temporal.activity.ActivityMethod;
24+
import io.temporal.activity.ActivityOptions;
2325
import io.temporal.client.WorkflowClient;
2426
import io.temporal.serviceclient.WorkflowServiceStubs;
2527
import io.temporal.worker.Worker;
2628
import io.temporal.worker.WorkerFactory;
2729
import io.temporal.workflow.Workflow;
30+
import io.temporal.workflow.WorkflowInterface;
2831
import io.temporal.workflow.WorkflowMethod;
32+
import java.time.Duration;
2933

3034
/**
3135
* Hello World Temporal workflow that executes a single activity. Requires a local instance the
@@ -36,15 +40,17 @@ public class HelloActivity {
3640
static final String TASK_LIST = "HelloActivity";
3741

3842
/** Workflow interface has to have at least one method annotated with @WorkflowMethod. */
43+
@WorkflowInterface
3944
public interface GreetingWorkflow {
4045
/** @return greeting string */
4146
@WorkflowMethod(executionStartToCloseTimeoutSeconds = 10, taskList = TASK_LIST)
4247
String getGreeting(String name);
4348
}
4449

4550
/** Activity interface is just a POJI. */
51+
@ActivityInterface
4652
public interface GreetingActivities {
47-
@ActivityMethod(scheduleToCloseTimeoutSeconds = 2)
53+
@ActivityMethod
4854
String composeGreeting(String greeting, String name);
4955
}
5056

@@ -57,7 +63,9 @@ public static class GreetingWorkflowImpl implements GreetingWorkflow {
5763
* activity invocations.
5864
*/
5965
private final GreetingActivities activities =
60-
Workflow.newActivityStub(GreetingActivities.class);
66+
Workflow.newActivityStub(
67+
GreetingActivities.class,
68+
ActivityOptions.newBuilder().setScheduleToCloseTimeout(Duration.ofSeconds(2)).build());
6169

6270
@Override
6371
public String getGreeting(String name) {

src/main/java/io/temporal/samples/hello/HelloActivityRetry.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919

2020
package io.temporal.samples.hello;
2121

22+
import io.temporal.activity.ActivityInterface;
2223
import io.temporal.activity.ActivityOptions;
2324
import io.temporal.client.WorkflowClient;
2425
import io.temporal.client.WorkflowOptions;
@@ -28,6 +29,7 @@
2829
import io.temporal.worker.WorkerFactory;
2930
import io.temporal.workflow.Functions;
3031
import io.temporal.workflow.Workflow;
32+
import io.temporal.workflow.WorkflowInterface;
3133
import io.temporal.workflow.WorkflowMethod;
3234
import java.time.Duration;
3335

@@ -39,12 +41,14 @@ public class HelloActivityRetry {
3941

4042
static final String TASK_LIST = "HelloActivityRetry";
4143

44+
@WorkflowInterface
4245
public interface GreetingWorkflow {
4346
/** @return greeting string */
4447
@WorkflowMethod
4548
String getGreeting(String name);
4649
}
4750

51+
@ActivityInterface
4852
public interface GreetingActivities {
4953
String composeGreeting(String greeting, String name);
5054
}

src/main/java/io/temporal/samples/hello/HelloAsync.java

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@
1919

2020
package io.temporal.samples.hello;
2121

22-
import io.temporal.activity.ActivityMethod;
22+
import io.temporal.activity.ActivityInterface;
23+
import io.temporal.activity.ActivityOptions;
2324
import io.temporal.client.WorkflowClient;
2425
import io.temporal.serviceclient.WorkflowServiceStubs;
2526
import io.temporal.worker.Worker;
@@ -28,7 +29,9 @@
2829
import io.temporal.workflow.Functions.Func;
2930
import io.temporal.workflow.Promise;
3031
import io.temporal.workflow.Workflow;
32+
import io.temporal.workflow.WorkflowInterface;
3133
import io.temporal.workflow.WorkflowMethod;
34+
import java.time.Duration;
3235

3336
/**
3437
* Demonstrates asynchronous activity invocation. Requires a local instance of Temporal server to be
@@ -38,13 +41,14 @@ public class HelloAsync {
3841

3942
static final String TASK_LIST = "HelloAsync";
4043

44+
@WorkflowInterface
4145
public interface GreetingWorkflow {
4246
@WorkflowMethod(executionStartToCloseTimeoutSeconds = 15, taskList = TASK_LIST)
4347
String getGreeting(String name);
4448
}
4549

50+
@ActivityInterface
4651
public interface GreetingActivities {
47-
@ActivityMethod(scheduleToCloseTimeoutSeconds = 10)
4852
String composeGreeting(String greeting, String name);
4953
}
5054

@@ -60,7 +64,9 @@ public static class GreetingWorkflowImpl implements GreetingWorkflow {
6064
* activity invocations.
6165
*/
6266
private final GreetingActivities activities =
63-
Workflow.newActivityStub(GreetingActivities.class);
67+
Workflow.newActivityStub(
68+
GreetingActivities.class,
69+
ActivityOptions.newBuilder().setScheduleToCloseTimeout(Duration.ofSeconds(10)).build());
6470

6571
@Override
6672
public String getGreeting(String name) {

src/main/java/io/temporal/samples/hello/HelloAsyncActivityCompletion.java

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,17 @@
2020
package io.temporal.samples.hello;
2121

2222
import io.temporal.activity.Activity;
23-
import io.temporal.activity.ActivityMethod;
23+
import io.temporal.activity.ActivityInterface;
24+
import io.temporal.activity.ActivityOptions;
2425
import io.temporal.client.ActivityCompletionClient;
2526
import io.temporal.client.WorkflowClient;
2627
import io.temporal.serviceclient.WorkflowServiceStubs;
2728
import io.temporal.worker.Worker;
2829
import io.temporal.worker.WorkerFactory;
2930
import io.temporal.workflow.Workflow;
31+
import io.temporal.workflow.WorkflowInterface;
3032
import io.temporal.workflow.WorkflowMethod;
33+
import java.time.Duration;
3134
import java.util.concurrent.CompletableFuture;
3235
import java.util.concurrent.ExecutionException;
3336
import java.util.concurrent.ForkJoinPool;
@@ -40,15 +43,16 @@ public class HelloAsyncActivityCompletion {
4043

4144
static final String TASK_LIST = "HelloAsyncActivityCompletion";
4245

46+
@WorkflowInterface
4347
public interface GreetingWorkflow {
4448
/** @return greeting string */
4549
@WorkflowMethod(executionStartToCloseTimeoutSeconds = 15, taskList = TASK_LIST)
4650
String getGreeting(String name);
4751
}
4852

4953
/** Activity interface is just a POJI. * */
54+
@ActivityInterface
5055
public interface GreetingActivities {
51-
@ActivityMethod(scheduleToCloseTimeoutSeconds = 10)
5256
String composeGreeting(String greeting, String name);
5357
}
5458

@@ -61,7 +65,9 @@ public static class GreetingWorkflowImpl implements GreetingWorkflow {
6165
* activity invocations.
6266
*/
6367
private final GreetingActivities activities =
64-
Workflow.newActivityStub(GreetingActivities.class);
68+
Workflow.newActivityStub(
69+
GreetingActivities.class,
70+
ActivityOptions.newBuilder().setScheduleToCloseTimeout(Duration.ofSeconds(10)).build());
6571

6672
@Override
6773
public String getGreeting(String name) {

0 commit comments

Comments
 (0)