From 61bf7a9071fe443eb6f1722ccdb7a78fdd6ccd9b Mon Sep 17 00:00:00 2001 From: Maxim Fateev Date: Fri, 26 Jun 2020 19:19:32 -0700 Subject: [PATCH 1/4] 25.0 Release (#18) * Error handling and other proto changes in Java SDK (#17) * Updated temporal-sdk version to 0.25.0 --- build.gradle | 2 +- .../bookingsaga/TripBookingWorkflowImpl.java | 4 +- .../common/QueryWorkflowExecution.java | 2 +- .../fileprocessing/StoreActivities.java | 7 +++- .../samples/hello/HelloActivityRetry.java | 2 +- .../hello/HelloAsyncActivityCompletion.java | 10 +++-- .../io/temporal/samples/hello/HelloCron.java | 13 ++++-- .../temporal/samples/hello/HelloPeriodic.java | 9 ++-- .../samples/hello/HelloSearchAttributes.java | 15 ++++--- .../samples/moneytransfer/AccountImpl.java | 1 - .../AccountTransferWorkflowImpl.java | 5 +-- .../DynamicSleepWorkflowStarter.java | 11 ++--- src/main/resources/logback.xml | 2 +- .../bookingsaga/TripBookingWorkflowTest.java | 9 +++- .../fileprocessing/FileProcessingTest.java | 7 ++-- .../temporal/samples/hello/HelloCronTest.java | 2 +- .../samples/hello/HelloExceptionTest.java | 42 +++++++++++-------- .../samples/hello/HelloPeriodicTest.java | 15 +++---- .../samples/hello/HelloSignalTest.java | 5 ++- 19 files changed, 92 insertions(+), 71 deletions(-) diff --git a/build.gradle b/build.gradle index e70ab58b..098d844d 100644 --- a/build.gradle +++ b/build.gradle @@ -27,7 +27,7 @@ repositories { } dependencies { - implementation group: 'io.temporal', name: 'temporal-sdk', version: '0.23.1' + implementation group: 'io.temporal', name: 'temporal-sdk', version: '0.25.0' implementation group: 'commons-configuration', name: 'commons-configuration', version: '1.9' implementation group: 'ch.qos.logback', name: 'logback-classic', version: '1.2.3' diff --git a/src/main/java/io/temporal/samples/bookingsaga/TripBookingWorkflowImpl.java b/src/main/java/io/temporal/samples/bookingsaga/TripBookingWorkflowImpl.java index f551b4a3..4ff188d7 100644 --- a/src/main/java/io/temporal/samples/bookingsaga/TripBookingWorkflowImpl.java +++ b/src/main/java/io/temporal/samples/bookingsaga/TripBookingWorkflowImpl.java @@ -21,7 +21,7 @@ import io.temporal.activity.ActivityOptions; import io.temporal.common.RetryOptions; -import io.temporal.workflow.ActivityException; +import io.temporal.failure.ActivityFailure; import io.temporal.workflow.Saga; import io.temporal.workflow.Workflow; import java.time.Duration; @@ -51,7 +51,7 @@ public void bookTrip(String name) { String flightReservationID = activities.bookFlight(name); saga.addCompensation(activities::cancelFlight, flightReservationID, name); - } catch (ActivityException e) { + } catch (ActivityFailure e) { saga.compensate(); throw e; } diff --git a/src/main/java/io/temporal/samples/common/QueryWorkflowExecution.java b/src/main/java/io/temporal/samples/common/QueryWorkflowExecution.java index eea0b235..da104cd0 100644 --- a/src/main/java/io/temporal/samples/common/QueryWorkflowExecution.java +++ b/src/main/java/io/temporal/samples/common/QueryWorkflowExecution.java @@ -21,7 +21,7 @@ import io.temporal.client.WorkflowClient; import io.temporal.client.WorkflowStub; -import io.temporal.proto.common.WorkflowExecution; +import io.temporal.common.v1.WorkflowExecution; import io.temporal.serviceclient.WorkflowServiceStubs; import java.util.Optional; diff --git a/src/main/java/io/temporal/samples/fileprocessing/StoreActivities.java b/src/main/java/io/temporal/samples/fileprocessing/StoreActivities.java index 80431d77..79cf072a 100644 --- a/src/main/java/io/temporal/samples/fileprocessing/StoreActivities.java +++ b/src/main/java/io/temporal/samples/fileprocessing/StoreActivities.java @@ -26,14 +26,17 @@ public interface StoreActivities { final class TaskListFileNamePair { - private final String hostTaskList; - private final String fileName; + private String hostTaskList; + private String fileName; public TaskListFileNamePair(String hostTaskList, String fileName) { this.hostTaskList = hostTaskList; this.fileName = fileName; } + /** Jackson needs it */ + public TaskListFileNamePair() {} + public String getHostTaskList() { return hostTaskList; } diff --git a/src/main/java/io/temporal/samples/hello/HelloActivityRetry.java b/src/main/java/io/temporal/samples/hello/HelloActivityRetry.java index d49c7a73..bcca4528 100644 --- a/src/main/java/io/temporal/samples/hello/HelloActivityRetry.java +++ b/src/main/java/io/temporal/samples/hello/HelloActivityRetry.java @@ -72,7 +72,7 @@ public static class GreetingWorkflowImpl implements GreetingWorkflow { .setRetryOptions( RetryOptions.newBuilder() .setInitialInterval(Duration.ofSeconds(1)) - .setDoNotRetry(IllegalArgumentException.class) + .setDoNotRetry(IllegalArgumentException.class.getName()) .build()) .build()); diff --git a/src/main/java/io/temporal/samples/hello/HelloAsyncActivityCompletion.java b/src/main/java/io/temporal/samples/hello/HelloAsyncActivityCompletion.java index 668adca4..352f4f38 100644 --- a/src/main/java/io/temporal/samples/hello/HelloAsyncActivityCompletion.java +++ b/src/main/java/io/temporal/samples/hello/HelloAsyncActivityCompletion.java @@ -20,6 +20,7 @@ package io.temporal.samples.hello; import io.temporal.activity.Activity; +import io.temporal.activity.ActivityExecutionContext; import io.temporal.activity.ActivityInterface; import io.temporal.activity.ActivityOptions; import io.temporal.client.ActivityCompletionClient; @@ -86,17 +87,18 @@ static class GreetingActivitiesImpl implements GreetingActivities { /** * Demonstrates how to implement an activity asynchronously. When {@link - * Activity#doNotCompleteOnReturn()} is called the activity implementation function returning - * doesn't complete the activity. + * io.temporal.activity.ActivityExecutionContext#doNotCompleteOnReturn()} is called the activity + * implementation function returning doesn't complete the activity. */ @Override public String composeGreeting(String greeting, String name) { // TaskToken is a correlation token used to match an activity task with its completion - byte[] taskToken = Activity.getTaskToken(); + ActivityExecutionContext context = Activity.getExecutionContext(); + byte[] taskToken = context.getTaskToken(); // In real life this request can be executed anywhere. By a separate service for // example. ForkJoinPool.commonPool().execute(() -> composeGreetingAsync(taskToken, greeting, name)); - Activity.doNotCompleteOnReturn(); + context.doNotCompleteOnReturn(); // When doNotCompleteOnReturn() is invoked the return value is ignored. return "ignored"; } diff --git a/src/main/java/io/temporal/samples/hello/HelloCron.java b/src/main/java/io/temporal/samples/hello/HelloCron.java index 5bbf4d4c..6049b52d 100644 --- a/src/main/java/io/temporal/samples/hello/HelloCron.java +++ b/src/main/java/io/temporal/samples/hello/HelloCron.java @@ -22,10 +22,10 @@ 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.WorkflowExecutionAlreadyStarted; import io.temporal.client.WorkflowOptions; -import io.temporal.proto.common.WorkflowExecution; +import io.temporal.common.v1.WorkflowExecution; import io.temporal.serviceclient.WorkflowServiceStubs; import io.temporal.worker.Worker; import io.temporal.worker.WorkerFactory; @@ -82,7 +82,8 @@ public void greet(String name) { static class GreetingActivitiesImpl implements GreetingActivities { @Override public void greet(String greeting) { - System.out.println("From " + Activity.getWorkflowExecution() + ": " + greeting); + System.out.println( + "From " + Activity.getExecutionContext().getInfo().getWorkflowId() + ": " + greeting); } } @@ -114,13 +115,17 @@ public static void main(String[] args) throws InterruptedException { .setWorkflowId(CRON_WORKFLOW_ID) .setTaskList(TASK_LIST) .setCronSchedule("* * * * *") + // Execution timeout limits total time. Cron will stop executing after this timeout. + .setWorkflowExecutionTimeout(Duration.ofMinutes(10)) + // Run timeout limits duration of a single workflow invocation. + .setWorkflowRunTimeout(Duration.ofMinutes(1)) .build(); // WorkflowOptions.newBuilder().setCronSchedule("@every 2s").build(); GreetingWorkflow workflow = client.newWorkflowStub(GreetingWorkflow.class, workflowOptions); try { WorkflowExecution execution = WorkflowClient.start(workflow::greet, "World"); System.out.println("Started " + execution); - } catch (DuplicateWorkflowException e) { + } catch (WorkflowExecutionAlreadyStarted e) { System.out.println("Already running as " + e.getExecution()); } catch (Throwable e) { e.printStackTrace(); diff --git a/src/main/java/io/temporal/samples/hello/HelloPeriodic.java b/src/main/java/io/temporal/samples/hello/HelloPeriodic.java index b19d8fba..dde31794 100644 --- a/src/main/java/io/temporal/samples/hello/HelloPeriodic.java +++ b/src/main/java/io/temporal/samples/hello/HelloPeriodic.java @@ -23,12 +23,12 @@ 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.WorkflowException; +import io.temporal.client.WorkflowExecutionAlreadyStarted; import io.temporal.client.WorkflowOptions; import io.temporal.client.WorkflowStub; -import io.temporal.proto.common.WorkflowExecution; +import io.temporal.common.v1.WorkflowExecution; import io.temporal.serviceclient.WorkflowServiceStubs; import io.temporal.worker.Worker; import io.temporal.worker.WorkerFactory; @@ -112,7 +112,8 @@ public void greetPeriodically(String name) { static class GreetingActivitiesImpl implements GreetingActivities { @Override public void greet(String greeting) { - System.out.println("From " + Activity.getWorkflowExecution() + ": " + greeting); + System.out.println( + "From " + Activity.getExecutionContext().getInfo().getWorkflowId() + ": " + greeting); } } @@ -160,7 +161,7 @@ public static void main(String[] args) throws InterruptedException { try { execution = WorkflowClient.start(workflow::greetPeriodically, "World"); System.out.println("Started " + execution); - } catch (DuplicateWorkflowException e) { + } catch (WorkflowExecutionAlreadyStarted e) { System.out.println("Still running as " + e.getExecution()); } catch (Throwable e) { e.printStackTrace(); diff --git a/src/main/java/io/temporal/samples/hello/HelloSearchAttributes.java b/src/main/java/io/temporal/samples/hello/HelloSearchAttributes.java index 9cb56236..e5578b0c 100644 --- a/src/main/java/io/temporal/samples/hello/HelloSearchAttributes.java +++ b/src/main/java/io/temporal/samples/hello/HelloSearchAttributes.java @@ -25,18 +25,17 @@ import io.temporal.client.WorkflowClient; import io.temporal.client.WorkflowOptions; import io.temporal.common.converter.DataConverter; -import io.temporal.common.converter.GsonJsonDataConverter; -import io.temporal.proto.common.Payload; -import io.temporal.proto.common.SearchAttributes; -import io.temporal.proto.common.WorkflowExecution; -import io.temporal.proto.workflowservice.DescribeWorkflowExecutionRequest; -import io.temporal.proto.workflowservice.DescribeWorkflowExecutionResponse; +import io.temporal.common.v1.Payload; +import io.temporal.common.v1.SearchAttributes; +import io.temporal.common.v1.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 io.temporal.workflowservice.v1.DescribeWorkflowExecutionRequest; +import io.temporal.workflowservice.v1.DescribeWorkflowExecutionResponse; import java.text.SimpleDateFormat; import java.time.Duration; import java.util.Date; @@ -168,7 +167,7 @@ private static String generateDateTimeFieldValue() { // example for extract value from search attributes private static String getKeywordFromSearchAttribute(SearchAttributes searchAttributes) { Payload field = searchAttributes.getIndexedFieldsOrThrow("CustomKeywordField"); - DataConverter dataConverter = GsonJsonDataConverter.getInstance(); - return dataConverter.getPayloadConverter().fromData(field, String.class, String.class); + DataConverter dataConverter = DataConverter.getDefaultInstance(); + return dataConverter.fromPayload(field, String.class, String.class); } } diff --git a/src/main/java/io/temporal/samples/moneytransfer/AccountImpl.java b/src/main/java/io/temporal/samples/moneytransfer/AccountImpl.java index 6ff9678e..761c06b3 100644 --- a/src/main/java/io/temporal/samples/moneytransfer/AccountImpl.java +++ b/src/main/java/io/temporal/samples/moneytransfer/AccountImpl.java @@ -26,7 +26,6 @@ public void withdraw(String accountId, String referenceId, int amountCents) { System.out.printf( "Withdraw to %s of %d cents requested. ReferenceId=%s\n", accountId, amountCents, referenceId); - // throw new RuntimeException("simulated"); } @Override diff --git a/src/main/java/io/temporal/samples/moneytransfer/AccountTransferWorkflowImpl.java b/src/main/java/io/temporal/samples/moneytransfer/AccountTransferWorkflowImpl.java index 32202aff..bf7a042f 100644 --- a/src/main/java/io/temporal/samples/moneytransfer/AccountTransferWorkflowImpl.java +++ b/src/main/java/io/temporal/samples/moneytransfer/AccountTransferWorkflowImpl.java @@ -26,10 +26,7 @@ public class AccountTransferWorkflowImpl implements AccountTransferWorkflow { private final ActivityOptions options = - ActivityOptions.newBuilder() - .setStartToCloseTimeout(Duration.ofSeconds(5)) - .setScheduleToStartTimeout(Duration.ofMinutes(10)) - .build(); + ActivityOptions.newBuilder().setStartToCloseTimeout(Duration.ofSeconds(5)).build(); private final Account account = Workflow.newActivityStub(Account.class, options); @Override diff --git a/src/main/java/io/temporal/samples/updatabletimer/DynamicSleepWorkflowStarter.java b/src/main/java/io/temporal/samples/updatabletimer/DynamicSleepWorkflowStarter.java index 623f1769..4f8cf3ca 100644 --- a/src/main/java/io/temporal/samples/updatabletimer/DynamicSleepWorkflowStarter.java +++ b/src/main/java/io/temporal/samples/updatabletimer/DynamicSleepWorkflowStarter.java @@ -22,11 +22,11 @@ import static io.temporal.samples.updatabletimer.DynamicSleepWorkflowWorker.DYNAMIC_SLEEP_WORKFLOW_ID; import static io.temporal.samples.updatabletimer.DynamicSleepWorkflowWorker.TASK_LIST; -import io.temporal.client.DuplicateWorkflowException; import io.temporal.client.WorkflowClient; +import io.temporal.client.WorkflowExecutionAlreadyStarted; import io.temporal.client.WorkflowOptions; -import io.temporal.proto.common.WorkflowExecution; -import io.temporal.proto.common.WorkflowIdReusePolicy; +import io.temporal.common.v1.WorkflowExecution; +import io.temporal.enums.v1.WorkflowIdReusePolicy; import io.temporal.serviceclient.WorkflowServiceStubs; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -45,7 +45,8 @@ public static void main(String[] args) { WorkflowOptions.newBuilder() .setTaskList(TASK_LIST) .setWorkflowId(DYNAMIC_SLEEP_WORKFLOW_ID) - .setWorkflowIdReusePolicy(WorkflowIdReusePolicy.AllowDuplicate) + .setWorkflowIdReusePolicy( + WorkflowIdReusePolicy.WORKFLOW_ID_REUSE_POLICY_ALLOW_DUPLICATE) .build()); try { @@ -53,7 +54,7 @@ public static void main(String[] args) { WorkflowExecution execution = WorkflowClient.start(workflow::execute, System.currentTimeMillis() + 60000); logger.info("Workflow started: " + execution); - } catch (DuplicateWorkflowException e) { + } catch (WorkflowExecutionAlreadyStarted e) { logger.info("Workflow already running: " + e.getExecution()); } } diff --git a/src/main/resources/logback.xml b/src/main/resources/logback.xml index 64bbddde..608083ff 100644 --- a/src/main/resources/logback.xml +++ b/src/main/resources/logback.xml @@ -26,7 +26,7 @@ - + \ No newline at end of file diff --git a/src/test/java/io/temporal/samples/bookingsaga/TripBookingWorkflowTest.java b/src/test/java/io/temporal/samples/bookingsaga/TripBookingWorkflowTest.java index 5603ae43..7e9a1609 100644 --- a/src/test/java/io/temporal/samples/bookingsaga/TripBookingWorkflowTest.java +++ b/src/test/java/io/temporal/samples/bookingsaga/TripBookingWorkflowTest.java @@ -28,6 +28,7 @@ import io.temporal.client.WorkflowClient; import io.temporal.client.WorkflowException; import io.temporal.client.WorkflowOptions; +import io.temporal.failure.ApplicationFailure; import io.temporal.testing.TestWorkflowEnvironment; import io.temporal.worker.Worker; import org.junit.After; @@ -70,7 +71,9 @@ public void testTripBookingFails() { workflow.bookTrip("trip1"); fail("unreachable"); } catch (WorkflowException e) { - assertEquals("Flight booking did not work", e.getCause().getCause().getMessage()); + assertEquals( + "Flight booking did not work", + ((ApplicationFailure) e.getCause().getCause()).getOriginalMessage()); } } @@ -93,7 +96,9 @@ public void testSAGA() { workflow.bookTrip("trip1"); fail("unreachable"); } catch (WorkflowException e) { - assertEquals("Flight booking did not work", e.getCause().getCause().getMessage()); + assertEquals( + "Flight booking did not work", + ((ApplicationFailure) e.getCause().getCause()).getOriginalMessage()); } verify(activities).cancelHotel(eq("HotelBookingID1"), eq("trip1")); diff --git a/src/test/java/io/temporal/samples/fileprocessing/FileProcessingTest.java b/src/test/java/io/temporal/samples/fileprocessing/FileProcessingTest.java index 2106af20..f5db5f5f 100644 --- a/src/test/java/io/temporal/samples/fileprocessing/FileProcessingTest.java +++ b/src/test/java/io/temporal/samples/fileprocessing/FileProcessingTest.java @@ -25,9 +25,9 @@ import io.temporal.client.WorkflowClient; import io.temporal.client.WorkflowOptions; -import io.temporal.proto.common.TimeoutType; +import io.temporal.enums.v1.TimeoutType; +import io.temporal.failure.TimeoutFailure; import io.temporal.samples.fileprocessing.StoreActivities.TaskListFileNamePair; -import io.temporal.testing.SimulatedTimeoutException; import io.temporal.testing.TestWorkflowEnvironment; import io.temporal.worker.Worker; import java.net.MalformedURLException; @@ -142,7 +142,8 @@ public void testHostFailover() { StoreActivities activitiesHost1 = mock(StoreActivities.class); when(activitiesHost1.process(FILE_NAME_UNPROCESSED)) - .thenThrow(new SimulatedTimeoutException(TimeoutType.ScheduleToStart)); + .thenThrow( + new TimeoutFailure("simulated", null, TimeoutType.TIMEOUT_TYPE_SCHEDULE_TO_START)); workerHost1.registerActivitiesImplementations(activitiesHost1); StoreActivities activitiesHost2 = mock(StoreActivities.class); diff --git a/src/test/java/io/temporal/samples/hello/HelloCronTest.java b/src/test/java/io/temporal/samples/hello/HelloCronTest.java index 34eabaa4..40135f56 100644 --- a/src/test/java/io/temporal/samples/hello/HelloCronTest.java +++ b/src/test/java/io/temporal/samples/hello/HelloCronTest.java @@ -27,7 +27,7 @@ import io.temporal.client.WorkflowClient; import io.temporal.client.WorkflowOptions; -import io.temporal.proto.common.WorkflowExecution; +import io.temporal.common.v1.WorkflowExecution; import io.temporal.samples.hello.HelloCron.GreetingActivities; import io.temporal.samples.hello.HelloCron.GreetingWorkflow; import io.temporal.samples.hello.HelloCron.GreetingWorkflowImpl; diff --git a/src/test/java/io/temporal/samples/hello/HelloExceptionTest.java b/src/test/java/io/temporal/samples/hello/HelloExceptionTest.java index 4b2d9d8d..788277eb 100644 --- a/src/test/java/io/temporal/samples/hello/HelloExceptionTest.java +++ b/src/test/java/io/temporal/samples/hello/HelloExceptionTest.java @@ -29,19 +29,17 @@ import io.temporal.client.WorkflowClient; import io.temporal.client.WorkflowException; import io.temporal.client.WorkflowOptions; -import io.temporal.proto.common.TimeoutType; +import io.temporal.enums.v1.TimeoutType; +import io.temporal.failure.ActivityFailure; +import io.temporal.failure.ApplicationFailure; +import io.temporal.failure.ChildWorkflowFailure; +import io.temporal.failure.TimeoutFailure; import io.temporal.samples.hello.HelloException.GreetingActivities; import io.temporal.samples.hello.HelloException.GreetingChildImpl; import io.temporal.samples.hello.HelloException.GreetingWorkflow; import io.temporal.samples.hello.HelloException.GreetingWorkflowImpl; -import io.temporal.testing.SimulatedTimeoutException; import io.temporal.testing.TestWorkflowEnvironment; import io.temporal.worker.Worker; -import io.temporal.workflow.ActivityFailureException; -import io.temporal.workflow.ActivityTimeoutException; -import io.temporal.workflow.ChildWorkflowFailureException; -import io.temporal.workflow.ChildWorkflowTimedOutException; -import java.io.IOException; import org.junit.After; import org.junit.Before; import org.junit.Ignore; @@ -95,10 +93,12 @@ public void testIOException() { workflow.getGreeting("World"); throw new IllegalStateException("unreachable"); } catch (WorkflowException e) { - assertTrue(e.getCause() instanceof ChildWorkflowFailureException); - assertTrue(e.getCause().getCause() instanceof ActivityFailureException); - assertTrue(e.getCause().getCause().getCause() instanceof IOException); - assertEquals("Hello World!", e.getCause().getCause().getCause().getMessage()); + assertTrue(e.getCause() instanceof ChildWorkflowFailure); + assertTrue(e.getCause().getCause() instanceof ActivityFailure); + assertTrue(e.getCause().getCause().getCause() instanceof ApplicationFailure); + assertEquals( + "Hello World!", + ((ApplicationFailure) e.getCause().getCause().getCause()).getOriginalMessage()); } } @@ -110,7 +110,8 @@ public void testActivityTimeout() { // Mock an activity that times out. GreetingActivities activities = mock(GreetingActivities.class); when(activities.composeGreeting(anyString(), anyString())) - .thenThrow(new SimulatedTimeoutException(TimeoutType.ScheduleToStart)); + .thenThrow( + new TimeoutFailure("simulated", null, TimeoutType.TIMEOUT_TYPE_SCHEDULE_TO_START)); worker.registerActivitiesImplementations(activities); testEnv.start(); @@ -121,11 +122,14 @@ public void testActivityTimeout() { workflow.getGreeting("World"); throw new IllegalStateException("unreachable"); } catch (WorkflowException e) { - assertTrue(e.getCause() instanceof ChildWorkflowFailureException); + assertTrue(e.getCause() instanceof ChildWorkflowFailure); Throwable doubleCause = e.getCause().getCause(); - assertTrue(doubleCause instanceof ActivityTimeoutException); - ActivityTimeoutException timeoutException = (ActivityTimeoutException) doubleCause; - assertEquals(TimeoutType.ScheduleToStart, timeoutException.getTimeoutType()); + assertTrue(doubleCause instanceof ActivityFailure); + Throwable tripleCause = doubleCause.getCause(); + assertTrue(tripleCause instanceof TimeoutFailure); + assertEquals( + TimeoutType.TIMEOUT_TYPE_SCHEDULE_TO_START, + ((TimeoutFailure) tripleCause).getTimeoutType()); } } @@ -139,7 +143,8 @@ public void testChildWorkflowTimeout() { () -> { GreetingChildImpl child = mock(GreetingChildImpl.class); when(child.composeGreeting(anyString(), anyString())) - .thenThrow(new SimulatedTimeoutException()); + .thenThrow( + new TimeoutFailure("simulated", null, TimeoutType.TIMEOUT_TYPE_START_TO_CLOSE)); return child; }); @@ -151,7 +156,8 @@ public void testChildWorkflowTimeout() { workflow.getGreeting("World"); throw new IllegalStateException("unreachable"); } catch (WorkflowException e) { - assertTrue(e.getCause() instanceof ChildWorkflowTimedOutException); + assertTrue(e.getCause() instanceof ChildWorkflowFailure); + assertTrue(e.getCause().getCause() instanceof TimeoutFailure); } } } diff --git a/src/test/java/io/temporal/samples/hello/HelloPeriodicTest.java b/src/test/java/io/temporal/samples/hello/HelloPeriodicTest.java index 1bf3f252..e3231193 100644 --- a/src/test/java/io/temporal/samples/hello/HelloPeriodicTest.java +++ b/src/test/java/io/temporal/samples/hello/HelloPeriodicTest.java @@ -28,18 +28,18 @@ import io.temporal.client.WorkflowClient; import io.temporal.client.WorkflowOptions; -import io.temporal.proto.common.WorkflowExecution; -import io.temporal.proto.execution.WorkflowExecutionInfo; -import io.temporal.proto.execution.WorkflowExecutionStatus; -import io.temporal.proto.filter.WorkflowExecutionFilter; -import io.temporal.proto.workflowservice.ListClosedWorkflowExecutionsRequest; -import io.temporal.proto.workflowservice.ListClosedWorkflowExecutionsResponse; +import io.temporal.common.v1.WorkflowExecution; +import io.temporal.enums.v1.WorkflowExecutionStatus; +import io.temporal.filter.v1.WorkflowExecutionFilter; import io.temporal.samples.hello.HelloPeriodic.GreetingActivities; import io.temporal.samples.hello.HelloPeriodic.GreetingActivitiesImpl; import io.temporal.samples.hello.HelloPeriodic.GreetingWorkflow; import io.temporal.samples.hello.HelloPeriodic.GreetingWorkflowImpl; import io.temporal.testing.TestWorkflowEnvironment; import io.temporal.worker.Worker; +import io.temporal.workflow.v1.WorkflowExecutionInfo; +import io.temporal.workflowservice.v1.ListClosedWorkflowExecutionsRequest; +import io.temporal.workflowservice.v1.ListClosedWorkflowExecutionsResponse; import java.time.Duration; import org.junit.After; import org.junit.Before; @@ -114,7 +114,8 @@ public void testPeriodicActivityInvocation() { testEnv.getWorkflowService().blockingStub().listClosedWorkflowExecutions(request); assertTrue(listResponse.getExecutionsCount() > 1); for (WorkflowExecutionInfo e : listResponse.getExecutionsList()) { - assertEquals(WorkflowExecutionStatus.ContinuedAsNew, e.getStatus()); + assertEquals( + WorkflowExecutionStatus.WORKFLOW_EXECUTION_STATUS_CONTINUED_AS_NEW, e.getStatus()); } } diff --git a/src/test/java/io/temporal/samples/hello/HelloSignalTest.java b/src/test/java/io/temporal/samples/hello/HelloSignalTest.java index 93d70721..32e1e12f 100644 --- a/src/test/java/io/temporal/samples/hello/HelloSignalTest.java +++ b/src/test/java/io/temporal/samples/hello/HelloSignalTest.java @@ -23,7 +23,7 @@ import io.temporal.client.WorkflowClient; import io.temporal.client.WorkflowOptions; -import io.temporal.proto.common.WorkflowIdReusePolicy; +import io.temporal.enums.v1.WorkflowIdReusePolicy; import io.temporal.samples.hello.HelloSignal.GreetingWorkflow; import io.temporal.testing.TestWorkflowEnvironment; import io.temporal.worker.Worker; @@ -78,7 +78,8 @@ public void testSignal() { WorkflowOptions workflowOptions = WorkflowOptions.newBuilder() .setTaskList(HelloSignal.TASK_LIST) - .setWorkflowIdReusePolicy(WorkflowIdReusePolicy.RejectDuplicate) + .setWorkflowIdReusePolicy( + WorkflowIdReusePolicy.WORKFLOW_ID_REUSE_POLICY_REJECT_DUPLICATE) .build(); GreetingWorkflow workflow = client.newWorkflowStub(GreetingWorkflow.class, workflowOptions); From c73b08435ab1cd798670ffdb32bb7f6ff8f87f4c Mon Sep 17 00:00:00 2001 From: Maxim Fateev Date: Fri, 26 Jun 2020 19:26:33 -0700 Subject: [PATCH 2/4] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 70143385..35a75386 100644 --- a/README.md +++ b/README.md @@ -47,7 +47,7 @@ choose **Gradle** and then click **Next**->**Finish**. Run Temporal Server using Docker Compose: - curl -L https://github.com/temporalio/temporal/releases/download/v0.23.1/docker.tar.gz | tar -xz --strip-components 1 docker/docker-compose.yml + curl -L https://github.com/temporalio/temporal/releases/download/v0.25.0/docker.tar.gz | tar -xz --strip-components 1 docker/docker-compose.yml docker-compose up If this does not work, see the instructions for running Temporal Server at https://github.com/temporalio/temporal/blob/master/README.md. From adede42d4fa0941ce4c99830b8a79a3e79e3fa22 Mon Sep 17 00:00:00 2001 From: Maxim Fateev Date: Sat, 27 Jun 2020 17:41:07 -0700 Subject: [PATCH 3/4] Updated to rename task list to task queue --- build.gradle | 2 +- .../samples/bookingsaga/TripBookingSaga.java | 12 ++++----- .../fileprocessing/FileProcessingStarter.java | 4 +-- .../fileprocessing/FileProcessingWorker.java | 26 +++++++++---------- .../FileProcessingWorkflowImpl.java | 22 ++++++++-------- .../fileprocessing/StoreActivities.java | 18 ++++++------- .../fileprocessing/StoreActivitiesImpl.java | 10 +++---- .../temporal/samples/hello/HelloActivity.java | 14 +++++----- .../samples/hello/HelloActivityRetry.java | 14 +++++----- .../io/temporal/samples/hello/HelloAsync.java | 14 +++++----- .../hello/HelloAsyncActivityCompletion.java | 14 +++++----- .../samples/hello/HelloAsyncLambda.java | 14 +++++----- .../io/temporal/samples/hello/HelloChild.java | 14 +++++----- .../io/temporal/samples/hello/HelloCron.java | 12 ++++----- .../samples/hello/HelloException.java | 10 +++---- .../temporal/samples/hello/HelloPeriodic.java | 12 ++++----- .../hello/HelloPolymorphicActivity.java | 14 +++++----- .../io/temporal/samples/hello/HelloQuery.java | 12 ++++----- .../io/temporal/samples/hello/HelloSaga.java | 12 ++++----- .../samples/hello/HelloSearchAttributes.java | 14 +++++----- .../temporal/samples/hello/HelloSignal.java | 8 +++--- .../moneybatch/AccountActivityWorker.java | 6 ++--- .../moneybatch/AccountTransferWorker.java | 4 +-- .../samples/moneybatch/TransferRequester.java | 2 +- .../moneytransfer/AccountActivityWorker.java | 8 +++--- .../moneytransfer/AccountTransferWorker.java | 12 ++++----- .../moneytransfer/TransferRequester.java | 4 +-- .../DynamicSleepWorkflowStarter.java | 4 +-- .../DynamicSleepWorkflowWorker.java | 6 ++--- .../temporal/samples/updatabletimer/README.md | 2 +- .../bookingsaga/TripBookingWorkflowTest.java | 10 ++++--- .../fileprocessing/FileProcessingTest.java | 16 ++++++------ .../samples/hello/HelloActivityRetryTest.java | 8 +++--- .../samples/hello/HelloActivityTest.java | 12 ++++----- .../HelloAsyncActivityCompletionTest.java | 6 ++--- .../samples/hello/HelloAsyncLambdaTest.java | 8 +++--- .../samples/hello/HelloAsyncTest.java | 8 +++--- .../samples/hello/HelloChildTest.java | 12 ++++----- .../temporal/samples/hello/HelloCronTest.java | 6 ++--- .../samples/hello/HelloExceptionTest.java | 10 +++---- .../samples/hello/HelloPeriodicTest.java | 12 ++++----- .../hello/HelloPolymorphicActivityTest.java | 12 ++++----- .../samples/hello/HelloQueryTest.java | 8 +++--- .../samples/hello/HelloSignalTest.java | 6 ++--- .../moneybatch/TransferWorkflowTest.java | 6 ++--- .../moneytransfer/TransferWorkflowTest.java | 6 ++--- 46 files changed, 234 insertions(+), 232 deletions(-) diff --git a/build.gradle b/build.gradle index 098d844d..6056486b 100644 --- a/build.gradle +++ b/build.gradle @@ -27,7 +27,7 @@ repositories { } dependencies { - implementation group: 'io.temporal', name: 'temporal-sdk', version: '0.25.0' + implementation group: 'io.temporal', name: 'temporal-sdk', version: '0.25.0-SNAPSHOT' implementation group: 'commons-configuration', name: 'commons-configuration', version: '1.9' implementation group: 'ch.qos.logback', name: 'logback-classic', version: '1.2.3' diff --git a/src/main/java/io/temporal/samples/bookingsaga/TripBookingSaga.java b/src/main/java/io/temporal/samples/bookingsaga/TripBookingSaga.java index cb42cf1e..94a58f73 100644 --- a/src/main/java/io/temporal/samples/bookingsaga/TripBookingSaga.java +++ b/src/main/java/io/temporal/samples/bookingsaga/TripBookingSaga.java @@ -28,7 +28,7 @@ public class TripBookingSaga { - static final String TASK_LIST = "TripBooking"; + static final String TASK_QUEUE = "TripBooking"; @SuppressWarnings("CatchAndPrintStackTrace") public static void main(String[] args) { @@ -37,11 +37,11 @@ public static void main(String[] args) { // client that can be used to start and signal workflows WorkflowClient client = WorkflowClient.newInstance(service); - // worker factory that can be used to create workers for specific task lists + // worker factory that can be used to create workers for specific task queues WorkerFactory factory = WorkerFactory.newInstance(client); - // Worker that listens on a task list and hosts both workflow and activity implementations. - Worker worker = factory.newWorker(TASK_LIST); + // Worker that listens on a task queue and hosts both workflow and activity implementations. + Worker worker = factory.newWorker(TASK_QUEUE); // Workflows are stateful. So you need a type to create instances. worker.registerWorkflowImplementationTypes(TripBookingWorkflowImpl.class); @@ -52,10 +52,10 @@ public static void main(String[] args) { // Start all workers created by this factory. factory.start(); - System.out.println("Worker started for task list: " + TASK_LIST); + System.out.println("Worker started for task queue: " + TASK_QUEUE); // now we can start running instances of our saga - its state will be persisted - WorkflowOptions options = WorkflowOptions.newBuilder().setTaskList(TASK_LIST).build(); + WorkflowOptions options = WorkflowOptions.newBuilder().setTaskQueue(TASK_QUEUE).build(); TripBookingWorkflow trip1 = client.newWorkflowStub(TripBookingWorkflow.class, options); try { trip1.bookTrip("trip1"); diff --git a/src/main/java/io/temporal/samples/fileprocessing/FileProcessingStarter.java b/src/main/java/io/temporal/samples/fileprocessing/FileProcessingStarter.java index 9bcc607c..0100b6f6 100644 --- a/src/main/java/io/temporal/samples/fileprocessing/FileProcessingStarter.java +++ b/src/main/java/io/temporal/samples/fileprocessing/FileProcessingStarter.java @@ -19,7 +19,7 @@ package io.temporal.samples.fileprocessing; -import static io.temporal.samples.fileprocessing.FileProcessingWorker.TASK_LIST; +import static io.temporal.samples.fileprocessing.FileProcessingWorker.TASK_QUEUE; import io.temporal.client.WorkflowClient; import io.temporal.client.WorkflowOptions; @@ -37,7 +37,7 @@ public static void main(String[] args) throws Exception { FileProcessingWorkflow workflow = client.newWorkflowStub( FileProcessingWorkflow.class, - WorkflowOptions.newBuilder().setTaskList(TASK_LIST).build()); + WorkflowOptions.newBuilder().setTaskQueue(TASK_QUEUE).build()); System.out.println("Executing FileProcessingWorkflow"); diff --git a/src/main/java/io/temporal/samples/fileprocessing/FileProcessingWorker.java b/src/main/java/io/temporal/samples/fileprocessing/FileProcessingWorker.java index 090bd47c..10a59ede 100644 --- a/src/main/java/io/temporal/samples/fileprocessing/FileProcessingWorker.java +++ b/src/main/java/io/temporal/samples/fileprocessing/FileProcessingWorker.java @@ -34,32 +34,32 @@ */ public class FileProcessingWorker { - static final String TASK_LIST = "FileProcessing"; + static final String TASK_QUEUE = "FileProcessing"; public static void main(String[] args) { - String hostSpecifiTaskList = ManagementFactory.getRuntimeMXBean().getName(); + String hostSpecifiTaskQueue = ManagementFactory.getRuntimeMXBean().getName(); // gRPC stubs wrapper that talks to the local docker instance of temporal service. WorkflowServiceStubs service = WorkflowServiceStubs.newInstance(); // client that can be used to start and signal workflows WorkflowClient client = WorkflowClient.newInstance(service); - // worker factory that can be used to create workers for specific task lists + // worker factory that can be used to create workers for specific task queues WorkerFactory factory = WorkerFactory.newInstance(client); - // Worker that listens on a task list and hosts both workflow and activity implementations. - final Worker workerForCommonTaskList = factory.newWorker(TASK_LIST); - workerForCommonTaskList.registerWorkflowImplementationTypes(FileProcessingWorkflowImpl.class); - StoreActivitiesImpl storeActivityImpl = new StoreActivitiesImpl(hostSpecifiTaskList); - workerForCommonTaskList.registerActivitiesImplementations(storeActivityImpl); + // Worker that listens on a task queue and hosts both workflow and activity implementations. + final Worker workerForCommonTaskQueue = factory.newWorker(TASK_QUEUE); + workerForCommonTaskQueue.registerWorkflowImplementationTypes(FileProcessingWorkflowImpl.class); + StoreActivitiesImpl storeActivityImpl = new StoreActivitiesImpl(hostSpecifiTaskQueue); + workerForCommonTaskQueue.registerActivitiesImplementations(storeActivityImpl); - // Get worker to poll the host-specific task list. - final Worker workerForHostSpecificTaskList = factory.newWorker(hostSpecifiTaskList); - workerForHostSpecificTaskList.registerActivitiesImplementations(storeActivityImpl); + // Get worker to poll the host-specific task queue. + final Worker workerForHostSpecificTaskQueue = factory.newWorker(hostSpecifiTaskQueue); + workerForHostSpecificTaskQueue.registerActivitiesImplementations(storeActivityImpl); // Start all workers created by this factory. factory.start(); - System.out.println("Worker started for task list: " + TASK_LIST); - System.out.println("Worker Started for activity task List: " + hostSpecifiTaskList); + System.out.println("Worker started for task queue: " + TASK_QUEUE); + System.out.println("Worker Started for activity task Queue: " + hostSpecifiTaskQueue); } } diff --git a/src/main/java/io/temporal/samples/fileprocessing/FileProcessingWorkflowImpl.java b/src/main/java/io/temporal/samples/fileprocessing/FileProcessingWorkflowImpl.java index 95145d3d..5d200bd8 100644 --- a/src/main/java/io/temporal/samples/fileprocessing/FileProcessingWorkflowImpl.java +++ b/src/main/java/io/temporal/samples/fileprocessing/FileProcessingWorkflowImpl.java @@ -30,23 +30,23 @@ * This implementation of FileProcessingWorkflow downloads the file, zips it, and uploads it to a * destination. An important requirement for such a workflow is that while a first activity can run * on any host, the second and third must run on the same host as the first one. This is achieved - * through use of a host specific task list. The first activity returns the name of the host - * specific task list and all other activities are dispatched using the stub that is configured with - * it. This assumes that FileProcessingWorker has a worker running on the same task list. + * through use of a host specific task queue. The first activity returns the name of the host + * specific task queue and all other activities are dispatched using the stub that is configured + * with it. This assumes that FileProcessingWorker has a worker running on the same task queue. */ public class FileProcessingWorkflowImpl implements FileProcessingWorkflow { - // Uses the default task list shared by the pool of workers. - private final StoreActivities defaultTaskListStore; + // Uses the default task queue shared by the pool of workers. + private final StoreActivities defaultTaskQueueStore; public FileProcessingWorkflowImpl() { // Create activity clients. ActivityOptions ao = ActivityOptions.newBuilder() .setScheduleToCloseTimeout(Duration.ofSeconds(10)) - .setTaskList(FileProcessingWorker.TASK_LIST) + .setTaskQueue(FileProcessingWorker.TASK_QUEUE) .build(); - this.defaultTaskListStore = Workflow.newActivityStub(StoreActivities.class, ao); + this.defaultTaskQueueStore = Workflow.newActivityStub(StoreActivities.class, ao); } @Override @@ -61,19 +61,19 @@ public void processFile(URL source, URL destination) { } private void processFileImpl(URL source, URL destination) { - StoreActivities.TaskListFileNamePair downloaded = defaultTaskListStore.download(source); + StoreActivities.TaskQueueFileNamePair downloaded = defaultTaskQueueStore.download(source); - // Now initialize stubs that are specific to the returned task list. + // Now initialize stubs that are specific to the returned task queue. ActivityOptions hostActivityOptions = ActivityOptions.newBuilder() - .setTaskList(downloaded.getHostTaskList()) + .setTaskQueue(downloaded.getHostTaskQueue()) .setScheduleToCloseTimeout(Duration.ofSeconds(10)) .build(); StoreActivities hostSpecificStore = Workflow.newActivityStub(StoreActivities.class, hostActivityOptions); // Call processFile activity to zip the file. - // Call the activity to process the file using worker-specific task list. + // Call the activity to process the file using worker-specific task queue. String processed = hostSpecificStore.process(downloaded.getFileName()); // Call upload activity to upload the zipped file. hostSpecificStore.upload(processed, destination); diff --git a/src/main/java/io/temporal/samples/fileprocessing/StoreActivities.java b/src/main/java/io/temporal/samples/fileprocessing/StoreActivities.java index 79cf072a..1326a8ad 100644 --- a/src/main/java/io/temporal/samples/fileprocessing/StoreActivities.java +++ b/src/main/java/io/temporal/samples/fileprocessing/StoreActivities.java @@ -25,20 +25,20 @@ @ActivityInterface public interface StoreActivities { - final class TaskListFileNamePair { - private String hostTaskList; + final class TaskQueueFileNamePair { + private String hostTaskQueue; private String fileName; - public TaskListFileNamePair(String hostTaskList, String fileName) { - this.hostTaskList = hostTaskList; + public TaskQueueFileNamePair(String hostTaskQueue, String fileName) { + this.hostTaskQueue = hostTaskQueue; this.fileName = fileName; } /** Jackson needs it */ - public TaskListFileNamePair() {} + public TaskQueueFileNamePair() {} - public String getHostTaskList() { - return hostTaskList; + public String getHostTaskQueue() { + return hostTaskQueue; } public String getFileName() { @@ -65,7 +65,7 @@ public String getFileName() { * Downloads file to local disk. * * @param url remote file location - * @return local task list and downloaded file name + * @return local task queue and downloaded file name */ - TaskListFileNamePair download(URL url); + TaskQueueFileNamePair download(URL url); } diff --git a/src/main/java/io/temporal/samples/fileprocessing/StoreActivitiesImpl.java b/src/main/java/io/temporal/samples/fileprocessing/StoreActivitiesImpl.java index bf5d7cea..1318f91e 100644 --- a/src/main/java/io/temporal/samples/fileprocessing/StoreActivitiesImpl.java +++ b/src/main/java/io/temporal/samples/fileprocessing/StoreActivitiesImpl.java @@ -30,21 +30,21 @@ /** Store activities implementation. */ public class StoreActivitiesImpl implements StoreActivities { - private final String hostSpecificTaskList; + private final String hostSpecificTaskQueue; - public StoreActivitiesImpl(String taskList) { - this.hostSpecificTaskList = taskList; + public StoreActivitiesImpl(String taskQueue) { + this.hostSpecificTaskQueue = taskQueue; } @Override - public TaskListFileNamePair download(URL url) { + public TaskQueueFileNamePair download(URL url) { try { byte[] binary = Resources.toByteArray(url); File destination = new File(Files.createTempDir(), "downloaded"); Files.write(binary, destination); System.out.println( "download activity: downloaded from " + url + " to " + destination.getAbsolutePath()); - return new TaskListFileNamePair(hostSpecificTaskList, destination.getAbsolutePath()); + return new TaskQueueFileNamePair(hostSpecificTaskQueue, destination.getAbsolutePath()); } catch (IOException e) { throw Workflow.wrap(e); } diff --git a/src/main/java/io/temporal/samples/hello/HelloActivity.java b/src/main/java/io/temporal/samples/hello/HelloActivity.java index 64fff3d5..d8e22644 100644 --- a/src/main/java/io/temporal/samples/hello/HelloActivity.java +++ b/src/main/java/io/temporal/samples/hello/HelloActivity.java @@ -38,7 +38,7 @@ */ public class HelloActivity { - static final String TASK_LIST = "HelloActivity"; + static final String TASK_QUEUE = "HelloActivity"; /** Workflow interface has to have at least one method annotated with @WorkflowMethod. */ @WorkflowInterface @@ -88,22 +88,22 @@ public static void main(String[] args) { // client that can be used to start and signal workflows WorkflowClient client = WorkflowClient.newInstance(service); - // worker factory that can be used to create workers for specific task lists + // worker factory that can be used to create workers for specific task queues WorkerFactory factory = WorkerFactory.newInstance(client); - // Worker that listens on a task list and hosts both workflow and activity implementations. - Worker worker = factory.newWorker(TASK_LIST); + // Worker that listens on a task queue and hosts both workflow and activity implementations. + Worker worker = factory.newWorker(TASK_QUEUE); // Workflows are stateful. So you need a type to create instances. worker.registerWorkflowImplementationTypes(GreetingWorkflowImpl.class); // Activities are stateless and thread safe. So a shared instance is used. worker.registerActivitiesImplementations(new GreetingActivitiesImpl()); - // Start listening to the workflow and activity task lists. + // Start listening to the workflow and activity task queues. factory.start(); // Start a workflow execution. Usually this is done from another program. - // Uses task list from the GreetingWorkflow @WorkflowMethod annotation. + // Uses task queue from the GreetingWorkflow @WorkflowMethod annotation. GreetingWorkflow workflow = client.newWorkflowStub( - GreetingWorkflow.class, WorkflowOptions.newBuilder().setTaskList(TASK_LIST).build()); + GreetingWorkflow.class, WorkflowOptions.newBuilder().setTaskQueue(TASK_QUEUE).build()); // Execute a workflow waiting for it to complete. See {@link // io.temporal.samples.hello.HelloSignal} // for an example of starting workflow without waiting synchronously for its result. diff --git a/src/main/java/io/temporal/samples/hello/HelloActivityRetry.java b/src/main/java/io/temporal/samples/hello/HelloActivityRetry.java index bcca4528..8c87649b 100644 --- a/src/main/java/io/temporal/samples/hello/HelloActivityRetry.java +++ b/src/main/java/io/temporal/samples/hello/HelloActivityRetry.java @@ -39,7 +39,7 @@ */ public class HelloActivityRetry { - static final String TASK_LIST = "HelloActivityRetry"; + static final String TASK_QUEUE = "HelloActivityRetry"; @WorkflowInterface public interface GreetingWorkflow { @@ -109,19 +109,19 @@ public static void main(String[] args) { // client that can be used to start and signal workflows WorkflowClient client = WorkflowClient.newInstance(service); - // worker factory that can be used to create workers for specific task lists + // worker factory that can be used to create workers for specific task queues WorkerFactory factory = WorkerFactory.newInstance(client); - // Worker that listens on a task list and hosts both workflow and activity implementations. - Worker worker = factory.newWorker(TASK_LIST); + // Worker that listens on a task queue and hosts both workflow and activity implementations. + Worker worker = factory.newWorker(TASK_QUEUE); // Workflows are stateful. So you need a type to create instances. worker.registerWorkflowImplementationTypes(GreetingWorkflowImpl.class); // Activities are stateless and thread safe. So a shared instance is used. worker.registerActivitiesImplementations(new GreetingActivitiesImpl()); - // Start listening to the workflow and activity task lists. + // Start listening to the workflow and activity task queues. factory.start(); - // Get a workflow stub using the same task list the worker uses. - WorkflowOptions workflowOptions = WorkflowOptions.newBuilder().setTaskList(TASK_LIST).build(); + // Get a workflow stub using the same task queue the worker uses. + WorkflowOptions workflowOptions = WorkflowOptions.newBuilder().setTaskQueue(TASK_QUEUE).build(); GreetingWorkflow workflow = client.newWorkflowStub(GreetingWorkflow.class, workflowOptions); // Execute a workflow waiting for it to complete. String greeting = workflow.getGreeting("World"); diff --git a/src/main/java/io/temporal/samples/hello/HelloAsync.java b/src/main/java/io/temporal/samples/hello/HelloAsync.java index 51e6d7bb..8bfdbb41 100644 --- a/src/main/java/io/temporal/samples/hello/HelloAsync.java +++ b/src/main/java/io/temporal/samples/hello/HelloAsync.java @@ -40,7 +40,7 @@ */ public class HelloAsync { - static final String TASK_LIST = "HelloAsync"; + static final String TASK_QUEUE = "HelloAsync"; @WorkflowInterface public interface GreetingWorkflow { @@ -93,22 +93,22 @@ public static void main(String[] args) { // client that can be used to start and signal workflows WorkflowClient client = WorkflowClient.newInstance(service); - // worker factory that can be used to create workers for specific task lists + // worker factory that can be used to create workers for specific task queues WorkerFactory factory = WorkerFactory.newInstance(client); - // Worker that listens on a task list and hosts both workflow and activity implementations. - Worker worker = factory.newWorker(TASK_LIST); + // Worker that listens on a task queue and hosts both workflow and activity implementations. + Worker worker = factory.newWorker(TASK_QUEUE); // Workflows are stateful. So you need a type to create instances. worker.registerWorkflowImplementationTypes(GreetingWorkflowImpl.class); // Activities are stateless and thread safe. So a shared instance is used. worker.registerActivitiesImplementations(new GreetingActivitiesImpl()); - // Start listening to the workflow and activity task lists. + // Start listening to the workflow and activity task queues. factory.start(); // Start a workflow execution. Usually this is done from another program.\n' - // Uses task list from the GreetingWorkflow @WorkflowMethod annotation. + // Uses task queue from the GreetingWorkflow @WorkflowMethod annotation. GreetingWorkflow workflow = client.newWorkflowStub( - GreetingWorkflow.class, WorkflowOptions.newBuilder().setTaskList(TASK_LIST).build()); + GreetingWorkflow.class, WorkflowOptions.newBuilder().setTaskQueue(TASK_QUEUE).build()); // Execute a workflow waiting for it to complete. String greeting = workflow.getGreeting("World"); System.out.println(greeting); diff --git a/src/main/java/io/temporal/samples/hello/HelloAsyncActivityCompletion.java b/src/main/java/io/temporal/samples/hello/HelloAsyncActivityCompletion.java index 352f4f38..15451e3a 100644 --- a/src/main/java/io/temporal/samples/hello/HelloAsyncActivityCompletion.java +++ b/src/main/java/io/temporal/samples/hello/HelloAsyncActivityCompletion.java @@ -43,7 +43,7 @@ */ public class HelloAsyncActivityCompletion { - static final String TASK_LIST = "HelloAsyncActivityCompletion"; + static final String TASK_QUEUE = "HelloAsyncActivityCompletion"; @WorkflowInterface public interface GreetingWorkflow { @@ -117,24 +117,24 @@ public static void main(String[] args) throws ExecutionException, InterruptedExc // client that can be used to start and signal workflows WorkflowClient client = WorkflowClient.newInstance(service); - // worker factory that can be used to create workers for specific task lists + // worker factory that can be used to create workers for specific task queues WorkerFactory factory = WorkerFactory.newInstance(client); - // Worker that listens on a task list and hosts both workflow and activity implementations. - Worker worker = factory.newWorker(TASK_LIST); + // Worker that listens on a task queue and hosts both workflow and activity implementations. + Worker worker = factory.newWorker(TASK_QUEUE); // Workflows are stateful. So you need a type to create instances. worker.registerWorkflowImplementationTypes(GreetingWorkflowImpl.class); // Activities are stateless and thread safe. So a shared instance is used. // CompletionClient is passed to activity here only to support unit testing. ActivityCompletionClient completionClient = client.newActivityCompletionClient(); worker.registerActivitiesImplementations(new GreetingActivitiesImpl(completionClient)); - // Start listening to the workflow and activity task lists. + // Start listening to the workflow and activity task queues. factory.start(); // Start a workflow execution. Usually this is done from another program. - // Uses task list from the GreetingWorkflow @WorkflowMethod annotation. + // Uses task queue from the GreetingWorkflow @WorkflowMethod annotation. GreetingWorkflow workflow = client.newWorkflowStub( - GreetingWorkflow.class, WorkflowOptions.newBuilder().setTaskList(TASK_LIST).build()); + GreetingWorkflow.class, WorkflowOptions.newBuilder().setTaskQueue(TASK_QUEUE).build()); // Execute a workflow asynchronously returning a future that can be used to wait for the // workflow // completion. diff --git a/src/main/java/io/temporal/samples/hello/HelloAsyncLambda.java b/src/main/java/io/temporal/samples/hello/HelloAsyncLambda.java index 7dd7a257..c9a57468 100644 --- a/src/main/java/io/temporal/samples/hello/HelloAsyncLambda.java +++ b/src/main/java/io/temporal/samples/hello/HelloAsyncLambda.java @@ -39,7 +39,7 @@ */ public class HelloAsyncLambda { - static final String TASK_LIST = "HelloAsyncLambda"; + static final String TASK_QUEUE = "HelloAsyncLambda"; @WorkflowInterface public interface GreetingWorkflow { @@ -109,21 +109,21 @@ public static void main(String[] args) { // client that can be used to start and signal workflows WorkflowClient client = WorkflowClient.newInstance(service); - // worker factory that can be used to create workers for specific task lists + // worker factory that can be used to create workers for specific task queues WorkerFactory factory = WorkerFactory.newInstance(client); - // Worker that listens on a task list and hosts both workflow and activity implementations. - Worker worker = factory.newWorker(TASK_LIST); + // Worker that listens on a task queue and hosts both workflow and activity implementations. + Worker worker = factory.newWorker(TASK_QUEUE); // Workflows are stateful. So you need a type to create instances. worker.registerWorkflowImplementationTypes(GreetingWorkflowImpl.class); // Activities are stateless and thread safe. So a shared instance is used. worker.registerActivitiesImplementations(new GreetingActivitiesImpl()); - // Start listening to the workflow and activity task lists. + // Start listening to the workflow and activity task queues. factory.start(); - // Get a workflow stub using the same task list the worker uses. + // Get a workflow stub using the same task queue the worker uses. // As the required ExecutionStartToCloseTimeout is not specified through the @WorkflowMethod // annotation it has to be specified through the options. - WorkflowOptions workflowOptions = WorkflowOptions.newBuilder().setTaskList(TASK_LIST).build(); + WorkflowOptions workflowOptions = WorkflowOptions.newBuilder().setTaskQueue(TASK_QUEUE).build(); GreetingWorkflow workflow = client.newWorkflowStub(GreetingWorkflow.class, workflowOptions); // Execute a workflow waiting for it to complete. String greeting = workflow.getGreeting("World"); diff --git a/src/main/java/io/temporal/samples/hello/HelloChild.java b/src/main/java/io/temporal/samples/hello/HelloChild.java index 3c03f07d..3a198f1c 100644 --- a/src/main/java/io/temporal/samples/hello/HelloChild.java +++ b/src/main/java/io/temporal/samples/hello/HelloChild.java @@ -35,7 +35,7 @@ */ public class HelloChild { - static final String TASK_LIST = "HelloChild"; + static final String TASK_QUEUE = "HelloChild"; /** The parent workflow interface. */ @WorkflowInterface @@ -85,19 +85,19 @@ public static void main(String[] args) { // client that can be used to start and signal workflows WorkflowClient client = WorkflowClient.newInstance(service); - // worker factory that can be used to create workers for specific task lists + // worker factory that can be used to create workers for specific task queues WorkerFactory factory = WorkerFactory.newInstance(client); - // Worker that listens on a task list and hosts both workflow and activity implementations. - Worker worker = factory.newWorker(TASK_LIST); + // Worker that listens on a task queue and hosts both workflow and activity implementations. + Worker worker = factory.newWorker(TASK_QUEUE); worker.registerWorkflowImplementationTypes(GreetingWorkflowImpl.class, GreetingChildImpl.class); - // Start listening to the workflow task list. + // Start listening to the workflow task queue. factory.start(); // Start a workflow execution. Usually this is done from another program. - // Uses task list from the GreetingWorkflow @WorkflowMethod annotation. + // Uses task queue from the GreetingWorkflow @WorkflowMethod annotation. GreetingWorkflow workflow = client.newWorkflowStub( - GreetingWorkflow.class, WorkflowOptions.newBuilder().setTaskList(TASK_LIST).build()); + GreetingWorkflow.class, WorkflowOptions.newBuilder().setTaskQueue(TASK_QUEUE).build()); // Execute a workflow waiting for it to complete. String greeting = workflow.getGreeting("World"); System.out.println(greeting); diff --git a/src/main/java/io/temporal/samples/hello/HelloCron.java b/src/main/java/io/temporal/samples/hello/HelloCron.java index 6049b52d..be489396 100644 --- a/src/main/java/io/temporal/samples/hello/HelloCron.java +++ b/src/main/java/io/temporal/samples/hello/HelloCron.java @@ -42,7 +42,7 @@ */ public class HelloCron { - static final String TASK_LIST = "HelloCron"; + static final String TASK_QUEUE = "HelloCron"; static final String CRON_WORKFLOW_ID = "HelloCron"; @WorkflowInterface @@ -93,15 +93,15 @@ public static void main(String[] args) throws InterruptedException { // client that can be used to start and signal workflows WorkflowClient client = WorkflowClient.newInstance(service); - // worker factory that can be used to create workers for specific task lists + // worker factory that can be used to create workers for specific task queues WorkerFactory factory = WorkerFactory.newInstance(client); - // Worker that listens on a task list and hosts both workflow and activity implementations. - Worker worker = factory.newWorker(TASK_LIST); + // Worker that listens on a task queue and hosts both workflow and activity implementations. + Worker worker = factory.newWorker(TASK_QUEUE); // Workflows are stateful. So you need a type to create instances. worker.registerWorkflowImplementationTypes(GreetingWorkflowImpl.class); // Activities are stateless and thread safe. So a shared instance is used. worker.registerActivitiesImplementations(new GreetingActivitiesImpl()); - // Start listening to the workflow and activity task lists. + // Start listening to the workflow and activity task queues. factory.start(); // Sets the cron schedule using the WorkflowOptions. @@ -113,7 +113,7 @@ public static void main(String[] args) throws InterruptedException { WorkflowOptions workflowOptions = WorkflowOptions.newBuilder() .setWorkflowId(CRON_WORKFLOW_ID) - .setTaskList(TASK_LIST) + .setTaskQueue(TASK_QUEUE) .setCronSchedule("* * * * *") // Execution timeout limits total time. Cron will stop executing after this timeout. .setWorkflowExecutionTimeout(Duration.ofMinutes(10)) diff --git a/src/main/java/io/temporal/samples/hello/HelloException.java b/src/main/java/io/temporal/samples/hello/HelloException.java index 3dec3a86..26ff68c1 100644 --- a/src/main/java/io/temporal/samples/hello/HelloException.java +++ b/src/main/java/io/temporal/samples/hello/HelloException.java @@ -107,7 +107,7 @@ */ public class HelloException { - static final String TASK_LIST = "HelloException"; + static final String TASK_QUEUE = "HelloException"; @WorkflowInterface public interface GreetingWorkflow { @@ -169,15 +169,15 @@ public static void main(String[] args) { // client that can be used to start and signal workflows WorkflowClient client = WorkflowClient.newInstance(service); - // worker factory that can be used to create workers for specific task lists + // worker factory that can be used to create workers for specific task queues WorkerFactory factory = WorkerFactory.newInstance(client); - // Worker that listens on a task list and hosts both workflow and activity implementations. - Worker worker = factory.newWorker(TASK_LIST); + // Worker that listens on a task queue and hosts both workflow and activity implementations. + Worker worker = factory.newWorker(TASK_QUEUE); worker.registerWorkflowImplementationTypes(GreetingWorkflowImpl.class, GreetingChildImpl.class); worker.registerActivitiesImplementations(new GreetingActivitiesImpl()); factory.start(); - WorkflowOptions workflowOptions = WorkflowOptions.newBuilder().setTaskList(TASK_LIST).build(); + WorkflowOptions workflowOptions = WorkflowOptions.newBuilder().setTaskQueue(TASK_QUEUE).build(); GreetingWorkflow workflow = client.newWorkflowStub(GreetingWorkflow.class, workflowOptions); try { workflow.getGreeting("World"); diff --git a/src/main/java/io/temporal/samples/hello/HelloPeriodic.java b/src/main/java/io/temporal/samples/hello/HelloPeriodic.java index dde31794..209beade 100644 --- a/src/main/java/io/temporal/samples/hello/HelloPeriodic.java +++ b/src/main/java/io/temporal/samples/hello/HelloPeriodic.java @@ -48,7 +48,7 @@ */ public class HelloPeriodic { - static final String TASK_LIST = "HelloPeriodic"; + static final String TASK_QUEUE = "HelloPeriodic"; static final String PERIODIC_WORKFLOW_ID = "HelloPeriodic"; @WorkflowInterface @@ -123,15 +123,15 @@ public static void main(String[] args) throws InterruptedException { // client that can be used to start and signal workflows WorkflowClient client = WorkflowClient.newInstance(service); - // worker factory that can be used to create workers for specific task lists + // worker factory that can be used to create workers for specific task queues WorkerFactory factory = WorkerFactory.newInstance(client); - // Worker that listens on a task list and hosts both workflow and activity implementations. - Worker worker = factory.newWorker(TASK_LIST); + // Worker that listens on a task queue and hosts both workflow and activity implementations. + Worker worker = factory.newWorker(TASK_QUEUE); // Workflows are stateful. So you need a type to create instances. worker.registerWorkflowImplementationTypes(GreetingWorkflowImpl.class); // Activities are stateless and thread safe. So a shared instance is used. worker.registerActivitiesImplementations(new GreetingActivitiesImpl()); - // Start listening to the workflow and activity task lists. + // Start listening to the workflow and activity task queues. factory.start(); // To ensure that this daemon type workflow is always running try to start it periodically @@ -156,7 +156,7 @@ public static void main(String[] args) throws InterruptedException { // At most one instance. WorkflowOptions.newBuilder() .setWorkflowId(PERIODIC_WORKFLOW_ID) - .setTaskList(TASK_LIST) + .setTaskQueue(TASK_QUEUE) .build()); try { execution = WorkflowClient.start(workflow::greetPeriodically, "World"); diff --git a/src/main/java/io/temporal/samples/hello/HelloPolymorphicActivity.java b/src/main/java/io/temporal/samples/hello/HelloPolymorphicActivity.java index 812039cd..4b250314 100644 --- a/src/main/java/io/temporal/samples/hello/HelloPolymorphicActivity.java +++ b/src/main/java/io/temporal/samples/hello/HelloPolymorphicActivity.java @@ -41,7 +41,7 @@ */ public class HelloPolymorphicActivity { - static final String TASK_LIST = "HelloPolymorphicActivity"; + static final String TASK_QUEUE = "HelloPolymorphicActivity"; @WorkflowInterface public interface GreetingWorkflow { @@ -119,22 +119,22 @@ public static void main(String[] args) { // client that can be used to start and signal workflows WorkflowClient client = WorkflowClient.newInstance(service); - // worker factory that can be used to create workers for specific task lists + // worker factory that can be used to create workers for specific task queues WorkerFactory factory = WorkerFactory.newInstance(client); - // Worker that listens on a task list and hosts both workflow and activity implementations. - Worker worker = factory.newWorker(TASK_LIST); + // Worker that listens on a task queue and hosts both workflow and activity implementations. + Worker worker = factory.newWorker(TASK_QUEUE); // Workflows are stateful. So you need a type to create instances. worker.registerWorkflowImplementationTypes(GreetingWorkflowImpl.class); // Activities are stateless and thread safe. So a shared instance is used. worker.registerActivitiesImplementations(new HelloActivityImpl(), new ByeActivityImpl()); - // Start listening to the workflow and activity task lists. + // Start listening to the workflow and activity task queues. factory.start(); // Start a workflow execution. Usually this is done from another program. - // Uses task list from the GreetingWorkflow @WorkflowMethod annotation. + // Uses task queue from the GreetingWorkflow @WorkflowMethod annotation. GreetingWorkflow workflow = client.newWorkflowStub( - GreetingWorkflow.class, WorkflowOptions.newBuilder().setTaskList(TASK_LIST).build()); + GreetingWorkflow.class, WorkflowOptions.newBuilder().setTaskQueue(TASK_QUEUE).build()); // Execute a workflow waiting for it to complete. See {@link // io.temporal.samples.hello.HelloSignal} // for an example of starting workflow without waiting synchronously for its result. diff --git a/src/main/java/io/temporal/samples/hello/HelloQuery.java b/src/main/java/io/temporal/samples/hello/HelloQuery.java index 5d0763f8..50b9ace5 100644 --- a/src/main/java/io/temporal/samples/hello/HelloQuery.java +++ b/src/main/java/io/temporal/samples/hello/HelloQuery.java @@ -33,7 +33,7 @@ /** Demonstrates query capability. Requires a local instance of Temporal server to be running. */ public class HelloQuery { - static final String TASK_LIST = "HelloQuery"; + static final String TASK_QUEUE = "HelloQuery"; @WorkflowInterface public interface GreetingWorkflow { @@ -72,15 +72,15 @@ public static void main(String[] args) throws InterruptedException { // client that can be used to start and signal workflows WorkflowClient client = WorkflowClient.newInstance(service); - // worker factory that can be used to create workers for specific task lists + // worker factory that can be used to create workers for specific task queues WorkerFactory factory = WorkerFactory.newInstance(client); - // Worker that listens on a task list and hosts both workflow and activity implementations. - Worker worker = factory.newWorker(TASK_LIST); + // Worker that listens on a task queue and hosts both workflow and activity implementations. + Worker worker = factory.newWorker(TASK_QUEUE); worker.registerWorkflowImplementationTypes(GreetingWorkflowImpl.class); factory.start(); - // Get a workflow stub using the same task list the worker uses. - WorkflowOptions workflowOptions = WorkflowOptions.newBuilder().setTaskList(TASK_LIST).build(); + // Get a workflow stub using the same task queue the worker uses. + WorkflowOptions workflowOptions = WorkflowOptions.newBuilder().setTaskQueue(TASK_QUEUE).build(); GreetingWorkflow workflow = client.newWorkflowStub(GreetingWorkflow.class, workflowOptions); // Start workflow asynchronously to not use another thread to query. WorkflowClient.start(workflow::createGreeting, "World"); diff --git a/src/main/java/io/temporal/samples/hello/HelloSaga.java b/src/main/java/io/temporal/samples/hello/HelloSaga.java index 51e2ee8c..a9c0f00b 100644 --- a/src/main/java/io/temporal/samples/hello/HelloSaga.java +++ b/src/main/java/io/temporal/samples/hello/HelloSaga.java @@ -37,7 +37,7 @@ /** Demonstrates implementing saga transaction and compensation logic using Temporal. */ public class HelloSaga { - static final String TASK_LIST = "HelloSaga"; + static final String TASK_QUEUE = "HelloSaga"; @WorkflowInterface public interface ChildWorkflowOperation { @@ -150,10 +150,10 @@ public static void main(String[] args) { // client that can be used to start and signal workflows WorkflowClient client = WorkflowClient.newInstance(service); - // worker factory that can be used to create workers for specific task lists + // worker factory that can be used to create workers for specific task queues WorkerFactory factory = WorkerFactory.newInstance(client); - // Worker that listens on a task list and hosts both workflow and activity implementations. - Worker worker = factory.newWorker(TASK_LIST); + // Worker that listens on a task queue and hosts both workflow and activity implementations. + Worker worker = factory.newWorker(TASK_QUEUE); worker.registerWorkflowImplementationTypes( HelloSaga.SagaWorkflowImpl.class, HelloSaga.ChildWorkflowOperationImpl.class, @@ -161,8 +161,8 @@ public static void main(String[] args) { worker.registerActivitiesImplementations(new ActivityOperationImpl()); factory.start(); - // Get a workflow stub using the same task list the worker uses. - WorkflowOptions workflowOptions = WorkflowOptions.newBuilder().setTaskList(TASK_LIST).build(); + // Get a workflow stub using the same task queue the worker uses. + WorkflowOptions workflowOptions = WorkflowOptions.newBuilder().setTaskQueue(TASK_QUEUE).build(); HelloSaga.SagaWorkflow workflow = client.newWorkflowStub(HelloSaga.SagaWorkflow.class, workflowOptions); workflow.execute(); diff --git a/src/main/java/io/temporal/samples/hello/HelloSearchAttributes.java b/src/main/java/io/temporal/samples/hello/HelloSearchAttributes.java index e5578b0c..30461da8 100644 --- a/src/main/java/io/temporal/samples/hello/HelloSearchAttributes.java +++ b/src/main/java/io/temporal/samples/hello/HelloSearchAttributes.java @@ -48,7 +48,7 @@ */ public class HelloSearchAttributes { - static final String TASK_LIST = "HelloSearchAttributes"; + static final String TASK_QUEUE = "HelloSearchAttributes"; /** Workflow interface has to have at least one method annotated with @WorkflowMethod. */ @WorkflowInterface @@ -98,26 +98,26 @@ public static void main(String[] args) { // client that can be used to start and signal workflows WorkflowClient client = WorkflowClient.newInstance(service); - // worker factory that can be used to create workers for specific task lists + // worker factory that can be used to create workers for specific task queues WorkerFactory factory = WorkerFactory.newInstance(client); - // Worker that listens on a task list and hosts both workflow and activity implementations. - Worker worker = factory.newWorker(TASK_LIST); + // Worker that listens on a task queue and hosts both workflow and activity implementations. + Worker worker = factory.newWorker(TASK_QUEUE); // Workflows are stateful. So you need a type to create instances. worker.registerWorkflowImplementationTypes(HelloSearchAttributes.GreetingWorkflowImpl.class); // Activities are stateless and thread safe. So a shared instance is used. worker.registerActivitiesImplementations(new HelloSearchAttributes.GreetingActivitiesImpl()); - // Start listening to the workflow and activity task lists. + // Start listening to the workflow and activity task queues. factory.start(); // Set search attributes in workflowOptions String workflowID = UUID.randomUUID().toString(); WorkflowOptions workflowOptions = WorkflowOptions.newBuilder() - .setTaskList(TASK_LIST) + .setTaskQueue(TASK_QUEUE) .setWorkflowId(workflowID) .setSearchAttributes(generateSearchAttributes()) .build(); - // Get a workflow stub using the same task list the worker uses. + // Get a workflow stub using the same task queue the worker uses. HelloSearchAttributes.GreetingWorkflow workflow = client.newWorkflowStub(HelloSearchAttributes.GreetingWorkflow.class, workflowOptions); // Execute a workflow waiting for it to complete. diff --git a/src/main/java/io/temporal/samples/hello/HelloSignal.java b/src/main/java/io/temporal/samples/hello/HelloSignal.java index 91f282ce..24089792 100644 --- a/src/main/java/io/temporal/samples/hello/HelloSignal.java +++ b/src/main/java/io/temporal/samples/hello/HelloSignal.java @@ -39,7 +39,7 @@ @SuppressWarnings("ALL") public class HelloSignal { - static final String TASK_LIST = "HelloSignal"; + static final String TASK_QUEUE = "HelloSignal"; /** Workflow interface must have a method annotated with @WorkflowMethod. */ @WorkflowInterface @@ -95,7 +95,7 @@ public static void main(String[] args) throws Exception { WorkflowServiceStubs service = WorkflowServiceStubs.newInstance(); WorkflowClient client = WorkflowClient.newInstance(service); WorkerFactory factory = WorkerFactory.newInstance(client); - Worker worker = factory.newWorker(TASK_LIST); + Worker worker = factory.newWorker(TASK_QUEUE); worker.registerWorkflowImplementationTypes(GreetingWorkflowImpl.class); factory.start(); @@ -103,10 +103,10 @@ public static void main(String[] args) throws Exception { String workflowId = RandomStringUtils.randomAlphabetic(10); // Start a workflow execution. Usually this is done from another program. - // Get a workflow stub using the same task list the worker uses. + // Get a workflow stub using the same task queue the worker uses. // The newly started workflow is going to have the workflowId generated above. WorkflowOptions workflowOptions = - WorkflowOptions.newBuilder().setTaskList(TASK_LIST).setWorkflowId(workflowId).build(); + WorkflowOptions.newBuilder().setTaskQueue(TASK_QUEUE).setWorkflowId(workflowId).build(); GreetingWorkflow workflow = client.newWorkflowStub(GreetingWorkflow.class, workflowOptions); // Start workflow asynchronously to not use another thread to signal. WorkflowClient.start(workflow::getGreetings); diff --git a/src/main/java/io/temporal/samples/moneybatch/AccountActivityWorker.java b/src/main/java/io/temporal/samples/moneybatch/AccountActivityWorker.java index 0b93a630..c8d06253 100644 --- a/src/main/java/io/temporal/samples/moneybatch/AccountActivityWorker.java +++ b/src/main/java/io/temporal/samples/moneybatch/AccountActivityWorker.java @@ -26,7 +26,7 @@ public class AccountActivityWorker { - static final String TASK_LIST = "Account"; + static final String TASK_QUEUE = "Account"; @SuppressWarnings("CatchAndPrintStackTrace") public static void main(String[] args) { @@ -34,12 +34,12 @@ public static void main(String[] args) { WorkflowClient client = WorkflowClient.newInstance(service); WorkerFactory factory = WorkerFactory.newInstance(client); - Worker worker = factory.newWorker(TASK_LIST); + Worker worker = factory.newWorker(TASK_QUEUE); Account account = new AccountImpl(); worker.registerActivitiesImplementations(account); factory.start(); - System.out.println("Activity Worker started for task list: " + TASK_LIST); + System.out.println("Activity Worker started for task queue: " + TASK_QUEUE); } } diff --git a/src/main/java/io/temporal/samples/moneybatch/AccountTransferWorker.java b/src/main/java/io/temporal/samples/moneybatch/AccountTransferWorker.java index 02413ab5..8ff3f830 100644 --- a/src/main/java/io/temporal/samples/moneybatch/AccountTransferWorker.java +++ b/src/main/java/io/temporal/samples/moneybatch/AccountTransferWorker.java @@ -32,10 +32,10 @@ public static void main(String[] args) { WorkflowClient client = WorkflowClient.newInstance(service); WorkerFactory factory = WorkerFactory.newInstance(client); - Worker worker = factory.newWorker(AccountActivityWorker.TASK_LIST); + Worker worker = factory.newWorker(AccountActivityWorker.TASK_QUEUE); worker.registerWorkflowImplementationTypes(AccountTransferWorkflowImpl.class); factory.start(); - System.out.println("Worker started for task list: " + AccountActivityWorker.TASK_LIST); + System.out.println("Worker started for task queue: " + AccountActivityWorker.TASK_QUEUE); } } diff --git a/src/main/java/io/temporal/samples/moneybatch/TransferRequester.java b/src/main/java/io/temporal/samples/moneybatch/TransferRequester.java index 394a3946..4b3eb364 100644 --- a/src/main/java/io/temporal/samples/moneybatch/TransferRequester.java +++ b/src/main/java/io/temporal/samples/moneybatch/TransferRequester.java @@ -42,7 +42,7 @@ public static void main(String[] args) { String to = "account2"; WorkflowOptions options = WorkflowOptions.newBuilder() - .setTaskList(AccountActivityWorker.TASK_LIST) + .setTaskQueue(AccountActivityWorker.TASK_QUEUE) .setWorkflowId(to) .build(); AccountTransferWorkflow transferWorkflow = diff --git a/src/main/java/io/temporal/samples/moneytransfer/AccountActivityWorker.java b/src/main/java/io/temporal/samples/moneytransfer/AccountActivityWorker.java index 29196ca8..dca9d9fe 100644 --- a/src/main/java/io/temporal/samples/moneytransfer/AccountActivityWorker.java +++ b/src/main/java/io/temporal/samples/moneytransfer/AccountActivityWorker.java @@ -26,7 +26,7 @@ public class AccountActivityWorker { - static final String TASK_LIST = "AcccountTransfer"; + static final String TASK_QUEUE = "AcccountTransfer"; @SuppressWarnings("CatchAndPrintStackTrace") public static void main(String[] args) { @@ -35,14 +35,14 @@ public static void main(String[] args) { // client that can be used to start and signal workflows WorkflowClient client = WorkflowClient.newInstance(service); - // worker factory that can be used to create workers for specific task lists + // worker factory that can be used to create workers for specific task queues WorkerFactory factory = WorkerFactory.newInstance(client); - Worker worker = factory.newWorker(TASK_LIST); + Worker worker = factory.newWorker(TASK_QUEUE); Account account = new AccountImpl(); worker.registerActivitiesImplementations(account); // Start all workers created by this factory. factory.start(); - System.out.println("Activity Worker started for task list: " + TASK_LIST); + System.out.println("Activity Worker started for task queue: " + TASK_QUEUE); } } diff --git a/src/main/java/io/temporal/samples/moneytransfer/AccountTransferWorker.java b/src/main/java/io/temporal/samples/moneytransfer/AccountTransferWorker.java index ac2ec0bb..fc4272bc 100644 --- a/src/main/java/io/temporal/samples/moneytransfer/AccountTransferWorker.java +++ b/src/main/java/io/temporal/samples/moneytransfer/AccountTransferWorker.java @@ -19,7 +19,7 @@ package io.temporal.samples.moneytransfer; -import static io.temporal.samples.moneytransfer.AccountActivityWorker.TASK_LIST; +import static io.temporal.samples.moneytransfer.AccountActivityWorker.TASK_QUEUE; import io.temporal.client.WorkflowClient; import io.temporal.serviceclient.WorkflowServiceStubs; @@ -30,18 +30,18 @@ public class AccountTransferWorker { @SuppressWarnings("CatchAndPrintStackTrace") public static void main(String[] args) { - // Get worker to poll the common task list. + // Get worker to poll the common task queue. // gRPC stubs wrapper that talks to the local docker instance of temporal service. WorkflowServiceStubs service = WorkflowServiceStubs.newInstance(); // client that can be used to start and signal workflows WorkflowClient client = WorkflowClient.newInstance(service); - // worker factory that can be used to create workers for specific task lists + // worker factory that can be used to create workers for specific task queues WorkerFactory factory = WorkerFactory.newInstance(client); - Worker workerForCommonTaskList = factory.newWorker(TASK_LIST); - workerForCommonTaskList.registerWorkflowImplementationTypes(AccountTransferWorkflowImpl.class); + Worker workerForCommonTaskQueue = factory.newWorker(TASK_QUEUE); + workerForCommonTaskQueue.registerWorkflowImplementationTypes(AccountTransferWorkflowImpl.class); // Start all workers created by this factory. factory.start(); - System.out.println("Worker started for task list: " + TASK_LIST); + System.out.println("Worker started for task queue: " + TASK_QUEUE); } } diff --git a/src/main/java/io/temporal/samples/moneytransfer/TransferRequester.java b/src/main/java/io/temporal/samples/moneytransfer/TransferRequester.java index 2e60eb60..35abb6de 100644 --- a/src/main/java/io/temporal/samples/moneytransfer/TransferRequester.java +++ b/src/main/java/io/temporal/samples/moneytransfer/TransferRequester.java @@ -19,7 +19,7 @@ package io.temporal.samples.moneytransfer; -import static io.temporal.samples.moneytransfer.AccountActivityWorker.TASK_LIST; +import static io.temporal.samples.moneytransfer.AccountActivityWorker.TASK_QUEUE; import io.temporal.client.WorkflowClient; import io.temporal.client.WorkflowOptions; @@ -45,7 +45,7 @@ public static void main(String[] args) { WorkflowClient workflowClient = WorkflowClient.newInstance(service); // now we can start running instances of our saga - its state will be persisted - WorkflowOptions options = WorkflowOptions.newBuilder().setTaskList(TASK_LIST).build(); + WorkflowOptions options = WorkflowOptions.newBuilder().setTaskQueue(TASK_QUEUE).build(); AccountTransferWorkflow transferWorkflow = workflowClient.newWorkflowStub(AccountTransferWorkflow.class, options); String from = "account1"; diff --git a/src/main/java/io/temporal/samples/updatabletimer/DynamicSleepWorkflowStarter.java b/src/main/java/io/temporal/samples/updatabletimer/DynamicSleepWorkflowStarter.java index 4f8cf3ca..f6d5248e 100644 --- a/src/main/java/io/temporal/samples/updatabletimer/DynamicSleepWorkflowStarter.java +++ b/src/main/java/io/temporal/samples/updatabletimer/DynamicSleepWorkflowStarter.java @@ -20,7 +20,7 @@ package io.temporal.samples.updatabletimer; import static io.temporal.samples.updatabletimer.DynamicSleepWorkflowWorker.DYNAMIC_SLEEP_WORKFLOW_ID; -import static io.temporal.samples.updatabletimer.DynamicSleepWorkflowWorker.TASK_LIST; +import static io.temporal.samples.updatabletimer.DynamicSleepWorkflowWorker.TASK_QUEUE; import io.temporal.client.WorkflowClient; import io.temporal.client.WorkflowExecutionAlreadyStarted; @@ -43,7 +43,7 @@ public static void main(String[] args) { client.newWorkflowStub( DynamicSleepWorkflow.class, WorkflowOptions.newBuilder() - .setTaskList(TASK_LIST) + .setTaskQueue(TASK_QUEUE) .setWorkflowId(DYNAMIC_SLEEP_WORKFLOW_ID) .setWorkflowIdReusePolicy( WorkflowIdReusePolicy.WORKFLOW_ID_REUSE_POLICY_ALLOW_DUPLICATE) diff --git a/src/main/java/io/temporal/samples/updatabletimer/DynamicSleepWorkflowWorker.java b/src/main/java/io/temporal/samples/updatabletimer/DynamicSleepWorkflowWorker.java index cc4f82c5..e0472513 100644 --- a/src/main/java/io/temporal/samples/updatabletimer/DynamicSleepWorkflowWorker.java +++ b/src/main/java/io/temporal/samples/updatabletimer/DynamicSleepWorkflowWorker.java @@ -28,7 +28,7 @@ public class DynamicSleepWorkflowWorker { - static final String TASK_LIST = "TimerUpdate"; + static final String TASK_QUEUE = "TimerUpdate"; private static final Logger logger = LoggerFactory.getLogger(DynamicSleepWorkflowWorker.class); /** Create just one workflow instance for the sake of the sample. */ @@ -38,9 +38,9 @@ public static void main(String[] args) { WorkflowServiceStubs service = WorkflowServiceStubs.newInstance(); WorkflowClient client = WorkflowClient.newInstance(service); WorkerFactory factory = WorkerFactory.newInstance(client); - final Worker worker = factory.newWorker(TASK_LIST); + final Worker worker = factory.newWorker(TASK_QUEUE); worker.registerWorkflowImplementationTypes(DynamicSleepWorkflowImpl.class); factory.start(); - logger.info("Worker started for task list: " + TASK_LIST); + logger.info("Worker started for task queue: " + TASK_QUEUE); } } diff --git a/src/main/java/io/temporal/samples/updatabletimer/README.md b/src/main/java/io/temporal/samples/updatabletimer/README.md index d5e7f8ff..2e094c8e 100644 --- a/src/main/java/io/temporal/samples/updatabletimer/README.md +++ b/src/main/java/io/temporal/samples/updatabletimer/README.md @@ -22,7 +22,7 @@ Then in a different terminal window start the workflow instance: Check the output of the worker window. The expected output is: ```bash -10:38:56.282 [main] INFO i.t.s.timerupdate.DynamicSleepWorker - Worker started for task list: TimerUpdate +10:38:56.282 [main] INFO i.t.s.timerupdate.DynamicSleepWorker - Worker started for task queue: TimerUpdate 10:39:07.359 [workflow-732875527] INFO i.t.s.t.DynamicSleepWorkflowImpl - sleepUntil: Thu May 28 10:40:06 PDT 2020 10:39:07.360 [workflow-732875527] INFO i.t.s.t.DynamicSleepWorkflowImpl - Going to sleep for PT59.688S ``` diff --git a/src/test/java/io/temporal/samples/bookingsaga/TripBookingWorkflowTest.java b/src/test/java/io/temporal/samples/bookingsaga/TripBookingWorkflowTest.java index 7e9a1609..66e1012e 100644 --- a/src/test/java/io/temporal/samples/bookingsaga/TripBookingWorkflowTest.java +++ b/src/test/java/io/temporal/samples/bookingsaga/TripBookingWorkflowTest.java @@ -19,7 +19,7 @@ package io.temporal.samples.bookingsaga; -import static io.temporal.samples.bookingsaga.TripBookingSaga.TASK_LIST; +import static io.temporal.samples.bookingsaga.TripBookingSaga.TASK_QUEUE; import static org.junit.Assert.assertEquals; import static org.junit.Assert.fail; import static org.mockito.Matchers.eq; @@ -44,7 +44,7 @@ public class TripBookingWorkflowTest { @Before public void setUp() { testEnv = TestWorkflowEnvironment.newInstance(); - worker = testEnv.newWorker(TASK_LIST); + worker = testEnv.newWorker(TASK_QUEUE); worker.registerWorkflowImplementationTypes(TripBookingWorkflowImpl.class); client = testEnv.getWorkflowClient(); @@ -66,7 +66,8 @@ public void testTripBookingFails() { TripBookingWorkflow workflow = client.newWorkflowStub( - TripBookingWorkflow.class, WorkflowOptions.newBuilder().setTaskList(TASK_LIST).build()); + TripBookingWorkflow.class, + WorkflowOptions.newBuilder().setTaskQueue(TASK_QUEUE).build()); try { workflow.bookTrip("trip1"); fail("unreachable"); @@ -91,7 +92,8 @@ public void testSAGA() { TripBookingWorkflow workflow = client.newWorkflowStub( - TripBookingWorkflow.class, WorkflowOptions.newBuilder().setTaskList(TASK_LIST).build()); + TripBookingWorkflow.class, + WorkflowOptions.newBuilder().setTaskQueue(TASK_QUEUE).build()); try { workflow.bookTrip("trip1"); fail("unreachable"); diff --git a/src/test/java/io/temporal/samples/fileprocessing/FileProcessingTest.java b/src/test/java/io/temporal/samples/fileprocessing/FileProcessingTest.java index f5db5f5f..64b16d54 100644 --- a/src/test/java/io/temporal/samples/fileprocessing/FileProcessingTest.java +++ b/src/test/java/io/temporal/samples/fileprocessing/FileProcessingTest.java @@ -19,7 +19,7 @@ package io.temporal.samples.fileprocessing; -import static io.temporal.samples.fileprocessing.FileProcessingWorker.TASK_LIST; +import static io.temporal.samples.fileprocessing.FileProcessingWorker.TASK_QUEUE; import static org.mockito.Matchers.anyObject; import static org.mockito.Mockito.*; @@ -27,7 +27,7 @@ import io.temporal.client.WorkflowOptions; import io.temporal.enums.v1.TimeoutType; import io.temporal.failure.TimeoutFailure; -import io.temporal.samples.fileprocessing.StoreActivities.TaskListFileNamePair; +import io.temporal.samples.fileprocessing.StoreActivities.TaskQueueFileNamePair; import io.temporal.testing.TestWorkflowEnvironment; import io.temporal.worker.Worker; import java.net.MalformedURLException; @@ -86,7 +86,7 @@ protected void failed(Throwable e, Description description) { @Before public void setUp() { testEnv = TestWorkflowEnvironment.newInstance(); - worker = testEnv.newWorker(TASK_LIST); + worker = testEnv.newWorker(TASK_QUEUE); worker.registerWorkflowImplementationTypes(FileProcessingWorkflowImpl.class); workerHost1 = testEnv.newWorker(HOST_NAME_1); workerHost2 = testEnv.newWorker(HOST_NAME_2); @@ -103,7 +103,7 @@ public void tearDown() { public void testHappyPath() { StoreActivities activities = mock(StoreActivities.class); when(activities.download(anyObject())) - .thenReturn(new TaskListFileNamePair(HOST_NAME_1, FILE_NAME_UNPROCESSED)); + .thenReturn(new TaskQueueFileNamePair(HOST_NAME_1, FILE_NAME_UNPROCESSED)); worker.registerActivitiesImplementations(activities); StoreActivities activitiesHost1 = mock(StoreActivities.class); @@ -117,7 +117,7 @@ public void testHappyPath() { FileProcessingWorkflow workflow = client.newWorkflowStub( FileProcessingWorkflow.class, - WorkflowOptions.newBuilder().setTaskList(TASK_LIST).build()); + WorkflowOptions.newBuilder().setTaskQueue(TASK_QUEUE).build()); // Execute workflow waiting for completion. workflow.processFile(SOURCE, DESTINATION); @@ -135,8 +135,8 @@ public void testHappyPath() { public void testHostFailover() { StoreActivities activities = mock(StoreActivities.class); when(activities.download(anyObject())) - .thenReturn(new TaskListFileNamePair(HOST_NAME_1, FILE_NAME_UNPROCESSED)) - .thenReturn(new TaskListFileNamePair(HOST_NAME_2, FILE_NAME_UNPROCESSED)); + .thenReturn(new TaskQueueFileNamePair(HOST_NAME_1, FILE_NAME_UNPROCESSED)) + .thenReturn(new TaskQueueFileNamePair(HOST_NAME_2, FILE_NAME_UNPROCESSED)); worker.registerActivitiesImplementations(activities); @@ -156,7 +156,7 @@ public void testHostFailover() { FileProcessingWorkflow workflow = client.newWorkflowStub( FileProcessingWorkflow.class, - WorkflowOptions.newBuilder().setTaskList(TASK_LIST).build()); + WorkflowOptions.newBuilder().setTaskQueue(TASK_QUEUE).build()); workflow.processFile(SOURCE, DESTINATION); diff --git a/src/test/java/io/temporal/samples/hello/HelloActivityRetryTest.java b/src/test/java/io/temporal/samples/hello/HelloActivityRetryTest.java index e1e6a896..f0558b1a 100644 --- a/src/test/java/io/temporal/samples/hello/HelloActivityRetryTest.java +++ b/src/test/java/io/temporal/samples/hello/HelloActivityRetryTest.java @@ -61,7 +61,7 @@ protected void failed(Throwable e, Description description) { @Before public void setUp() { testEnv = TestWorkflowEnvironment.newInstance(); - worker = testEnv.newWorker(HelloActivityRetry.TASK_LIST); + worker = testEnv.newWorker(HelloActivityRetry.TASK_QUEUE); worker.registerWorkflowImplementationTypes(GreetingWorkflowImpl.class); client = testEnv.getWorkflowClient(); @@ -78,7 +78,7 @@ public void testActivityImpl() { testEnv.start(); WorkflowOptions workflowOptions = - WorkflowOptions.newBuilder().setTaskList(HelloActivityRetry.TASK_LIST).build(); + WorkflowOptions.newBuilder().setTaskQueue(HelloActivityRetry.TASK_QUEUE).build(); GreetingWorkflow workflow = client.newWorkflowStub(GreetingWorkflow.class, workflowOptions); // Execute a workflow waiting for it to complete. @@ -98,9 +98,9 @@ public void testMockedActivity() { worker.registerActivitiesImplementations(activities); testEnv.start(); - // Get a workflow stub using the same task list the worker uses. + // Get a workflow stub using the same task queue the worker uses. WorkflowOptions workflowOptions = - WorkflowOptions.newBuilder().setTaskList(HelloActivityRetry.TASK_LIST).build(); + WorkflowOptions.newBuilder().setTaskQueue(HelloActivityRetry.TASK_QUEUE).build(); GreetingWorkflow workflow = client.newWorkflowStub(GreetingWorkflow.class, workflowOptions); // Execute a workflow waiting for it to complete. String greeting = workflow.getGreeting("World"); diff --git a/src/test/java/io/temporal/samples/hello/HelloActivityTest.java b/src/test/java/io/temporal/samples/hello/HelloActivityTest.java index f931c3b8..8f9f87e5 100644 --- a/src/test/java/io/temporal/samples/hello/HelloActivityTest.java +++ b/src/test/java/io/temporal/samples/hello/HelloActivityTest.java @@ -19,7 +19,7 @@ package io.temporal.samples.hello; -import static io.temporal.samples.hello.HelloActivity.TASK_LIST; +import static io.temporal.samples.hello.HelloActivity.TASK_QUEUE; import static org.junit.Assert.assertEquals; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; @@ -46,7 +46,7 @@ public class HelloActivityTest { @Before public void setUp() { testEnv = TestWorkflowEnvironment.newInstance(); - worker = testEnv.newWorker(TASK_LIST); + worker = testEnv.newWorker(TASK_QUEUE); worker.registerWorkflowImplementationTypes(GreetingWorkflowImpl.class); client = testEnv.getWorkflowClient(); @@ -62,10 +62,10 @@ public void testActivityImpl() { worker.registerActivitiesImplementations(new GreetingActivitiesImpl()); testEnv.start(); - // Get a workflow stub using the same task list the worker uses. + // Get a workflow stub using the same task queue the worker uses. GreetingWorkflow workflow = client.newWorkflowStub( - GreetingWorkflow.class, WorkflowOptions.newBuilder().setTaskList(TASK_LIST).build()); + GreetingWorkflow.class, WorkflowOptions.newBuilder().setTaskQueue(TASK_QUEUE).build()); // Execute a workflow waiting for it to complete. String greeting = workflow.getGreeting("World"); assertEquals("Hello World!", greeting); @@ -78,10 +78,10 @@ public void testMockedActivity() { worker.registerActivitiesImplementations(activities); testEnv.start(); - // Get a workflow stub using the same task list the worker uses. + // Get a workflow stub using the same task queue the worker uses. GreetingWorkflow workflow = client.newWorkflowStub( - GreetingWorkflow.class, WorkflowOptions.newBuilder().setTaskList(TASK_LIST).build()); + GreetingWorkflow.class, WorkflowOptions.newBuilder().setTaskQueue(TASK_QUEUE).build()); // Execute a workflow waiting for it to complete. String greeting = workflow.getGreeting("World"); assertEquals("Hello World!", greeting); diff --git a/src/test/java/io/temporal/samples/hello/HelloAsyncActivityCompletionTest.java b/src/test/java/io/temporal/samples/hello/HelloAsyncActivityCompletionTest.java index 2ec026c1..9cccdfa9 100644 --- a/src/test/java/io/temporal/samples/hello/HelloAsyncActivityCompletionTest.java +++ b/src/test/java/io/temporal/samples/hello/HelloAsyncActivityCompletionTest.java @@ -19,7 +19,7 @@ package io.temporal.samples.hello; -import static io.temporal.samples.hello.HelloAsyncActivityCompletion.TASK_LIST; +import static io.temporal.samples.hello.HelloAsyncActivityCompletion.TASK_QUEUE; import static org.junit.Assert.assertEquals; import io.temporal.client.ActivityCompletionClient; @@ -65,7 +65,7 @@ protected void failed(Throwable e, Description description) { @Before public void setUp() { testEnv = TestWorkflowEnvironment.newInstance(); - worker = testEnv.newWorker(TASK_LIST); + worker = testEnv.newWorker(TASK_QUEUE); worker.registerWorkflowImplementationTypes(GreetingWorkflowImpl.class); client = testEnv.getWorkflowClient(); @@ -84,7 +84,7 @@ public void testActivityImpl() throws ExecutionException, InterruptedException { GreetingWorkflow workflow = client.newWorkflowStub( - GreetingWorkflow.class, WorkflowOptions.newBuilder().setTaskList(TASK_LIST).build()); + GreetingWorkflow.class, WorkflowOptions.newBuilder().setTaskQueue(TASK_QUEUE).build()); // Execute a workflow asynchronously. CompletableFuture greeting = WorkflowClient.execute(workflow::getGreeting, "World"); // Wait for workflow completion. diff --git a/src/test/java/io/temporal/samples/hello/HelloAsyncLambdaTest.java b/src/test/java/io/temporal/samples/hello/HelloAsyncLambdaTest.java index 8e1063ca..3a5b6ce8 100644 --- a/src/test/java/io/temporal/samples/hello/HelloAsyncLambdaTest.java +++ b/src/test/java/io/temporal/samples/hello/HelloAsyncLambdaTest.java @@ -64,7 +64,7 @@ protected void failed(Throwable e, Description description) { @Before public void setUp() { testEnv = TestWorkflowEnvironment.newInstance(); - worker = testEnv.newWorker(HelloAsyncLambda.TASK_LIST); + worker = testEnv.newWorker(HelloAsyncLambda.TASK_QUEUE); worker.registerWorkflowImplementationTypes(GreetingWorkflowImpl.class); client = testEnv.getWorkflowClient(); @@ -80,9 +80,9 @@ public void testActivityImpl() { worker.registerActivitiesImplementations(new GreetingActivitiesImpl()); testEnv.start(); - // Get a workflow stub using the same task list the worker uses. + // Get a workflow stub using the same task queue the worker uses. WorkflowOptions workflowOptions = - WorkflowOptions.newBuilder().setTaskList(HelloAsyncLambda.TASK_LIST).build(); + WorkflowOptions.newBuilder().setTaskQueue(HelloAsyncLambda.TASK_QUEUE).build(); GreetingWorkflow workflow = client.newWorkflowStub(GreetingWorkflow.class, workflowOptions); // Execute a workflow waiting for it to complete. String greeting = workflow.getGreeting("World"); @@ -98,7 +98,7 @@ public void testMockedActivity() { testEnv.start(); WorkflowOptions workflowOptions = - WorkflowOptions.newBuilder().setTaskList(HelloAsyncLambda.TASK_LIST).build(); + WorkflowOptions.newBuilder().setTaskQueue(HelloAsyncLambda.TASK_QUEUE).build(); GreetingWorkflow workflow = client.newWorkflowStub(GreetingWorkflow.class, workflowOptions); // Execute a workflow waiting for it to complete. String greeting = workflow.getGreeting("World"); diff --git a/src/test/java/io/temporal/samples/hello/HelloAsyncTest.java b/src/test/java/io/temporal/samples/hello/HelloAsyncTest.java index ef1c5023..e306a28d 100644 --- a/src/test/java/io/temporal/samples/hello/HelloAsyncTest.java +++ b/src/test/java/io/temporal/samples/hello/HelloAsyncTest.java @@ -19,7 +19,7 @@ package io.temporal.samples.hello; -import static io.temporal.samples.hello.HelloAsync.TASK_LIST; +import static io.temporal.samples.hello.HelloAsync.TASK_QUEUE; import static org.junit.Assert.assertEquals; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; @@ -65,7 +65,7 @@ protected void failed(Throwable e, Description description) { @Before public void setUp() { testEnv = TestWorkflowEnvironment.newInstance(); - worker = testEnv.newWorker(TASK_LIST); + worker = testEnv.newWorker(TASK_QUEUE); worker.registerWorkflowImplementationTypes(GreetingWorkflowImpl.class); client = testEnv.getWorkflowClient(); @@ -83,7 +83,7 @@ public void testActivityImpl() { GreetingWorkflow workflow = client.newWorkflowStub( - GreetingWorkflow.class, WorkflowOptions.newBuilder().setTaskList(TASK_LIST).build()); + GreetingWorkflow.class, WorkflowOptions.newBuilder().setTaskQueue(TASK_QUEUE).build()); // Execute a workflow waiting for it to complete. String greeting = workflow.getGreeting("World"); assertEquals("Hello World!\nBye World!", greeting); @@ -99,7 +99,7 @@ public void testMockedActivity() { GreetingWorkflow workflow = client.newWorkflowStub( - GreetingWorkflow.class, WorkflowOptions.newBuilder().setTaskList(TASK_LIST).build()); + GreetingWorkflow.class, WorkflowOptions.newBuilder().setTaskQueue(TASK_QUEUE).build()); // Execute a workflow waiting for it to complete. String greeting = workflow.getGreeting("World"); assertEquals("Hello World!\nBye World!", greeting); diff --git a/src/test/java/io/temporal/samples/hello/HelloChildTest.java b/src/test/java/io/temporal/samples/hello/HelloChildTest.java index 99ed0251..e614727f 100644 --- a/src/test/java/io/temporal/samples/hello/HelloChildTest.java +++ b/src/test/java/io/temporal/samples/hello/HelloChildTest.java @@ -19,7 +19,7 @@ package io.temporal.samples.hello; -import static io.temporal.samples.hello.HelloChild.TASK_LIST; +import static io.temporal.samples.hello.HelloChild.TASK_QUEUE; import static org.junit.Assert.assertEquals; import static org.mockito.Matchers.eq; import static org.mockito.Mockito.*; @@ -63,7 +63,7 @@ protected void failed(Throwable e, Description description) { @Before public void setUp() { testEnv = TestWorkflowEnvironment.newInstance(); - worker = testEnv.newWorker(TASK_LIST); + worker = testEnv.newWorker(TASK_QUEUE); client = testEnv.getWorkflowClient(); } @@ -79,10 +79,10 @@ public void testChild() { testEnv.start(); - // Get a workflow stub using the same task list the worker uses. + // Get a workflow stub using the same task queue the worker uses. GreetingWorkflow workflow = client.newWorkflowStub( - GreetingWorkflow.class, WorkflowOptions.newBuilder().setTaskList(TASK_LIST).build()); + GreetingWorkflow.class, WorkflowOptions.newBuilder().setTaskQueue(TASK_QUEUE).build()); // Execute a workflow waiting for it to complete. String greeting = workflow.getGreeting("World"); assertEquals("Hello World!", greeting); @@ -104,10 +104,10 @@ public void testMockedChild() { }); testEnv.start(); - // Get a workflow stub using the same task list the worker uses. + // Get a workflow stub using the same task queue the worker uses. GreetingWorkflow workflow = client.newWorkflowStub( - GreetingWorkflow.class, WorkflowOptions.newBuilder().setTaskList(TASK_LIST).build()); + GreetingWorkflow.class, WorkflowOptions.newBuilder().setTaskQueue(TASK_QUEUE).build()); // Execute a workflow waiting for it to complete. String greeting = workflow.getGreeting("World"); assertEquals("Hello World!", greeting); diff --git a/src/test/java/io/temporal/samples/hello/HelloCronTest.java b/src/test/java/io/temporal/samples/hello/HelloCronTest.java index 40135f56..b18454ea 100644 --- a/src/test/java/io/temporal/samples/hello/HelloCronTest.java +++ b/src/test/java/io/temporal/samples/hello/HelloCronTest.java @@ -20,7 +20,7 @@ package io.temporal.samples.hello; import static io.temporal.samples.hello.HelloCron.CRON_WORKFLOW_ID; -import static io.temporal.samples.hello.HelloCron.TASK_LIST; +import static io.temporal.samples.hello.HelloCron.TASK_QUEUE; import static org.junit.Assert.assertEquals; import static org.mockito.Matchers.anyString; import static org.mockito.Mockito.*; @@ -67,7 +67,7 @@ protected void failed(Throwable e, Description description) { @Before public void setUp() { testEnv = TestWorkflowEnvironment.newInstance(); - worker = testEnv.newWorker(HelloCron.TASK_LIST); + worker = testEnv.newWorker(HelloCron.TASK_QUEUE); worker.registerWorkflowImplementationTypes(GreetingWorkflowImpl.class); client = testEnv.getWorkflowClient(); @@ -89,7 +89,7 @@ public void testMockedActivity() { WorkflowOptions workflowOptions = WorkflowOptions.newBuilder() .setCronSchedule("0 * * * *") - .setTaskList(TASK_LIST) + .setTaskQueue(TASK_QUEUE) .setWorkflowId(CRON_WORKFLOW_ID) .build(); GreetingWorkflow workflow = client.newWorkflowStub(GreetingWorkflow.class, workflowOptions); diff --git a/src/test/java/io/temporal/samples/hello/HelloExceptionTest.java b/src/test/java/io/temporal/samples/hello/HelloExceptionTest.java index 788277eb..b4ece52e 100644 --- a/src/test/java/io/temporal/samples/hello/HelloExceptionTest.java +++ b/src/test/java/io/temporal/samples/hello/HelloExceptionTest.java @@ -19,7 +19,7 @@ package io.temporal.samples.hello; -import static io.temporal.samples.hello.HelloException.TASK_LIST; +import static io.temporal.samples.hello.HelloException.TASK_QUEUE; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; import static org.mockito.Matchers.anyString; @@ -70,7 +70,7 @@ protected void failed(Throwable e, Description description) { @Before public void setUp() { testEnv = TestWorkflowEnvironment.newInstance(); - worker = testEnv.newWorker(HelloException.TASK_LIST); + worker = testEnv.newWorker(HelloException.TASK_QUEUE); client = testEnv.getWorkflowClient(); } @@ -87,7 +87,7 @@ public void testIOException() { worker.registerActivitiesImplementations(new HelloException.GreetingActivitiesImpl()); testEnv.start(); - WorkflowOptions workflowOptions = WorkflowOptions.newBuilder().setTaskList(TASK_LIST).build(); + WorkflowOptions workflowOptions = WorkflowOptions.newBuilder().setTaskQueue(TASK_QUEUE).build(); GreetingWorkflow workflow = client.newWorkflowStub(GreetingWorkflow.class, workflowOptions); try { workflow.getGreeting("World"); @@ -116,7 +116,7 @@ public void testActivityTimeout() { testEnv.start(); - WorkflowOptions workflowOptions = WorkflowOptions.newBuilder().setTaskList(TASK_LIST).build(); + WorkflowOptions workflowOptions = WorkflowOptions.newBuilder().setTaskQueue(TASK_QUEUE).build(); GreetingWorkflow workflow = client.newWorkflowStub(GreetingWorkflow.class, workflowOptions); try { workflow.getGreeting("World"); @@ -150,7 +150,7 @@ public void testChildWorkflowTimeout() { testEnv.start(); - WorkflowOptions workflowOptions = WorkflowOptions.newBuilder().setTaskList(TASK_LIST).build(); + WorkflowOptions workflowOptions = WorkflowOptions.newBuilder().setTaskQueue(TASK_QUEUE).build(); GreetingWorkflow workflow = client.newWorkflowStub(GreetingWorkflow.class, workflowOptions); try { workflow.getGreeting("World"); diff --git a/src/test/java/io/temporal/samples/hello/HelloPeriodicTest.java b/src/test/java/io/temporal/samples/hello/HelloPeriodicTest.java index e3231193..a4e5ac2a 100644 --- a/src/test/java/io/temporal/samples/hello/HelloPeriodicTest.java +++ b/src/test/java/io/temporal/samples/hello/HelloPeriodicTest.java @@ -20,7 +20,7 @@ package io.temporal.samples.hello; import static io.temporal.samples.hello.HelloPeriodic.PERIODIC_WORKFLOW_ID; -import static io.temporal.samples.hello.HelloPeriodic.TASK_LIST; +import static io.temporal.samples.hello.HelloPeriodic.TASK_QUEUE; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; import static org.mockito.Matchers.anyString; @@ -74,7 +74,7 @@ protected void failed(Throwable e, Description description) { @Before public void setUp() { testEnv = TestWorkflowEnvironment.newInstance(); - worker = testEnv.newWorker(TASK_LIST); + worker = testEnv.newWorker(TASK_QUEUE); worker.registerWorkflowImplementationTypes(GreetingWorkflowImpl.class); client = testEnv.getWorkflowClient(); @@ -90,12 +90,12 @@ public void testPeriodicActivityInvocation() { worker.registerActivitiesImplementations(new GreetingActivitiesImpl()); testEnv.start(); - // Get a workflow stub using the same task list the worker uses. + // Get a workflow stub using the same task queue the worker uses. GreetingWorkflow workflow = client.newWorkflowStub( GreetingWorkflow.class, WorkflowOptions.newBuilder() - .setTaskList(TASK_LIST) + .setTaskQueue(TASK_QUEUE) .setWorkflowId(PERIODIC_WORKFLOW_ID) .build()); // Execute a workflow waiting for it to complete. @@ -125,12 +125,12 @@ public void testMockedActivity() { worker.registerActivitiesImplementations(activities); testEnv.start(); - // Get a workflow stub using the same task list the worker uses. + // Get a workflow stub using the same task queue the worker uses. GreetingWorkflow workflow = client.newWorkflowStub( GreetingWorkflow.class, WorkflowOptions.newBuilder() - .setTaskList(TASK_LIST) + .setTaskQueue(TASK_QUEUE) .setWorkflowId(PERIODIC_WORKFLOW_ID) .build()); // Execute a workflow waiting for it to complete. diff --git a/src/test/java/io/temporal/samples/hello/HelloPolymorphicActivityTest.java b/src/test/java/io/temporal/samples/hello/HelloPolymorphicActivityTest.java index e00f7363..c6571659 100644 --- a/src/test/java/io/temporal/samples/hello/HelloPolymorphicActivityTest.java +++ b/src/test/java/io/temporal/samples/hello/HelloPolymorphicActivityTest.java @@ -19,7 +19,7 @@ package io.temporal.samples.hello; -import static io.temporal.samples.hello.HelloActivity.TASK_LIST; +import static io.temporal.samples.hello.HelloActivity.TASK_QUEUE; import static org.junit.Assert.assertEquals; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; @@ -46,7 +46,7 @@ public class HelloPolymorphicActivityTest { @Before public void setUp() { testEnv = TestWorkflowEnvironment.newInstance(); - worker = testEnv.newWorker(TASK_LIST); + worker = testEnv.newWorker(TASK_QUEUE); worker.registerWorkflowImplementationTypes(GreetingWorkflowImpl.class); client = testEnv.getWorkflowClient(); @@ -62,10 +62,10 @@ public void testActivityImpl() { worker.registerActivitiesImplementations(new HelloActivityImpl(), new ByeActivityImpl()); testEnv.start(); - // Get a workflow stub using the same task list the worker uses. + // Get a workflow stub using the same task queue the worker uses. GreetingWorkflow workflow = client.newWorkflowStub( - GreetingWorkflow.class, WorkflowOptions.newBuilder().setTaskList(TASK_LIST).build()); + GreetingWorkflow.class, WorkflowOptions.newBuilder().setTaskQueue(TASK_QUEUE).build()); // Execute a workflow waiting for it to complete. String greeting = workflow.getGreeting("World"); assertEquals("Hello World!\nBye World!\n", greeting); @@ -81,10 +81,10 @@ public void testMockedActivity() { worker.registerActivitiesImplementations(hello, bye); testEnv.start(); - // Get a workflow stub using the same task list the worker uses. + // Get a workflow stub using the same task queue the worker uses. GreetingWorkflow workflow = client.newWorkflowStub( - GreetingWorkflow.class, WorkflowOptions.newBuilder().setTaskList(TASK_LIST).build()); + GreetingWorkflow.class, WorkflowOptions.newBuilder().setTaskQueue(TASK_QUEUE).build()); // Execute a workflow waiting for it to complete. String greeting = workflow.getGreeting("World"); assertEquals("Hello World!\nBye World!\n", greeting); diff --git a/src/test/java/io/temporal/samples/hello/HelloQueryTest.java b/src/test/java/io/temporal/samples/hello/HelloQueryTest.java index 4a08a42f..47449c6d 100644 --- a/src/test/java/io/temporal/samples/hello/HelloQueryTest.java +++ b/src/test/java/io/temporal/samples/hello/HelloQueryTest.java @@ -58,10 +58,10 @@ protected void failed(Throwable e, Description description) { public void setUp() { testEnv = TestWorkflowEnvironment.newInstance(); - worker = testEnv.newWorker(HelloQuery.TASK_LIST); + worker = testEnv.newWorker(HelloQuery.TASK_QUEUE); // Comment the above line and uncomment the below one to see how the TestWatcher rule prints // the history of the stuck workflow as its decision task is never picked up. - // worker = testEnv.newWorker("InvalidTaskList"); + // worker = testEnv.newWorker("InvalidTaskQueue"); worker.registerWorkflowImplementationTypes(HelloQuery.GreetingWorkflowImpl.class); testEnv.start(); @@ -76,9 +76,9 @@ public void tearDown() { @Test(timeout = 5000) public void testQuery() { - // Get a workflow stub using the same task list the worker uses. + // Get a workflow stub using the same task queue the worker uses. WorkflowOptions workflowOptions = - WorkflowOptions.newBuilder().setTaskList(HelloQuery.TASK_LIST).build(); + WorkflowOptions.newBuilder().setTaskQueue(HelloQuery.TASK_QUEUE).build(); GreetingWorkflow workflow = client.newWorkflowStub(GreetingWorkflow.class, workflowOptions); // Start workflow asynchronously to not use another thread to query. diff --git a/src/test/java/io/temporal/samples/hello/HelloSignalTest.java b/src/test/java/io/temporal/samples/hello/HelloSignalTest.java index 32e1e12f..a2b553bd 100644 --- a/src/test/java/io/temporal/samples/hello/HelloSignalTest.java +++ b/src/test/java/io/temporal/samples/hello/HelloSignalTest.java @@ -60,7 +60,7 @@ protected void failed(Throwable e, Description description) { public void setUp() { testEnv = TestWorkflowEnvironment.newInstance(); - worker = testEnv.newWorker(HelloSignal.TASK_LIST); + worker = testEnv.newWorker(HelloSignal.TASK_QUEUE); worker.registerWorkflowImplementationTypes(HelloSignal.GreetingWorkflowImpl.class); testEnv.start(); @@ -74,10 +74,10 @@ public void tearDown() { @Test public void testSignal() { - // Get a workflow stub using the same task list the worker uses. + // Get a workflow stub using the same task queue the worker uses. WorkflowOptions workflowOptions = WorkflowOptions.newBuilder() - .setTaskList(HelloSignal.TASK_LIST) + .setTaskQueue(HelloSignal.TASK_QUEUE) .setWorkflowIdReusePolicy( WorkflowIdReusePolicy.WORKFLOW_ID_REUSE_POLICY_REJECT_DUPLICATE) .build(); diff --git a/src/test/java/io/temporal/samples/moneybatch/TransferWorkflowTest.java b/src/test/java/io/temporal/samples/moneybatch/TransferWorkflowTest.java index 957b7e05..597942b1 100644 --- a/src/test/java/io/temporal/samples/moneybatch/TransferWorkflowTest.java +++ b/src/test/java/io/temporal/samples/moneybatch/TransferWorkflowTest.java @@ -19,7 +19,7 @@ package io.temporal.samples.moneybatch; -import static io.temporal.samples.moneybatch.AccountActivityWorker.TASK_LIST; +import static io.temporal.samples.moneybatch.AccountActivityWorker.TASK_QUEUE; import static org.mockito.Matchers.any; import static org.mockito.Matchers.eq; import static org.mockito.Mockito.mock; @@ -61,7 +61,7 @@ protected void failed(Throwable e, Description description) { @Before public void setUp() { testEnv = TestWorkflowEnvironment.newInstance(); - worker = testEnv.newWorker(TASK_LIST); + worker = testEnv.newWorker(TASK_QUEUE); worker.registerWorkflowImplementationTypes(AccountTransferWorkflowImpl.class); workflowClient = testEnv.getWorkflowClient(); @@ -82,7 +82,7 @@ public void testTransfer() { String to = "account2"; int batchSize = 5; WorkflowOptions options = - WorkflowOptions.newBuilder().setTaskList(TASK_LIST).setWorkflowId(to).build(); + WorkflowOptions.newBuilder().setTaskQueue(TASK_QUEUE).setWorkflowId(to).build(); AccountTransferWorkflow transferWorkflow = workflowClient.newWorkflowStub(AccountTransferWorkflow.class, options); WorkflowClient.start(transferWorkflow::deposit, to, batchSize); diff --git a/src/test/java/io/temporal/samples/moneytransfer/TransferWorkflowTest.java b/src/test/java/io/temporal/samples/moneytransfer/TransferWorkflowTest.java index d121ad4b..95fe8219 100644 --- a/src/test/java/io/temporal/samples/moneytransfer/TransferWorkflowTest.java +++ b/src/test/java/io/temporal/samples/moneytransfer/TransferWorkflowTest.java @@ -19,7 +19,7 @@ package io.temporal.samples.moneytransfer; -import static io.temporal.samples.moneytransfer.AccountActivityWorker.TASK_LIST; +import static io.temporal.samples.moneytransfer.AccountActivityWorker.TASK_QUEUE; import static org.mockito.Matchers.eq; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.verify; @@ -41,7 +41,7 @@ public class TransferWorkflowTest { @Before public void setUp() { testEnv = TestWorkflowEnvironment.newInstance(); - worker = testEnv.newWorker(TASK_LIST); + worker = testEnv.newWorker(TASK_QUEUE); worker.registerWorkflowImplementationTypes(AccountTransferWorkflowImpl.class); workflowClient = testEnv.getWorkflowClient(); @@ -57,7 +57,7 @@ public void testTransfer() { Account activities = mock(Account.class); worker.registerActivitiesImplementations(activities); testEnv.start(); - WorkflowOptions options = WorkflowOptions.newBuilder().setTaskList(TASK_LIST).build(); + WorkflowOptions options = WorkflowOptions.newBuilder().setTaskQueue(TASK_QUEUE).build(); AccountTransferWorkflow workflow = workflowClient.newWorkflowStub(AccountTransferWorkflow.class, options); long starty = testEnv.currentTimeMillis(); From 9fa63454d70bbc10a59e5d6efd48e3f4e30919c4 Mon Sep 17 00:00:00 2001 From: Maxim Fateev Date: Sat, 27 Jun 2020 17:45:49 -0700 Subject: [PATCH 4/4] updated service version --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 35a75386..4b91fcdd 100644 --- a/README.md +++ b/README.md @@ -47,7 +47,7 @@ choose **Gradle** and then click **Next**->**Finish**. Run Temporal Server using Docker Compose: - curl -L https://github.com/temporalio/temporal/releases/download/v0.25.0/docker.tar.gz | tar -xz --strip-components 1 docker/docker-compose.yml + curl -L https://github.com/temporalio/temporal/releases/download/v0.26.0/docker.tar.gz | tar -xz --strip-components 1 docker/docker-compose.yml docker-compose up If this does not work, see the instructions for running Temporal Server at https://github.com/temporalio/temporal/blob/master/README.md.