Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ googleJavaFormat {
}

group = 'com.uber'
version = '0.10.0-SNAPSHOT'
version = '0.20.0-SNAPSHOT'

description = "Temporal Java SDK Samples"

Expand All @@ -36,7 +36,7 @@ repositories {
}

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

compile group: 'commons-configuration', name: 'commons-configuration', version: '1.9'
compile group: 'ch.qos.logback', name: 'logback-classic', version: '1.2.3'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@

package io.temporal.samples.bookingsaga;

import io.temporal.activity.ActivityInterface;

@ActivityInterface
public interface TripBookingActivities {

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,10 @@

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

import io.temporal.workflow.WorkflowInterface;
import io.temporal.workflow.WorkflowMethod;

@WorkflowInterface
public interface TripBookingWorkflow {

@WorkflowMethod(executionStartToCloseTimeoutSeconds = 3600, taskList = TASK_LIST)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

import io.temporal.client.WorkflowClient;
import io.temporal.client.WorkflowStub;
import io.temporal.proto.common.WorkflowExecution;
import io.temporal.proto.execution.WorkflowExecution;
import io.temporal.serviceclient.WorkflowServiceStubs;
import java.util.Optional;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,12 @@

package io.temporal.samples.fileprocessing;

import io.temporal.workflow.WorkflowInterface;
import io.temporal.workflow.WorkflowMethod;
import java.net.URL;

/** Contract for file processing workflow. */
@WorkflowInterface
public interface FileProcessingWorkflow {

@WorkflowMethod(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,10 @@

package io.temporal.samples.fileprocessing;

import io.temporal.activity.ActivityInterface;
import java.net.URL;

@ActivityInterface
public interface StoreActivities {

final class TaskListFileNamePair {
Expand Down
12 changes: 10 additions & 2 deletions src/main/java/io/temporal/samples/hello/HelloActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,17 @@

package io.temporal.samples.hello;

import io.temporal.activity.ActivityInterface;
import io.temporal.activity.ActivityMethod;
import io.temporal.activity.ActivityOptions;
import io.temporal.client.WorkflowClient;
import io.temporal.serviceclient.WorkflowServiceStubs;
import io.temporal.worker.Worker;
import io.temporal.worker.WorkerFactory;
import io.temporal.workflow.Workflow;
import io.temporal.workflow.WorkflowInterface;
import io.temporal.workflow.WorkflowMethod;
import java.time.Duration;

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

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

/** Activity interface is just a POJI. */
@ActivityInterface
public interface GreetingActivities {
@ActivityMethod(scheduleToCloseTimeoutSeconds = 2)
@ActivityMethod
String composeGreeting(String greeting, String name);
}

Expand All @@ -57,7 +63,9 @@ public static class GreetingWorkflowImpl implements GreetingWorkflow {
* activity invocations.
*/
private final GreetingActivities activities =
Workflow.newActivityStub(GreetingActivities.class);
Workflow.newActivityStub(
GreetingActivities.class,
ActivityOptions.newBuilder().setScheduleToCloseTimeout(Duration.ofSeconds(2)).build());

@Override
public String getGreeting(String name) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

package io.temporal.samples.hello;

import io.temporal.activity.ActivityInterface;
import io.temporal.activity.ActivityOptions;
import io.temporal.client.WorkflowClient;
import io.temporal.client.WorkflowOptions;
Expand All @@ -28,6 +29,7 @@
import io.temporal.worker.WorkerFactory;
import io.temporal.workflow.Functions;
import io.temporal.workflow.Workflow;
import io.temporal.workflow.WorkflowInterface;
import io.temporal.workflow.WorkflowMethod;
import java.time.Duration;

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

static final String TASK_LIST = "HelloActivityRetry";

@WorkflowInterface
public interface GreetingWorkflow {
/** @return greeting string */
@WorkflowMethod
String getGreeting(String name);
}

@ActivityInterface
public interface GreetingActivities {
String composeGreeting(String greeting, String name);
}
Expand Down
12 changes: 9 additions & 3 deletions src/main/java/io/temporal/samples/hello/HelloAsync.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@

package io.temporal.samples.hello;

import io.temporal.activity.ActivityMethod;
import io.temporal.activity.ActivityInterface;
import io.temporal.activity.ActivityOptions;
import io.temporal.client.WorkflowClient;
import io.temporal.serviceclient.WorkflowServiceStubs;
import io.temporal.worker.Worker;
Expand All @@ -28,7 +29,9 @@
import io.temporal.workflow.Functions.Func;
import io.temporal.workflow.Promise;
import io.temporal.workflow.Workflow;
import io.temporal.workflow.WorkflowInterface;
import io.temporal.workflow.WorkflowMethod;
import java.time.Duration;

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

static final String TASK_LIST = "HelloAsync";

@WorkflowInterface
public interface GreetingWorkflow {
@WorkflowMethod(executionStartToCloseTimeoutSeconds = 15, taskList = TASK_LIST)
String getGreeting(String name);
}

@ActivityInterface
public interface GreetingActivities {
@ActivityMethod(scheduleToCloseTimeoutSeconds = 10)
String composeGreeting(String greeting, String name);
}

Expand All @@ -60,7 +64,9 @@ public static class GreetingWorkflowImpl implements GreetingWorkflow {
* activity invocations.
*/
private final GreetingActivities activities =
Workflow.newActivityStub(GreetingActivities.class);
Workflow.newActivityStub(
GreetingActivities.class,
ActivityOptions.newBuilder().setScheduleToCloseTimeout(Duration.ofSeconds(10)).build());

@Override
public String getGreeting(String name) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,17 @@
package io.temporal.samples.hello;

import io.temporal.activity.Activity;
import io.temporal.activity.ActivityMethod;
import io.temporal.activity.ActivityInterface;
import io.temporal.activity.ActivityOptions;
import io.temporal.client.ActivityCompletionClient;
import io.temporal.client.WorkflowClient;
import io.temporal.serviceclient.WorkflowServiceStubs;
import io.temporal.worker.Worker;
import io.temporal.worker.WorkerFactory;
import io.temporal.workflow.Workflow;
import io.temporal.workflow.WorkflowInterface;
import io.temporal.workflow.WorkflowMethod;
import java.time.Duration;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.ForkJoinPool;
Expand All @@ -40,15 +43,16 @@ public class HelloAsyncActivityCompletion {

static final String TASK_LIST = "HelloAsyncActivityCompletion";

@WorkflowInterface
public interface GreetingWorkflow {
/** @return greeting string */
@WorkflowMethod(executionStartToCloseTimeoutSeconds = 15, taskList = TASK_LIST)
String getGreeting(String name);
}

/** Activity interface is just a POJI. * */
@ActivityInterface
public interface GreetingActivities {
@ActivityMethod(scheduleToCloseTimeoutSeconds = 10)
String composeGreeting(String greeting, String name);
}

Expand All @@ -61,7 +65,9 @@ public static class GreetingWorkflowImpl implements GreetingWorkflow {
* activity invocations.
*/
private final GreetingActivities activities =
Workflow.newActivityStub(GreetingActivities.class);
Workflow.newActivityStub(
GreetingActivities.class,
ActivityOptions.newBuilder().setScheduleToCloseTimeout(Duration.ofSeconds(10)).build());

@Override
public String getGreeting(String name) {
Expand Down
4 changes: 4 additions & 0 deletions src/main/java/io/temporal/samples/hello/HelloAsyncLambda.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

package io.temporal.samples.hello;

import io.temporal.activity.ActivityInterface;
import io.temporal.activity.ActivityOptions;
import io.temporal.client.WorkflowClient;
import io.temporal.client.WorkflowOptions;
Expand All @@ -28,6 +29,7 @@
import io.temporal.workflow.Async;
import io.temporal.workflow.Promise;
import io.temporal.workflow.Workflow;
import io.temporal.workflow.WorkflowInterface;
import io.temporal.workflow.WorkflowMethod;
import java.time.Duration;

Expand All @@ -39,13 +41,15 @@ public class HelloAsyncLambda {

static final String TASK_LIST = "HelloAsyncLambda";

@WorkflowInterface
public interface GreetingWorkflow {
/** @return greeting string */
@WorkflowMethod
String getGreeting(String name);
}

/** Activity interface is just a POJI. * */
@ActivityInterface
public interface GreetingActivities {
String getGreeting();

Expand Down
3 changes: 3 additions & 0 deletions src/main/java/io/temporal/samples/hello/HelloChild.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import io.temporal.workflow.Async;
import io.temporal.workflow.Promise;
import io.temporal.workflow.Workflow;
import io.temporal.workflow.WorkflowInterface;
import io.temporal.workflow.WorkflowMethod;

/**
Expand All @@ -36,13 +37,15 @@ public class HelloChild {
static final String TASK_LIST = "HelloChild";

/** The parent workflow interface. */
@WorkflowInterface
public interface GreetingWorkflow {
/** @return greeting string */
@WorkflowMethod(executionStartToCloseTimeoutSeconds = 10, taskList = TASK_LIST)
String getGreeting(String name);
}

/** The child workflow interface. */
@WorkflowInterface
public interface GreetingChild {
@WorkflowMethod
String composeGreeting(String greeting, String name);
Expand Down
6 changes: 5 additions & 1 deletion src/main/java/io/temporal/samples/hello/HelloCron.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,17 @@
package io.temporal.samples.hello;

import io.temporal.activity.Activity;
import io.temporal.activity.ActivityInterface;
import io.temporal.activity.ActivityOptions;
import io.temporal.client.DuplicateWorkflowException;
import io.temporal.client.WorkflowClient;
import io.temporal.client.WorkflowOptions;
import io.temporal.proto.common.WorkflowExecution;
import io.temporal.proto.execution.WorkflowExecution;
import io.temporal.serviceclient.WorkflowServiceStubs;
import io.temporal.worker.Worker;
import io.temporal.worker.WorkerFactory;
import io.temporal.workflow.Workflow;
import io.temporal.workflow.WorkflowInterface;
import io.temporal.workflow.WorkflowMethod;
import java.time.Duration;

Expand All @@ -43,6 +45,7 @@ public class HelloCron {
static final String TASK_LIST = "HelloCron";
static final String CRON_WORKFLOW_ID = "HelloCron";

@WorkflowInterface
public interface GreetingWorkflow {
/**
* Use single fixed ID to ensure that there is at most one instance running. To run multiple
Expand All @@ -59,6 +62,7 @@ public interface GreetingWorkflow {
void greet(String name);
}

@ActivityInterface
public interface GreetingActivities {
void greet(String greeting);
}
Expand Down
5 changes: 5 additions & 0 deletions src/main/java/io/temporal/samples/hello/HelloException.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
package io.temporal.samples.hello;

import com.google.common.base.Throwables;
import io.temporal.activity.ActivityInterface;
import io.temporal.activity.ActivityOptions;
import io.temporal.client.WorkflowClient;
import io.temporal.client.WorkflowException;
Expand All @@ -28,6 +29,7 @@
import io.temporal.worker.Worker;
import io.temporal.worker.WorkerFactory;
import io.temporal.workflow.Workflow;
import io.temporal.workflow.WorkflowInterface;
import io.temporal.workflow.WorkflowMethod;
import java.io.IOException;
import java.time.Duration;
Expand Down Expand Up @@ -107,16 +109,19 @@ public class HelloException {

static final String TASK_LIST = "HelloException";

@WorkflowInterface
public interface GreetingWorkflow {
@WorkflowMethod
String getGreeting(String name);
}

@WorkflowInterface
public interface GreetingChild {
@WorkflowMethod
String composeGreeting(String greeting, String name);
}

@ActivityInterface
public interface GreetingActivities {
String composeGreeting(String greeting, String name);
}
Expand Down
Loading