diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index 3e2e0df58..d3c936966 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -1,13 +1,15 @@
name: "Continuous Integration"
on: [push, pull_request]
+permissions:
+ contents: read
jobs:
validation:
name: "Gradle wrapper validation"
runs-on: ubuntu-latest
steps:
- - uses: actions/checkout@v4
- - uses: gradle/wrapper-validation-action@v3
+ - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
+ - uses: gradle/actions/wrapper-validation@ac396bf1a80af16236baf54bd7330ae21dc6ece5 # v6
unittest:
name: Unit Tests
@@ -15,7 +17,7 @@ jobs:
timeout-minutes: 15
steps:
- name: Checkout repo
- uses: actions/checkout@v4
+ uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
with:
fetch-depth: 0
submodules: recursive
@@ -23,28 +25,28 @@ jobs:
- name: Run unit tests
run: |
- docker compose -f ./docker/github/docker-compose.yaml up unit-test
+ docker compose -f ./docker/github/docker-compose.yaml up --exit-code-from unit-test unit-test
- copyright:
- name: Copyright and code format
+ code_format:
+ name: Code format
runs-on: ubuntu-latest
timeout-minutes: 20
steps:
- name: Checkout repo
- uses: actions/checkout@v4
+ uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
with:
fetch-depth: 0
submodules: recursive
ref: ${{ github.event.pull_request.head.sha }}
- name: Set up Java
- uses: actions/setup-java@v4
+ uses: actions/setup-java@be666c2fcd27ec809703dec50e508c2fdc7f6654 # v5
with:
java-version: "11"
distribution: "temurin"
- name: Set up Gradle
- uses: gradle/actions/setup-gradle@v3
+ uses: gradle/actions/setup-gradle@ac396bf1a80af16236baf54bd7330ae21dc6ece5 # v6
- name: Run copyright and code format checks
- run: ./gradlew --no-daemon checkLicenseMain checkLicenses spotlessCheck
\ No newline at end of file
+ run: ./gradlew --no-daemon spotlessCheck
diff --git a/.gitignore b/.gitignore
index 87bc9f8e1..038d5ef43 100644
--- a/.gitignore
+++ b/.gitignore
@@ -16,4 +16,6 @@ target
.classpath
.project
.settings/
-bin/
\ No newline at end of file
+bin/
+core/.vscode/
+.claude/
diff --git a/LICENSE.txt b/LICENSE
similarity index 91%
rename from LICENSE.txt
rename to LICENSE
index e89e81b36..e4f46f431 100644
--- a/LICENSE.txt
+++ b/LICENSE
@@ -1,6 +1,6 @@
Temporal Java SDK
-Copyright (c) 2020 Temporal Technologies, Inc. All Rights Reserved
+Copyright (c) 2025 Temporal Technologies, Inc. All Rights Reserved
Copyright (c) 2017 Uber Technologies, Inc. All Rights Reserved
diff --git a/README.md b/README.md
index b30743697..4d00e320b 100644
--- a/README.md
+++ b/README.md
@@ -79,7 +79,8 @@ See the README.md file in each main sample directory for cut/paste Gradle comman
- [**HelloDelayedStart**](/core/src/main/java/io/temporal/samples/hello/HelloDelayedStart.java): Demonstrates how to use delayed start config option when starting a Workflow Executions.
- [**HelloSignalWithTimer**](/core/src/main/java/io/temporal/samples/hello/HelloSignalWithTimer.java): Demonstrates how to use collect signals for certain amount of time and then process last one.
- [**HelloWorkflowTimer**](/core/src/main/java/io/temporal/samples/hello/HelloWorkflowTimer.java): Demonstrates how we can use workflow timer to restrict duration of workflow execution instead of workflow run/execution timeouts.
-
+ - [**Auto-Heartbeating**](/core/src/main/java/io/temporal/samples/autoheartbeat/): Demonstrates use of Auto-heartbeating utility via activity interceptor.
+ - [**HelloSignalWithStartAndWorkflowInit**](/core/src/main/java/io/temporal/samples/hello/HelloSignalWithStartAndWorkflowInit.java): Demonstrates how WorkflowInit can be useful with SignalWithStart to initialize workflow variables.
#### Scenario-based samples
@@ -105,6 +106,15 @@ See the README.md file in each main sample directory for cut/paste Gradle comman
- [**Safe Message Passing**](/core/src/main/java/io/temporal/samples/safemessagepassing): Safely handling concurrent updates and signals messages.
+- [**Custom Annotation**](/core/src/main/java/io/temporal/samples/customannotation): Demonstrates how to create a custom annotation using an interceptor.
+
+- [**Async Packet Delivery**](/core/src/main/java/io/temporal/samples/packetdelivery): Demonstrates running multiple execution paths async within single execution.
+
+- [**Worker Versioning**](/core/src/main/java/io/temporal/samples/workerversioning): Demonstrates how to use worker versioning to manage workflow code changes.
+
+- [**Environment Configuration**](/core/src/main/java/io/temporal/samples/envconfig):
+Load client configuration from TOML files with programmatic overrides.
+
#### API demonstrations
- [**Async Untyped Child Workflow**](/core/src/main/java/io/temporal/samples/asyncuntypedchild): Demonstrates how to invoke an untyped child workflow async, that can complete after parent workflow is already completed.
@@ -131,6 +141,8 @@ See the README.md file in each main sample directory for cut/paste Gradle comman
- [**Configure WorkflowClient to use mTLS**](/core/src/main/java/io/temporal/samples/ssl): Demonstrates how to configure WorkflowClient when using mTLS.
+- [**Configure WorkflowClient to use API Key**](/core/src/main/java/io/temporal/samples/apikey): Demonstrates how to configure WorkflowClient when using API Keys.
+
- [**Payload Codec**](/core/src/main/java/io/temporal/samples/encodefailures): Demonstrates how to use simple codec to encode/decode failure messages.
- [**Exclude Workflow/ActivityTypes from Interceptors**](/core/src/main/java/io/temporal/samples/excludefrominterceptor): Demonstrates how to exclude certain workflow / activity types from interceptors.
@@ -149,6 +161,16 @@ See the README.md file in each main sample directory for cut/paste Gradle comman
- [**AWS Encryption SDK**](/core/src/main/java/io/temporal/samples/keymanagementencryption/awsencryptionsdk): Demonstrates how to use the AWS Encryption SDK to encrypt and decrypt payloads with AWS KMS.
+#### Nexus Samples
+
+- [**Getting Started**](/core/src/main/java/io/temporal/samples/nexus): Demonstrates how to get started with Temporal and Nexus.
+
+- [**Mapping Multiple Arguments**](/core/src/main/java/io/temporal/samples/nexus): Demonstrates how map a Nexus operation to a Workflow that takes multiple arguments.
+
+- [**Cancellation**](/core/src/main/java/io/temporal/samples/nexuscancellation): Demonstrates how to cancel an async Nexus operation.
+
+- [**Context/Header Propagation**](/core/src/main/java/io/temporal/samples/nexuscontextpropagation): Demonstrates how to propagate context through Nexus operation headers.
+
### Running SpringBoot Samples
diff --git a/build.gradle b/build.gradle
index 92d13ca62..0cafde690 100644
--- a/build.gradle
+++ b/build.gradle
@@ -1,5 +1,4 @@
plugins {
- id 'org.cadixdev.licenser' version '0.6.1'
id "net.ltgt.errorprone" version "4.0.1"
id 'com.diffplug.spotless' version '6.25.0' apply false
id "org.springframework.boot" version "${springBootPluginVersion}"
@@ -7,7 +6,6 @@ plugins {
subprojects {
apply plugin: 'java'
- apply plugin: 'org.cadixdev.licenser'
apply plugin: 'net.ltgt.errorprone'
apply plugin: 'com.diffplug.spotless'
@@ -28,7 +26,7 @@ subprojects {
ext {
otelVersion = '1.30.1'
otelVersionAlpha = "${otelVersion}-alpha"
- javaSDKVersion = '1.27.0'
+ javaSDKVersion = '1.34.0'
camelVersion = '3.22.1'
jarVersion = '1.0.0'
}
@@ -44,15 +42,6 @@ subprojects {
}
- license {
- header rootProject.file('license-header.txt')
- exclude '**/*.json'
- exclude '**/*.yaml'
- exclude '**/*.yml'
- exclude '**/*.html'
- exclude '**/*.js'
- }
-
apply plugin: 'com.diffplug.spotless'
spotless {
diff --git a/core/build.gradle b/core/build.gradle
index 42ad4be2b..c5157db3d 100644
--- a/core/build.gradle
+++ b/core/build.gradle
@@ -4,7 +4,11 @@ dependencies {
implementation "io.temporal:temporal-opentracing:$javaSDKVersion"
testImplementation("io.temporal:temporal-testing:$javaSDKVersion")
+ // Environment configuration
+ implementation "io.temporal:temporal-envconfig:$javaSDKVersion"
+
// Needed for SDK related functionality
+ implementation "io.grpc:grpc-util"
implementation(platform("com.fasterxml.jackson:jackson-bom:2.17.2"))
implementation "com.fasterxml.jackson.core:jackson-databind"
implementation "com.fasterxml.jackson.core:jackson-core"
diff --git a/core/src/main/java/io/temporal/samples/apikey/ApiKeyWorker.java b/core/src/main/java/io/temporal/samples/apikey/ApiKeyWorker.java
new file mode 100644
index 000000000..2c4a326d4
--- /dev/null
+++ b/core/src/main/java/io/temporal/samples/apikey/ApiKeyWorker.java
@@ -0,0 +1,80 @@
+package io.temporal.samples.apikey;
+
+import io.temporal.client.WorkflowClient;
+import io.temporal.client.WorkflowClientOptions;
+import io.temporal.envconfig.ClientConfigProfile;
+import io.temporal.serviceclient.WorkflowServiceStubs;
+import io.temporal.serviceclient.WorkflowServiceStubsOptions;
+import io.temporal.worker.Worker;
+import io.temporal.worker.WorkerFactory;
+import java.io.IOException;
+
+public class ApiKeyWorker {
+ static final String TASK_QUEUE = "MyTaskQueue";
+
+ public static void main(String[] args) throws Exception {
+ // Load configuration from environment and files
+ ClientConfigProfile profile;
+ try {
+ profile = ClientConfigProfile.load();
+ } catch (IOException e) {
+ throw new RuntimeException("Failed to load client configuration", e);
+ }
+
+ // For temporal cloud this would be ${cloud-region}.{cloud}.api.temporal.io:7233
+ // Example us-east-1.aws.api.temporal.io:7233
+ String targetEndpoint = System.getenv("TEMPORAL_ENDPOINT");
+ // Your registered namespace.
+ String namespace = System.getenv("TEMPORAL_NAMESPACE");
+ // Your API Key
+ String apiKey = System.getenv("TEMPORAL_API_KEY");
+
+ if (targetEndpoint == null || namespace == null || apiKey == null) {
+ throw new IllegalArgumentException(
+ "TEMPORAL_ENDPOINT, TEMPORAL_NAMESPACE, and TEMPORAL_API_KEY environment variables must be set");
+ }
+
+ // Create API Key enabled client with environment config as base
+ WorkflowServiceStubs service =
+ WorkflowServiceStubs.newServiceStubs(
+ WorkflowServiceStubsOptions.newBuilder(profile.toWorkflowServiceStubsOptions())
+ .setTarget(targetEndpoint)
+ .setEnableHttps(true)
+ .addApiKey(() -> apiKey)
+ .build());
+
+ // Now setup and start workflow worker
+ WorkflowClient client =
+ WorkflowClient.newInstance(
+ service,
+ WorkflowClientOptions.newBuilder(profile.toWorkflowClientOptions())
+ .setNamespace(namespace)
+ .build());
+
+ // worker factory that can be used to create workers for specific task queues
+ WorkerFactory factory = WorkerFactory.newInstance(client);
+
+ /*
+ * Define the workflow worker. Workflow workers listen to a defined task queue and process
+ * workflows and activities.
+ */
+ Worker worker = factory.newWorker(TASK_QUEUE);
+
+ /*
+ * Register our workflow implementation with the worker.
+ * Workflow implementations must be known to the worker at runtime in
+ * order to dispatch workflow tasks.
+ */
+ worker.registerWorkflowImplementationTypes(MyWorkflowImpl.class);
+
+ /*
+ * Start all the workers registered for a specific task queue.
+ * The started workers then start polling for workflows and activities.
+ */
+ factory.start();
+
+ System.out.println("Worker started. Press Ctrl+C to exit.");
+ // Keep the worker running
+ Thread.currentThread().join();
+ }
+}
diff --git a/core/src/main/java/io/temporal/samples/apikey/MyWorkflow.java b/core/src/main/java/io/temporal/samples/apikey/MyWorkflow.java
new file mode 100644
index 000000000..d02953d73
--- /dev/null
+++ b/core/src/main/java/io/temporal/samples/apikey/MyWorkflow.java
@@ -0,0 +1,10 @@
+package io.temporal.samples.apikey;
+
+import io.temporal.workflow.WorkflowInterface;
+import io.temporal.workflow.WorkflowMethod;
+
+@WorkflowInterface
+public interface MyWorkflow {
+ @WorkflowMethod
+ String execute();
+}
diff --git a/core/src/main/java/io/temporal/samples/apikey/MyWorkflowImpl.java b/core/src/main/java/io/temporal/samples/apikey/MyWorkflowImpl.java
new file mode 100644
index 000000000..f6fea0fe7
--- /dev/null
+++ b/core/src/main/java/io/temporal/samples/apikey/MyWorkflowImpl.java
@@ -0,0 +1,8 @@
+package io.temporal.samples.apikey;
+
+public class MyWorkflowImpl implements MyWorkflow {
+ @Override
+ public String execute() {
+ return "done";
+ }
+}
diff --git a/core/src/main/java/io/temporal/samples/apikey/README.md b/core/src/main/java/io/temporal/samples/apikey/README.md
new file mode 100644
index 000000000..494aa0458
--- /dev/null
+++ b/core/src/main/java/io/temporal/samples/apikey/README.md
@@ -0,0 +1,83 @@
+# Workflow execution with API Key
+
+This example shows how to secure your Temporal application with API Key authentication.
+This is required to connect with Temporal Cloud or any production Temporal deployment that uses API Key authentication.
+
+## Prerequisites
+
+1. A Temporal Cloud account
+2. A namespace in Temporal Cloud
+3. An API Key for your namespace
+
+## Getting your API Key
+
+1. Log in to your Temporal Cloud account
+2. Navigate to your namespace
+3. Go to Namespace Settings > API Keys
+4. Click "Create API Key"
+5. Give your API Key a name and select the appropriate permissions
+6. Copy the API Key value (you won't be able to see it again)
+
+## Export env variables
+
+Before running the example you need to export the following env variables:
+
+```bash
+# Your Temporal Cloud endpoint (e.g., us-east-1.aws.api.temporal.io:7233)
+export TEMPORAL_ENDPOINT="us-east-1.aws.api.temporal.io:7233"
+
+# Your Temporal Cloud namespace
+export TEMPORAL_NAMESPACE="your-namespace"
+
+# Your API Key from Temporal Cloud
+export TEMPORAL_API_KEY="your-api-key"
+```
+
+## Running this sample
+
+This sample consists of two components that need to be run in separate terminals:
+
+1. First, start the worker:
+```bash
+./gradlew -q execute -PmainClass=io.temporal.samples.apikey.ApiKeyWorker
+```
+
+2. Then, in a new terminal, run the starter:
+```bash
+./gradlew -q execute -PmainClass=io.temporal.samples.apikey.Starter
+```
+
+## Expected result
+
+When running the worker, you should see:
+```text
+[main] INFO i.t.s.WorkflowServiceStubsImpl - Created WorkflowServiceStubs for channel: ManagedChannelOrphanWrapper{delegate=ManagedChannelImpl{logId=1, target=us-east-1.aws.api.temporal.io:7233}}
+[main] INFO io.temporal.internal.worker.Poller - start: Poller{name=Workflow Poller taskQueue="MyTaskQueue", namespace="your-namespace"}
+Worker started. Press Ctrl+C to exit.
+```
+
+When running the starter, you should see:
+```text
+[main] INFO i.t.s.WorkflowServiceStubsImpl - Created WorkflowServiceStubs for channel: ManagedChannelOrphanWrapper{delegate=ManagedChannelImpl{logId=1, target=us-east-1.aws.api.temporal.io:7233}}
+[main] INFO io.temporal.internal.worker.Poller - start: Poller{name=Workflow Poller taskQueue="MyTaskQueue", namespace="your-namespace"}
+done
+```
+
+## Troubleshooting
+
+If you encounter any issues:
+
+1. Verify your environment variables are set correctly:
+ ```bash
+ echo $TEMPORAL_ENDPOINT
+ echo $TEMPORAL_NAMESPACE
+ echo $TEMPORAL_API_KEY
+ ```
+
+2. Check that your API Key has the correct permissions for your namespace
+
+3. Ensure your namespace is active and accessible
+
+4. If you get connection errors, verify your endpoint is correct and accessible from your network
+
+5. Make sure you're running the commands from the correct directory (where the `gradlew` script is located)
diff --git a/core/src/main/java/io/temporal/samples/apikey/Starter.java b/core/src/main/java/io/temporal/samples/apikey/Starter.java
new file mode 100644
index 000000000..ac0fbce8c
--- /dev/null
+++ b/core/src/main/java/io/temporal/samples/apikey/Starter.java
@@ -0,0 +1,79 @@
+package io.temporal.samples.apikey;
+
+import io.temporal.client.WorkflowClient;
+import io.temporal.client.WorkflowClientOptions;
+import io.temporal.client.WorkflowOptions;
+import io.temporal.envconfig.ClientConfigProfile;
+import io.temporal.serviceclient.WorkflowServiceStubs;
+import io.temporal.serviceclient.WorkflowServiceStubsOptions;
+import io.temporal.worker.Worker;
+import io.temporal.worker.WorkerFactory;
+import java.io.IOException;
+
+public class Starter {
+
+ static final String TASK_QUEUE = "MyTaskQueue";
+ static final String WORKFLOW_ID = "HelloAPIKeyWorkflow";
+
+ public static void main(String[] args) throws Exception {
+ // Load configuration from environment and files
+ ClientConfigProfile profile;
+ try {
+ profile = ClientConfigProfile.load();
+ } catch (IOException e) {
+ throw new RuntimeException("Failed to load client configuration", e);
+ }
+
+ // For temporal cloud this would be ${cloud-region}.{cloud}.api.temporal.io:7233
+ // Example us-east-1.aws.api.temporal.io:7233
+ String targetEndpoint = System.getenv("TEMPORAL_ENDPOINT");
+ // Your registered namespace.
+ String namespace = System.getenv("TEMPORAL_NAMESPACE");
+ // Your API Key
+ String apiKey = System.getenv("TEMPORAL_API_KEY");
+
+ if (targetEndpoint == null || namespace == null || apiKey == null) {
+ throw new IllegalArgumentException(
+ "TEMPORAL_ENDPOINT, TEMPORAL_NAMESPACE, and TEMPORAL_API_KEY environment variables must be set");
+ }
+
+ // Create API Key enabled client with environment config as base
+ WorkflowServiceStubs service =
+ WorkflowServiceStubs.newServiceStubs(
+ WorkflowServiceStubsOptions.newBuilder(profile.toWorkflowServiceStubsOptions())
+ .setTarget(targetEndpoint)
+ .setEnableHttps(true)
+ .addApiKey(() -> apiKey)
+ .build());
+
+ WorkflowClient client =
+ WorkflowClient.newInstance(
+ service,
+ WorkflowClientOptions.newBuilder(profile.toWorkflowClientOptions())
+ .setNamespace(namespace)
+ .build());
+
+ WorkerFactory factory = WorkerFactory.newInstance(client);
+
+ Worker worker = factory.newWorker(TASK_QUEUE);
+
+ worker.registerWorkflowImplementationTypes(MyWorkflowImpl.class);
+
+ factory.start();
+
+ // Create the workflow client stub. It is used to start our workflow execution.
+ MyWorkflow workflow =
+ client.newWorkflowStub(
+ MyWorkflow.class,
+ WorkflowOptions.newBuilder()
+ .setWorkflowId(WORKFLOW_ID)
+ .setTaskQueue(TASK_QUEUE)
+ .build());
+
+ String greeting = workflow.execute();
+
+ // Display workflow execution results
+ System.out.println(greeting);
+ System.exit(0);
+ }
+}
diff --git a/core/src/main/java/io/temporal/samples/asyncchild/ChildWorkflow.java b/core/src/main/java/io/temporal/samples/asyncchild/ChildWorkflow.java
index 5009d68d3..6b60caac2 100644
--- a/core/src/main/java/io/temporal/samples/asyncchild/ChildWorkflow.java
+++ b/core/src/main/java/io/temporal/samples/asyncchild/ChildWorkflow.java
@@ -1,22 +1,3 @@
-/*
- * Copyright (c) 2020 Temporal Technologies, Inc. All Rights Reserved
- *
- * Copyright 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
- * Modifications copyright (C) 2017 Uber Technologies, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"). You may not
- * use this file except in compliance with the License. A copy of the License is
- * located at
- *
- * http://aws.amazon.com/apache2.0
- *
- * or in the "license" file accompanying this file. This file is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
package io.temporal.samples.asyncchild;
import io.temporal.workflow.WorkflowInterface;
diff --git a/core/src/main/java/io/temporal/samples/asyncchild/ChildWorkflowImpl.java b/core/src/main/java/io/temporal/samples/asyncchild/ChildWorkflowImpl.java
index 846ce39be..b375b3248 100644
--- a/core/src/main/java/io/temporal/samples/asyncchild/ChildWorkflowImpl.java
+++ b/core/src/main/java/io/temporal/samples/asyncchild/ChildWorkflowImpl.java
@@ -1,22 +1,3 @@
-/*
- * Copyright (c) 2020 Temporal Technologies, Inc. All Rights Reserved
- *
- * Copyright 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
- * Modifications copyright (C) 2017 Uber Technologies, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"). You may not
- * use this file except in compliance with the License. A copy of the License is
- * located at
- *
- * http://aws.amazon.com/apache2.0
- *
- * or in the "license" file accompanying this file. This file is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
package io.temporal.samples.asyncchild;
import io.temporal.workflow.Workflow;
diff --git a/core/src/main/java/io/temporal/samples/asyncchild/ParentWorkflow.java b/core/src/main/java/io/temporal/samples/asyncchild/ParentWorkflow.java
index 4a031bd08..6ac603ae8 100644
--- a/core/src/main/java/io/temporal/samples/asyncchild/ParentWorkflow.java
+++ b/core/src/main/java/io/temporal/samples/asyncchild/ParentWorkflow.java
@@ -1,22 +1,3 @@
-/*
- * Copyright (c) 2020 Temporal Technologies, Inc. All Rights Reserved
- *
- * Copyright 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
- * Modifications copyright (C) 2017 Uber Technologies, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"). You may not
- * use this file except in compliance with the License. A copy of the License is
- * located at
- *
- * http://aws.amazon.com/apache2.0
- *
- * or in the "license" file accompanying this file. This file is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
package io.temporal.samples.asyncchild;
import io.temporal.api.common.v1.WorkflowExecution;
diff --git a/core/src/main/java/io/temporal/samples/asyncchild/ParentWorkflowImpl.java b/core/src/main/java/io/temporal/samples/asyncchild/ParentWorkflowImpl.java
index 61dd13b3e..f98cffa0a 100644
--- a/core/src/main/java/io/temporal/samples/asyncchild/ParentWorkflowImpl.java
+++ b/core/src/main/java/io/temporal/samples/asyncchild/ParentWorkflowImpl.java
@@ -1,22 +1,3 @@
-/*
- * Copyright (c) 2020 Temporal Technologies, Inc. All Rights Reserved
- *
- * Copyright 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
- * Modifications copyright (C) 2017 Uber Technologies, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"). You may not
- * use this file except in compliance with the License. A copy of the License is
- * located at
- *
- * http://aws.amazon.com/apache2.0
- *
- * or in the "license" file accompanying this file. This file is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
package io.temporal.samples.asyncchild;
import io.temporal.api.common.v1.WorkflowExecution;
diff --git a/core/src/main/java/io/temporal/samples/asyncchild/Starter.java b/core/src/main/java/io/temporal/samples/asyncchild/Starter.java
index 126918043..339bd94fd 100644
--- a/core/src/main/java/io/temporal/samples/asyncchild/Starter.java
+++ b/core/src/main/java/io/temporal/samples/asyncchild/Starter.java
@@ -1,22 +1,3 @@
-/*
- * Copyright (c) 2020 Temporal Technologies, Inc. All Rights Reserved
- *
- * Copyright 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
- * Modifications copyright (C) 2017 Uber Technologies, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"). You may not
- * use this file except in compliance with the License. A copy of the License is
- * located at
- *
- * http://aws.amazon.com/apache2.0
- *
- * or in the "license" file accompanying this file. This file is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
package io.temporal.samples.asyncchild;
import io.temporal.api.common.v1.WorkflowExecution;
@@ -25,20 +6,32 @@
import io.temporal.api.workflowservice.v1.DescribeWorkflowExecutionResponse;
import io.temporal.client.WorkflowClient;
import io.temporal.client.WorkflowOptions;
+import io.temporal.envconfig.ClientConfigProfile;
import io.temporal.serviceclient.WorkflowServiceStubs;
import io.temporal.worker.Worker;
import io.temporal.worker.WorkerFactory;
+import java.io.IOException;
import java.util.concurrent.TimeUnit;
public class Starter {
public static final String TASK_QUEUE = "asyncChildTaskQueue";
- private static final WorkflowServiceStubs service = WorkflowServiceStubs.newLocalServiceStubs();
- private static final WorkflowClient client = WorkflowClient.newInstance(service);
- private static final WorkerFactory factory = WorkerFactory.newInstance(client);
public static void main(String[] args) {
- createWorker();
+ // Load configuration from environment and files
+ ClientConfigProfile profile;
+ try {
+ profile = ClientConfigProfile.load();
+ } catch (IOException e) {
+ throw new RuntimeException("Failed to load client configuration", e);
+ }
+
+ WorkflowServiceStubs service =
+ WorkflowServiceStubs.newServiceStubs(profile.toWorkflowServiceStubsOptions());
+ WorkflowClient client = WorkflowClient.newInstance(service, profile.toWorkflowClientOptions());
+ WorkerFactory factory = WorkerFactory.newInstance(client);
+
+ createWorker(factory);
WorkflowOptions parentWorkflowOptions =
WorkflowOptions.newBuilder()
@@ -52,25 +45,28 @@ public static void main(String[] args) {
WorkflowExecution childWorkflowExecution = parentWorkflowStub.executeParent();
// Get the child workflow execution status (after parent completed)
- System.out.println("Child execution status: " + getStatusAsString(childWorkflowExecution));
+ System.out.println(
+ "Child execution status: " + getStatusAsString(childWorkflowExecution, client, service));
// Wait for child workflow to complete
sleep(4);
// Check the status of the child workflow again
- System.out.println("Child execution status: " + getStatusAsString(childWorkflowExecution));
+ System.out.println(
+ "Child execution status: " + getStatusAsString(childWorkflowExecution, client, service));
System.exit(0);
}
- private static void createWorker() {
+ private static void createWorker(WorkerFactory factory) {
Worker worker = factory.newWorker(TASK_QUEUE);
worker.registerWorkflowImplementationTypes(ParentWorkflowImpl.class, ChildWorkflowImpl.class);
factory.start();
}
- private static String getStatusAsString(WorkflowExecution execution) {
+ private static String getStatusAsString(
+ WorkflowExecution execution, WorkflowClient client, WorkflowServiceStubs service) {
DescribeWorkflowExecutionRequest describeWorkflowExecutionRequest =
DescribeWorkflowExecutionRequest.newBuilder()
.setNamespace(client.getOptions().getNamespace())
diff --git a/core/src/main/java/io/temporal/samples/asyncuntypedchild/ChildWorkflow.java b/core/src/main/java/io/temporal/samples/asyncuntypedchild/ChildWorkflow.java
index 9cd9d75d2..48b57a57d 100644
--- a/core/src/main/java/io/temporal/samples/asyncuntypedchild/ChildWorkflow.java
+++ b/core/src/main/java/io/temporal/samples/asyncuntypedchild/ChildWorkflow.java
@@ -1,22 +1,3 @@
-/*
- * Copyright (c) 2020 Temporal Technologies, Inc. All Rights Reserved
- *
- * Copyright 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
- * Modifications copyright (C) 2017 Uber Technologies, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"). You may not
- * use this file except in compliance with the License. A copy of the License is
- * located at
- *
- * http://aws.amazon.com/apache2.0
- *
- * or in the "license" file accompanying this file. This file is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
package io.temporal.samples.asyncuntypedchild;
import io.temporal.workflow.WorkflowInterface;
diff --git a/core/src/main/java/io/temporal/samples/asyncuntypedchild/ChildWorkflowImpl.java b/core/src/main/java/io/temporal/samples/asyncuntypedchild/ChildWorkflowImpl.java
index 958bd0fc3..3f33a9470 100644
--- a/core/src/main/java/io/temporal/samples/asyncuntypedchild/ChildWorkflowImpl.java
+++ b/core/src/main/java/io/temporal/samples/asyncuntypedchild/ChildWorkflowImpl.java
@@ -1,22 +1,3 @@
-/*
- * Copyright (c) 2020 Temporal Technologies, Inc. All Rights Reserved
- *
- * Copyright 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
- * Modifications copyright (C) 2017 Uber Technologies, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"). You may not
- * use this file except in compliance with the License. A copy of the License is
- * located at
- *
- * http://aws.amazon.com/apache2.0
- *
- * or in the "license" file accompanying this file. This file is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
package io.temporal.samples.asyncuntypedchild;
import io.temporal.workflow.Workflow;
diff --git a/core/src/main/java/io/temporal/samples/asyncuntypedchild/ParentWorkflow.java b/core/src/main/java/io/temporal/samples/asyncuntypedchild/ParentWorkflow.java
index b911ed234..10397b365 100644
--- a/core/src/main/java/io/temporal/samples/asyncuntypedchild/ParentWorkflow.java
+++ b/core/src/main/java/io/temporal/samples/asyncuntypedchild/ParentWorkflow.java
@@ -1,22 +1,3 @@
-/*
- * Copyright (c) 2020 Temporal Technologies, Inc. All Rights Reserved
- *
- * Copyright 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
- * Modifications copyright (C) 2017 Uber Technologies, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"). You may not
- * use this file except in compliance with the License. A copy of the License is
- * located at
- *
- * http://aws.amazon.com/apache2.0
- *
- * or in the "license" file accompanying this file. This file is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
package io.temporal.samples.asyncuntypedchild;
import io.temporal.workflow.WorkflowInterface;
diff --git a/core/src/main/java/io/temporal/samples/asyncuntypedchild/ParentWorkflowImpl.java b/core/src/main/java/io/temporal/samples/asyncuntypedchild/ParentWorkflowImpl.java
index 87cb9fd0f..d16e45137 100644
--- a/core/src/main/java/io/temporal/samples/asyncuntypedchild/ParentWorkflowImpl.java
+++ b/core/src/main/java/io/temporal/samples/asyncuntypedchild/ParentWorkflowImpl.java
@@ -1,22 +1,3 @@
-/*
- * Copyright (c) 2020 Temporal Technologies, Inc. All Rights Reserved
- *
- * Copyright 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
- * Modifications copyright (C) 2017 Uber Technologies, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"). You may not
- * use this file except in compliance with the License. A copy of the License is
- * located at
- *
- * http://aws.amazon.com/apache2.0
- *
- * or in the "license" file accompanying this file. This file is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
package io.temporal.samples.asyncuntypedchild;
import static io.temporal.samples.asyncuntypedchild.Starter.WORKFLOW_ID;
diff --git a/core/src/main/java/io/temporal/samples/asyncuntypedchild/Starter.java b/core/src/main/java/io/temporal/samples/asyncuntypedchild/Starter.java
index 2453376ce..885a0c05c 100644
--- a/core/src/main/java/io/temporal/samples/asyncuntypedchild/Starter.java
+++ b/core/src/main/java/io/temporal/samples/asyncuntypedchild/Starter.java
@@ -1,29 +1,12 @@
-/*
- * Copyright (c) 2020 Temporal Technologies, Inc. All Rights Reserved
- *
- * Copyright 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
- * Modifications copyright (C) 2017 Uber Technologies, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"). You may not
- * use this file except in compliance with the License. A copy of the License is
- * located at
- *
- * http://aws.amazon.com/apache2.0
- *
- * or in the "license" file accompanying this file. This file is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
package io.temporal.samples.asyncuntypedchild;
import io.temporal.client.WorkflowClient;
import io.temporal.client.WorkflowOptions;
+import io.temporal.envconfig.ClientConfigProfile;
import io.temporal.serviceclient.WorkflowServiceStubs;
import io.temporal.worker.Worker;
import io.temporal.worker.WorkerFactory;
+import java.io.IOException;
/**
* Sample Temporal Workflow Definition that demonstrates the execution of a Child Workflow. Child
@@ -43,12 +26,21 @@ public class Starter {
public static void main(String[] args) {
// Get a Workflow service stub.
- WorkflowServiceStubs service = WorkflowServiceStubs.newLocalServiceStubs();
+ // Load configuration from environment and files
+ ClientConfigProfile profile;
+ try {
+ profile = ClientConfigProfile.load();
+ } catch (IOException e) {
+ throw new RuntimeException("Failed to load client configuration", e);
+ }
+
+ WorkflowServiceStubs service =
+ WorkflowServiceStubs.newServiceStubs(profile.toWorkflowServiceStubsOptions());
/*
* Get a Workflow service client which can be used to start, Signal, and Query Workflow Executions.
*/
- WorkflowClient client = WorkflowClient.newInstance(service);
+ WorkflowClient client = WorkflowClient.newInstance(service, profile.toWorkflowClientOptions());
/*
* Define the workflow factory. It is used to create workflow workers for a specific task queue.
diff --git a/core/src/main/java/io/temporal/samples/autoheartbeat/AutoHeartbeatUtil.java b/core/src/main/java/io/temporal/samples/autoheartbeat/AutoHeartbeatUtil.java
new file mode 100644
index 000000000..ca2b0a5f4
--- /dev/null
+++ b/core/src/main/java/io/temporal/samples/autoheartbeat/AutoHeartbeatUtil.java
@@ -0,0 +1,87 @@
+/*
+ * Copyright (c) 2020 Temporal Technologies, Inc. All Rights Reserved
+ *
+ * Copyright 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
+ *
+ * Modifications copyright (C) 2017 Uber Technologies, Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"). You may not
+ * use this file except in compliance with the License. A copy of the License is
+ * located at
+ *
+ * http://aws.amazon.com/apache2.0
+ *
+ * or in the "license" file accompanying this file. This file is distributed on
+ * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied. See the License for the specific language governing
+ * permissions and limitations under the License.
+ */
+
+package io.temporal.samples.autoheartbeat;
+
+import io.temporal.activity.ActivityExecutionContext;
+import java.time.Instant;
+import java.time.ZoneId;
+import java.time.format.DateTimeFormatter;
+import java.util.concurrent.Executors;
+import java.util.concurrent.ScheduledExecutorService;
+import java.util.concurrent.ScheduledFuture;
+import java.util.concurrent.TimeUnit;
+
+public class AutoHeartbeatUtil {
+ private final long period;
+ private final long initialDelay;
+ private final TimeUnit periodTimeUnit;
+ private final ScheduledExecutorService timerService =
+ Executors.newSingleThreadScheduledExecutor();
+ private final ActivityExecutionContext context;
+ private final Object details;
+ private String heartbeaterId;
+
+ public AutoHeartbeatUtil(
+ long period,
+ long initialDelay,
+ TimeUnit periodTimeUnit,
+ ActivityExecutionContext context,
+ Object details) {
+ this.period = period;
+ this.initialDelay = initialDelay;
+ this.periodTimeUnit = periodTimeUnit;
+ this.context = context;
+ this.details = details;
+ // Set to activity id better, for sample we just use type
+ heartbeaterId = context.getInfo().getActivityType();
+ }
+
+ public ScheduledFuture> start() {
+ System.out.println("Autoheartbeater[" + heartbeaterId + "] starting...");
+ return timerService.scheduleAtFixedRate(
+ () -> {
+ // try {
+ System.out.println(
+ "Autoheartbeater["
+ + heartbeaterId
+ + "]"
+ + "heartbeating at: "
+ + printShortCurrentTime());
+ context.heartbeat(details);
+ },
+ initialDelay,
+ period,
+ periodTimeUnit);
+ }
+
+ public void stop() {
+ System.out.println("Autoheartbeater[" + heartbeaterId + "] being requested to stop.");
+ // Try not to execute another heartbeat that could have been queued up
+ // Note this can at times take a second or two so make sure to test this out on your workers
+ // So can set best heartbeat timeout (sometimes might need larger value to accomodate)
+ timerService.shutdownNow();
+ }
+
+ private String printShortCurrentTime() {
+ return DateTimeFormatter.ofPattern("HH:mm:ss")
+ .withZone(ZoneId.systemDefault())
+ .format(Instant.now());
+ }
+}
diff --git a/core/src/main/java/io/temporal/samples/autoheartbeat/README.md b/core/src/main/java/io/temporal/samples/autoheartbeat/README.md
new file mode 100644
index 000000000..946e24fc5
--- /dev/null
+++ b/core/src/main/java/io/temporal/samples/autoheartbeat/README.md
@@ -0,0 +1,21 @@
+# Auto-heartbeating sample for activities that define HeartbeatTimeout
+
+This sample shows an implementation of an "auto-heartbeating" utility that can be applied via interceptor to all
+activities where you define HeartbeatTimeout. Use case where this can be helpful include situations where you have
+long-running activities where you want to heartbeat but its difficult to explicitly call heartbeat api in activity code
+directly.
+Another useful scenario for this is where you have activity that at times can complete in very short amount of time,
+but then at times can take for example minutes. In this case you have to set longer StartToClose timeout
+but you might not want first heartbeat to be sent right away but send it after the "shorter" duration of activity
+execution.
+
+Warning: make sure to test this sample for your use case. This includes load testing. This sample was not
+tested on large scale workloads. In addition note that it is recommended to heartbeat from activity code itself. Using
+this type of autoheartbeating utility does have disatvantage that activity code itself can continue running after
+a handled activity cancelation. Please be aware of these warnings when applying this sample.
+
+1. Start the Sample:
+
+```bash
+./gradlew -q execute -PmainClass=io.temporal.samples.autoheartbeat.Starter
+```
\ No newline at end of file
diff --git a/core/src/main/java/io/temporal/samples/autoheartbeat/Starter.java b/core/src/main/java/io/temporal/samples/autoheartbeat/Starter.java
new file mode 100644
index 000000000..ae438cc41
--- /dev/null
+++ b/core/src/main/java/io/temporal/samples/autoheartbeat/Starter.java
@@ -0,0 +1,178 @@
+/*
+ * Copyright (c) 2020 Temporal Technologies, Inc. All Rights Reserved
+ *
+ * Copyright 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
+ *
+ * Modifications copyright (C) 2017 Uber Technologies, Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"). You may not
+ * use this file except in compliance with the License. A copy of the License is
+ * located at
+ *
+ * http://aws.amazon.com/apache2.0
+ *
+ * or in the "license" file accompanying this file. This file is distributed on
+ * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied. See the License for the specific language governing
+ * permissions and limitations under the License.
+ */
+
+package io.temporal.samples.autoheartbeat;
+
+import io.temporal.client.WorkflowClient;
+import io.temporal.client.WorkflowOptions;
+import io.temporal.client.WorkflowStub;
+import io.temporal.envconfig.ClientConfigProfile;
+import io.temporal.failure.CanceledFailure;
+import io.temporal.samples.autoheartbeat.activities.AutoActivitiesImpl;
+import io.temporal.samples.autoheartbeat.interceptor.AutoHeartbeatWorkerInterceptor;
+import io.temporal.samples.autoheartbeat.workflows.AutoWorkflow;
+import io.temporal.samples.autoheartbeat.workflows.AutoWorkflowImpl;
+import io.temporal.serviceclient.WorkflowServiceStubs;
+import io.temporal.worker.Worker;
+import io.temporal.worker.WorkerFactory;
+import io.temporal.worker.WorkerFactoryOptions;
+import java.io.IOException;
+
+public class Starter {
+ static final String TASK_QUEUE = "AutoheartbeatTaskQueue";
+ static final String WORKFLOW_ID = "AutoHeartbeatWorkflow";
+
+ public static void main(String[] args) {
+ // Load configuration from environment and files
+ ClientConfigProfile profile;
+ try {
+ profile = ClientConfigProfile.load();
+ } catch (IOException e) {
+ throw new RuntimeException("Failed to load client configuration", e);
+ }
+
+ WorkflowServiceStubs service =
+ WorkflowServiceStubs.newServiceStubs(profile.toWorkflowServiceStubsOptions());
+ WorkflowClient client = WorkflowClient.newInstance(service, profile.toWorkflowClientOptions());
+
+ // Configure our auto heartbeat workflow interceptor which will apply
+ // AutoHeartbeaterUtil to each activity workflow schedules which has a heartbeat
+ // timeout configured
+ WorkerFactoryOptions wfo =
+ WorkerFactoryOptions.newBuilder()
+ .setWorkerInterceptors(new AutoHeartbeatWorkerInterceptor())
+ .build();
+
+ WorkerFactory factory = WorkerFactory.newInstance(client, wfo);
+ Worker worker = factory.newWorker(TASK_QUEUE);
+
+ worker.registerWorkflowImplementationTypes(AutoWorkflowImpl.class);
+ worker.registerActivitiesImplementations(new AutoActivitiesImpl());
+
+ factory.start();
+
+ // first run completes execution with autoheartbeat utils
+ firstRun(client);
+ // second run cancels running (pending) activity via signal (specific scope cancel)
+ secondRun(client);
+ // third run cancels running execution which cancels activity as well
+ thirdRun(client);
+ // fourth run turns off autoheartbeat for activities and lets activity time out on heartbeat
+ // timeout
+ fourthRun(client);
+
+ System.exit(0);
+ }
+
+ @SuppressWarnings("unused")
+ private static void firstRun(WorkflowClient client) {
+ System.out.println("**** First Run: run workflow to completion");
+ AutoWorkflow firstRun =
+ client.newWorkflowStub(
+ AutoWorkflow.class,
+ WorkflowOptions.newBuilder()
+ .setWorkflowId(WORKFLOW_ID)
+ .setTaskQueue(TASK_QUEUE)
+ .build());
+
+ try {
+ String firstRunResult = firstRun.exec("Auto heartbeating is cool");
+ System.out.println("First run result: " + firstRunResult);
+ } catch (Exception e) {
+ System.out.println("First run - Workflow exec exception: " + e.getClass().getName());
+ }
+ }
+
+ @SuppressWarnings("unused")
+ private static void secondRun(WorkflowClient client) {
+ System.out.println("\n\n**** Second Run: cancel activities via signal");
+ AutoWorkflow secondRun =
+ client.newWorkflowStub(
+ AutoWorkflow.class,
+ WorkflowOptions.newBuilder()
+ .setWorkflowId(WORKFLOW_ID)
+ .setTaskQueue(TASK_QUEUE)
+ .build());
+ WorkflowClient.start(secondRun::exec, "Auto heartbeating is cool");
+ doSleeps(4);
+ secondRun.cancelActivity();
+
+ try {
+ String secondRunResult = WorkflowStub.fromTyped(secondRun).getResult(String.class);
+ System.out.println("Second run result: " + secondRunResult);
+ } catch (Exception e) {
+ System.out.println("Second run - Workflow exec exception: " + e.getClass().getName());
+ }
+ }
+
+ @SuppressWarnings("unused")
+ private static void thirdRun(WorkflowClient client) {
+ System.out.println("\n\n**** Third Run: cancel workflow execution");
+ AutoWorkflow thirdRun =
+ client.newWorkflowStub(
+ AutoWorkflow.class,
+ WorkflowOptions.newBuilder()
+ .setWorkflowId(WORKFLOW_ID)
+ .setTaskQueue(TASK_QUEUE)
+ .build());
+ WorkflowClient.start(thirdRun::exec, "Auto heartbeating is cool");
+ doSleeps(10);
+ try {
+ WorkflowStub.fromTyped(thirdRun).cancel();
+ String thirdRunResult = WorkflowStub.fromTyped(thirdRun).getResult(String.class);
+ System.out.println("Third run result: " + thirdRunResult);
+ } catch (Exception e) {
+ // we are expecting workflow cancelation
+ if (e.getCause() instanceof CanceledFailure) {
+ System.out.println("Third run - Workflow execution canceled.");
+ } else {
+ System.out.println("Third run - Workflow exec exception: " + e.getMessage());
+ }
+ }
+ }
+
+ @SuppressWarnings("unused")
+ private static void fourthRun(WorkflowClient client) {
+ System.out.println("\n\n**** Fourth Run: cause heartbeat timeout");
+ // we disable autoheartbeat via env var
+ System.setProperty("sample.disableAutoHeartbeat", "true");
+ AutoWorkflow fourth =
+ client.newWorkflowStub(
+ AutoWorkflow.class,
+ WorkflowOptions.newBuilder()
+ .setWorkflowId(WORKFLOW_ID)
+ .setTaskQueue(TASK_QUEUE)
+ .build());
+
+ try {
+ String fourthRunResult = fourth.exec("Auto heartbeating is cool");
+ System.out.println("Fourth run result: " + fourthRunResult);
+ } catch (Exception e) {
+ System.out.println("Fourth run - Workflow exec exception: " + e.getClass().getName());
+ }
+ }
+
+ private static void doSleeps(int seconds) {
+ try {
+ Thread.sleep(seconds * 1000L);
+ } catch (Exception e) {
+ System.out.println(e.getMessage());
+ }
+ }
+}
diff --git a/core/src/main/java/io/temporal/samples/autoheartbeat/activities/AutoActivities.java b/core/src/main/java/io/temporal/samples/autoheartbeat/activities/AutoActivities.java
new file mode 100644
index 000000000..81726e05a
--- /dev/null
+++ b/core/src/main/java/io/temporal/samples/autoheartbeat/activities/AutoActivities.java
@@ -0,0 +1,29 @@
+/*
+ * Copyright (c) 2020 Temporal Technologies, Inc. All Rights Reserved
+ *
+ * Copyright 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
+ *
+ * Modifications copyright (C) 2017 Uber Technologies, Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"). You may not
+ * use this file except in compliance with the License. A copy of the License is
+ * located at
+ *
+ * http://aws.amazon.com/apache2.0
+ *
+ * or in the "license" file accompanying this file. This file is distributed on
+ * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied. See the License for the specific language governing
+ * permissions and limitations under the License.
+ */
+
+package io.temporal.samples.autoheartbeat.activities;
+
+import io.temporal.activity.ActivityInterface;
+
+@ActivityInterface
+public interface AutoActivities {
+ String runActivityOne(String input);
+
+ String runActivityTwo(String input);
+}
diff --git a/core/src/main/java/io/temporal/samples/autoheartbeat/activities/AutoActivitiesImpl.java b/core/src/main/java/io/temporal/samples/autoheartbeat/activities/AutoActivitiesImpl.java
new file mode 100644
index 000000000..26a30162d
--- /dev/null
+++ b/core/src/main/java/io/temporal/samples/autoheartbeat/activities/AutoActivitiesImpl.java
@@ -0,0 +1,51 @@
+/*
+ * Copyright (c) 2020 Temporal Technologies, Inc. All Rights Reserved
+ *
+ * Copyright 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
+ *
+ * Modifications copyright (C) 2017 Uber Technologies, Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"). You may not
+ * use this file except in compliance with the License. A copy of the License is
+ * located at
+ *
+ * http://aws.amazon.com/apache2.0
+ *
+ * or in the "license" file accompanying this file. This file is distributed on
+ * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied. See the License for the specific language governing
+ * permissions and limitations under the License.
+ */
+
+package io.temporal.samples.autoheartbeat.activities;
+
+import java.util.concurrent.TimeUnit;
+
+public class AutoActivitiesImpl implements AutoActivities {
+
+ @Override
+ public String runActivityOne(String input) {
+ return runActivity("runActivityOne - " + input, 10);
+ }
+
+ @Override
+ public String runActivityTwo(String input) {
+ return runActivity("runActivityTwo - " + input, 5);
+ }
+
+ @SuppressWarnings("FutureReturnValueIgnored")
+ private String runActivity(String input, int seconds) {
+ for (int i = 0; i < seconds; i++) {
+ sleep(1);
+ }
+ return "Activity completed: " + input;
+ }
+
+ private void sleep(int seconds) {
+ try {
+ Thread.sleep(TimeUnit.SECONDS.toMillis(seconds));
+ } catch (InterruptedException ee) {
+ // Empty
+ }
+ }
+}
diff --git a/core/src/main/java/io/temporal/samples/autoheartbeat/interceptor/AutoHeartbeatActivityInboundCallsInterceptor.java b/core/src/main/java/io/temporal/samples/autoheartbeat/interceptor/AutoHeartbeatActivityInboundCallsInterceptor.java
new file mode 100644
index 000000000..60a2d5427
--- /dev/null
+++ b/core/src/main/java/io/temporal/samples/autoheartbeat/interceptor/AutoHeartbeatActivityInboundCallsInterceptor.java
@@ -0,0 +1,108 @@
+/*
+ * Copyright (c) 2020 Temporal Technologies, Inc. All Rights Reserved
+ *
+ * Copyright 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
+ *
+ * Modifications copyright (C) 2017 Uber Technologies, Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"). You may not
+ * use this file except in compliance with the License. A copy of the License is
+ * located at
+ *
+ * http://aws.amazon.com/apache2.0
+ *
+ * or in the "license" file accompanying this file. This file is distributed on
+ * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied. See the License for the specific language governing
+ * permissions and limitations under the License.
+ */
+
+package io.temporal.samples.autoheartbeat.interceptor;
+
+import io.temporal.activity.Activity;
+import io.temporal.activity.ActivityExecutionContext;
+import io.temporal.client.ActivityCanceledException;
+import io.temporal.common.interceptors.ActivityInboundCallsInterceptor;
+import io.temporal.common.interceptors.ActivityInboundCallsInterceptorBase;
+import io.temporal.samples.autoheartbeat.AutoHeartbeatUtil;
+import java.time.Duration;
+import java.util.concurrent.CompletableFuture;
+import java.util.concurrent.ExecutionException;
+import java.util.concurrent.ScheduledFuture;
+import java.util.concurrent.TimeUnit;
+
+public class AutoHeartbeatActivityInboundCallsInterceptor
+ extends ActivityInboundCallsInterceptorBase {
+ private ActivityExecutionContext activityExecutionContext;
+ private Duration activityHeartbeatTimeout;
+ private AutoHeartbeatUtil autoHeartbeater;
+ private ScheduledFuture scheduledFuture;
+
+ public AutoHeartbeatActivityInboundCallsInterceptor(ActivityInboundCallsInterceptor next) {
+ super(next);
+ }
+
+ @Override
+ public void init(ActivityExecutionContext context) {
+ this.activityExecutionContext = context;
+ activityHeartbeatTimeout = activityExecutionContext.getInfo().getHeartbeatTimeout();
+ super.init(context);
+ }
+
+ @Override
+ @SuppressWarnings({"FutureReturnValueIgnored", "CatchAndPrintStackTrace"})
+ public ActivityOutput execute(ActivityInput input) {
+ // If activity has heartbeat timeout defined we want to apply auto-heartbeter
+ // Unless we explicitly disabled autoheartbeating via system property
+ if (activityHeartbeatTimeout != null
+ && activityHeartbeatTimeout.getSeconds() > 0
+ && !Boolean.parseBoolean(System.getProperty("sample.disableAutoHeartbeat"))) {
+ System.out.println(
+ "Auto heartbeating applied for activity: "
+ + activityExecutionContext.getInfo().getActivityType());
+ autoHeartbeater =
+ new AutoHeartbeatUtil(2, 0, TimeUnit.SECONDS, activityExecutionContext, input);
+ scheduledFuture = autoHeartbeater.start();
+ } else {
+ System.out.println(
+ "Auto heartbeating not being applied for activity: "
+ + activityExecutionContext.getInfo().getActivityType());
+ }
+
+ if (scheduledFuture != null) {
+ CompletableFuture activityExecFuture =
+ CompletableFuture.supplyAsync(() -> super.execute(input));
+ CompletableFuture autoHeartbeatFuture =
+ CompletableFuture.supplyAsync(
+ () -> {
+ try {
+ return scheduledFuture.get();
+ } catch (Exception e) {
+ throw new ActivityCanceledException(activityExecutionContext.getInfo());
+ }
+ });
+ try {
+ return (ActivityOutput)
+ CompletableFuture.anyOf(autoHeartbeatFuture, activityExecFuture).get();
+ } catch (Exception e) {
+ if (e instanceof ExecutionException) {
+ ExecutionException ee = (ExecutionException) e;
+ if (ee.getCause() instanceof ActivityCanceledException) {
+ throw new ActivityCanceledException(activityExecutionContext.getInfo());
+ }
+ }
+ throw Activity.wrap(e);
+ } finally {
+ if (autoHeartbeater != null) {
+ autoHeartbeater.stop();
+ }
+ }
+ } else {
+ return super.execute(input);
+ }
+ }
+
+ public interface AutoHeartbeaterCancellationCallback {
+ void handle(Exception e);
+ }
+}
diff --git a/core/src/main/java/io/temporal/samples/autoheartbeat/interceptor/AutoHeartbeatWorkerInterceptor.java b/core/src/main/java/io/temporal/samples/autoheartbeat/interceptor/AutoHeartbeatWorkerInterceptor.java
new file mode 100644
index 000000000..9816fe644
--- /dev/null
+++ b/core/src/main/java/io/temporal/samples/autoheartbeat/interceptor/AutoHeartbeatWorkerInterceptor.java
@@ -0,0 +1,30 @@
+/*
+ * Copyright (c) 2020 Temporal Technologies, Inc. All Rights Reserved
+ *
+ * Copyright 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
+ *
+ * Modifications copyright (C) 2017 Uber Technologies, Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"). You may not
+ * use this file except in compliance with the License. A copy of the License is
+ * located at
+ *
+ * http://aws.amazon.com/apache2.0
+ *
+ * or in the "license" file accompanying this file. This file is distributed on
+ * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied. See the License for the specific language governing
+ * permissions and limitations under the License.
+ */
+
+package io.temporal.samples.autoheartbeat.interceptor;
+
+import io.temporal.common.interceptors.ActivityInboundCallsInterceptor;
+import io.temporal.common.interceptors.WorkerInterceptorBase;
+
+public class AutoHeartbeatWorkerInterceptor extends WorkerInterceptorBase {
+ @Override
+ public ActivityInboundCallsInterceptor interceptActivity(ActivityInboundCallsInterceptor next) {
+ return new AutoHeartbeatActivityInboundCallsInterceptor(next);
+ }
+}
diff --git a/core/src/main/java/io/temporal/samples/autoheartbeat/workflows/AutoWorkflow.java b/core/src/main/java/io/temporal/samples/autoheartbeat/workflows/AutoWorkflow.java
new file mode 100644
index 000000000..e8816c6a2
--- /dev/null
+++ b/core/src/main/java/io/temporal/samples/autoheartbeat/workflows/AutoWorkflow.java
@@ -0,0 +1,33 @@
+/*
+ * Copyright (c) 2020 Temporal Technologies, Inc. All Rights Reserved
+ *
+ * Copyright 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
+ *
+ * Modifications copyright (C) 2017 Uber Technologies, Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"). You may not
+ * use this file except in compliance with the License. A copy of the License is
+ * located at
+ *
+ * http://aws.amazon.com/apache2.0
+ *
+ * or in the "license" file accompanying this file. This file is distributed on
+ * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied. See the License for the specific language governing
+ * permissions and limitations under the License.
+ */
+
+package io.temporal.samples.autoheartbeat.workflows;
+
+import io.temporal.workflow.SignalMethod;
+import io.temporal.workflow.WorkflowInterface;
+import io.temporal.workflow.WorkflowMethod;
+
+@WorkflowInterface
+public interface AutoWorkflow {
+ @WorkflowMethod
+ String exec(String input);
+
+ @SignalMethod
+ void cancelActivity();
+}
diff --git a/core/src/main/java/io/temporal/samples/autoheartbeat/workflows/AutoWorkflowImpl.java b/core/src/main/java/io/temporal/samples/autoheartbeat/workflows/AutoWorkflowImpl.java
new file mode 100644
index 000000000..6ff8100eb
--- /dev/null
+++ b/core/src/main/java/io/temporal/samples/autoheartbeat/workflows/AutoWorkflowImpl.java
@@ -0,0 +1,88 @@
+/*
+ * Copyright (c) 2020 Temporal Technologies, Inc. All Rights Reserved
+ *
+ * Copyright 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
+ *
+ * Modifications copyright (C) 2017 Uber Technologies, Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"). You may not
+ * use this file except in compliance with the License. A copy of the License is
+ * located at
+ *
+ * http://aws.amazon.com/apache2.0
+ *
+ * or in the "license" file accompanying this file. This file is distributed on
+ * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied. See the License for the specific language governing
+ * permissions and limitations under the License.
+ */
+
+package io.temporal.samples.autoheartbeat.workflows;
+
+import io.temporal.activity.ActivityCancellationType;
+import io.temporal.activity.ActivityOptions;
+import io.temporal.common.RetryOptions;
+import io.temporal.failure.ActivityFailure;
+import io.temporal.failure.CanceledFailure;
+import io.temporal.failure.TimeoutFailure;
+import io.temporal.samples.autoheartbeat.activities.AutoActivities;
+import io.temporal.workflow.CancellationScope;
+import io.temporal.workflow.Workflow;
+import java.time.Duration;
+
+public class AutoWorkflowImpl implements AutoWorkflow {
+ private CancellationScope scope;
+
+ @Override
+ public String exec(String input) {
+ AutoActivities activitiesOne =
+ Workflow.newActivityStub(
+ AutoActivities.class,
+ ActivityOptions.newBuilder()
+ .setStartToCloseTimeout(Duration.ofSeconds(22))
+ .setHeartbeatTimeout(Duration.ofSeconds(8))
+ .setCancellationType(ActivityCancellationType.WAIT_CANCELLATION_COMPLETED)
+ // for sample purposes
+ .setRetryOptions(RetryOptions.newBuilder().setMaximumAttempts(3).build())
+ .build());
+
+ AutoActivities activitiesTwo =
+ Workflow.newActivityStub(
+ AutoActivities.class,
+ ActivityOptions.newBuilder()
+ .setStartToCloseTimeout(Duration.ofSeconds(20))
+ .setHeartbeatTimeout(Duration.ofSeconds(7))
+ .setCancellationType(ActivityCancellationType.WAIT_CANCELLATION_COMPLETED)
+ // for sample purposes
+ .setRetryOptions(RetryOptions.newBuilder().setMaximumAttempts(3).build())
+ .build());
+
+ // Start our activity in CancellationScope so we can cancel it if needed
+ scope =
+ Workflow.newCancellationScope(
+ () -> {
+ activitiesOne.runActivityOne(input);
+ activitiesTwo.runActivityTwo(input);
+ });
+
+ try {
+ scope.run();
+ } catch (ActivityFailure e) {
+ if (e.getCause() instanceof CanceledFailure) {
+ // We dont want workflow to fail in we canceled our scope, just log and return
+ return "Workflow result after activity cancellation";
+ } else if (e.getCause() instanceof TimeoutFailure) {
+ return "Workflow result after activity timeout of type: "
+ + ((TimeoutFailure) e.getCause()).getTimeoutType().name();
+ } else {
+ throw e;
+ }
+ }
+ return "completed";
+ }
+
+ @Override
+ public void cancelActivity() {
+ scope.cancel("Canceling scope from signal handler");
+ }
+}
diff --git a/core/src/main/java/io/temporal/samples/batch/heartbeatingactivity/HeartbeatingActivityBatchStarter.java b/core/src/main/java/io/temporal/samples/batch/heartbeatingactivity/HeartbeatingActivityBatchStarter.java
index 57ec84bb2..90dcb7c10 100644
--- a/core/src/main/java/io/temporal/samples/batch/heartbeatingactivity/HeartbeatingActivityBatchStarter.java
+++ b/core/src/main/java/io/temporal/samples/batch/heartbeatingactivity/HeartbeatingActivityBatchStarter.java
@@ -1,22 +1,3 @@
-/*
- * Copyright (c) 2020 Temporal Technologies, Inc. All Rights Reserved
- *
- * Copyright 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
- * Modifications copyright (C) 2017 Uber Technologies, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"). You may not
- * use this file except in compliance with the License. A copy of the License is
- * located at
- *
- * http://aws.amazon.com/apache2.0
- *
- * or in the "license" file accompanying this file. This file is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
package io.temporal.samples.batch.heartbeatingactivity;
import static io.temporal.samples.batch.heartbeatingactivity.HeartbeatingActivityBatchWorker.TASK_QUEUE;
@@ -24,14 +5,26 @@
import io.temporal.api.common.v1.WorkflowExecution;
import io.temporal.client.WorkflowClient;
import io.temporal.client.WorkflowOptions;
+import io.temporal.envconfig.ClientConfigProfile;
import io.temporal.serviceclient.WorkflowServiceStubs;
+import java.io.IOException;
/** Starts a single execution of HeartbeatingActivityBatchWorkflow. */
public class HeartbeatingActivityBatchStarter {
public static void main(String[] args) {
- WorkflowServiceStubs service = WorkflowServiceStubs.newLocalServiceStubs();
- WorkflowClient workflowClient = WorkflowClient.newInstance(service);
+ // Load configuration from environment and files
+ ClientConfigProfile profile;
+ try {
+ profile = ClientConfigProfile.load();
+ } catch (IOException e) {
+ throw new RuntimeException("Failed to load client configuration", e);
+ }
+
+ WorkflowServiceStubs service =
+ WorkflowServiceStubs.newServiceStubs(profile.toWorkflowServiceStubsOptions());
+ WorkflowClient workflowClient =
+ WorkflowClient.newInstance(service, profile.toWorkflowClientOptions());
WorkflowOptions options = WorkflowOptions.newBuilder().setTaskQueue(TASK_QUEUE).build();
HeartbeatingActivityBatchWorkflow batchWorkflow =
workflowClient.newWorkflowStub(HeartbeatingActivityBatchWorkflow.class, options);
diff --git a/core/src/main/java/io/temporal/samples/batch/heartbeatingactivity/HeartbeatingActivityBatchWorker.java b/core/src/main/java/io/temporal/samples/batch/heartbeatingactivity/HeartbeatingActivityBatchWorker.java
index fad30f414..cd63bacf5 100644
--- a/core/src/main/java/io/temporal/samples/batch/heartbeatingactivity/HeartbeatingActivityBatchWorker.java
+++ b/core/src/main/java/io/temporal/samples/batch/heartbeatingactivity/HeartbeatingActivityBatchWorker.java
@@ -1,28 +1,11 @@
-/*
- * Copyright (c) 2020 Temporal Technologies, Inc. All Rights Reserved
- *
- * Copyright 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
- * Modifications copyright (C) 2017 Uber Technologies, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"). You may not
- * use this file except in compliance with the License. A copy of the License is
- * located at
- *
- * http://aws.amazon.com/apache2.0
- *
- * or in the "license" file accompanying this file. This file is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
package io.temporal.samples.batch.heartbeatingactivity;
import io.temporal.client.WorkflowClient;
+import io.temporal.envconfig.ClientConfigProfile;
import io.temporal.serviceclient.WorkflowServiceStubs;
import io.temporal.worker.Worker;
import io.temporal.worker.WorkerFactory;
+import java.io.IOException;
/**
* A worker process that hosts implementations of HeartbeatingActivityBatchWorkflow and
@@ -33,8 +16,17 @@ public final class HeartbeatingActivityBatchWorker {
static final String TASK_QUEUE = "HeartbeatingActivityBatch";
public static void main(String[] args) {
- WorkflowServiceStubs service = WorkflowServiceStubs.newLocalServiceStubs();
- WorkflowClient client = WorkflowClient.newInstance(service);
+ // Load configuration from environment and files
+ ClientConfigProfile profile;
+ try {
+ profile = ClientConfigProfile.load();
+ } catch (IOException e) {
+ throw new RuntimeException("Failed to load client configuration", e);
+ }
+
+ WorkflowServiceStubs service =
+ WorkflowServiceStubs.newServiceStubs(profile.toWorkflowServiceStubsOptions());
+ WorkflowClient client = WorkflowClient.newInstance(service, profile.toWorkflowClientOptions());
WorkerFactory factory = WorkerFactory.newInstance(client);
Worker worker = factory.newWorker(TASK_QUEUE);
diff --git a/core/src/main/java/io/temporal/samples/batch/heartbeatingactivity/HeartbeatingActivityBatchWorkflow.java b/core/src/main/java/io/temporal/samples/batch/heartbeatingactivity/HeartbeatingActivityBatchWorkflow.java
index 8d9d9f061..b201795d2 100644
--- a/core/src/main/java/io/temporal/samples/batch/heartbeatingactivity/HeartbeatingActivityBatchWorkflow.java
+++ b/core/src/main/java/io/temporal/samples/batch/heartbeatingactivity/HeartbeatingActivityBatchWorkflow.java
@@ -1,22 +1,3 @@
-/*
- * Copyright (c) 2020 Temporal Technologies, Inc. All Rights Reserved
- *
- * Copyright 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
- * Modifications copyright (C) 2017 Uber Technologies, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"). You may not
- * use this file except in compliance with the License. A copy of the License is
- * located at
- *
- * http://aws.amazon.com/apache2.0
- *
- * or in the "license" file accompanying this file. This file is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
package io.temporal.samples.batch.heartbeatingactivity;
import io.temporal.workflow.WorkflowInterface;
diff --git a/core/src/main/java/io/temporal/samples/batch/heartbeatingactivity/HeartbeatingActivityBatchWorkflowImpl.java b/core/src/main/java/io/temporal/samples/batch/heartbeatingactivity/HeartbeatingActivityBatchWorkflowImpl.java
index 946f3fa20..345e97ea4 100644
--- a/core/src/main/java/io/temporal/samples/batch/heartbeatingactivity/HeartbeatingActivityBatchWorkflowImpl.java
+++ b/core/src/main/java/io/temporal/samples/batch/heartbeatingactivity/HeartbeatingActivityBatchWorkflowImpl.java
@@ -1,22 +1,3 @@
-/*
- * Copyright (c) 2020 Temporal Technologies, Inc. All Rights Reserved
- *
- * Copyright 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
- * Modifications copyright (C) 2017 Uber Technologies, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"). You may not
- * use this file except in compliance with the License. A copy of the License is
- * located at
- *
- * http://aws.amazon.com/apache2.0
- *
- * or in the "license" file accompanying this file. This file is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
package io.temporal.samples.batch.heartbeatingactivity;
import io.temporal.activity.ActivityOptions;
diff --git a/core/src/main/java/io/temporal/samples/batch/heartbeatingactivity/RecordLoader.java b/core/src/main/java/io/temporal/samples/batch/heartbeatingactivity/RecordLoader.java
index b5e49918f..706ad7533 100644
--- a/core/src/main/java/io/temporal/samples/batch/heartbeatingactivity/RecordLoader.java
+++ b/core/src/main/java/io/temporal/samples/batch/heartbeatingactivity/RecordLoader.java
@@ -1,22 +1,3 @@
-/*
- * Copyright (c) 2020 Temporal Technologies, Inc. All Rights Reserved
- *
- * Copyright 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
- * Modifications copyright (C) 2017 Uber Technologies, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"). You may not
- * use this file except in compliance with the License. A copy of the License is
- * located at
- *
- * http://aws.amazon.com/apache2.0
- *
- * or in the "license" file accompanying this file. This file is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
package io.temporal.samples.batch.heartbeatingactivity;
import java.util.Optional;
diff --git a/core/src/main/java/io/temporal/samples/batch/heartbeatingactivity/RecordLoaderImpl.java b/core/src/main/java/io/temporal/samples/batch/heartbeatingactivity/RecordLoaderImpl.java
index 818507743..f72c3a719 100644
--- a/core/src/main/java/io/temporal/samples/batch/heartbeatingactivity/RecordLoaderImpl.java
+++ b/core/src/main/java/io/temporal/samples/batch/heartbeatingactivity/RecordLoaderImpl.java
@@ -1,22 +1,3 @@
-/*
- * Copyright (c) 2020 Temporal Technologies, Inc. All Rights Reserved
- *
- * Copyright 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
- * Modifications copyright (C) 2017 Uber Technologies, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"). You may not
- * use this file except in compliance with the License. A copy of the License is
- * located at
- *
- * http://aws.amazon.com/apache2.0
- *
- * or in the "license" file accompanying this file. This file is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
package io.temporal.samples.batch.heartbeatingactivity;
import java.util.Optional;
diff --git a/core/src/main/java/io/temporal/samples/batch/heartbeatingactivity/RecordProcessor.java b/core/src/main/java/io/temporal/samples/batch/heartbeatingactivity/RecordProcessor.java
index 6aa0241da..0c35b8cf9 100644
--- a/core/src/main/java/io/temporal/samples/batch/heartbeatingactivity/RecordProcessor.java
+++ b/core/src/main/java/io/temporal/samples/batch/heartbeatingactivity/RecordProcessor.java
@@ -1,22 +1,3 @@
-/*
- * Copyright (c) 2020 Temporal Technologies, Inc. All Rights Reserved
- *
- * Copyright 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
- * Modifications copyright (C) 2017 Uber Technologies, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"). You may not
- * use this file except in compliance with the License. A copy of the License is
- * located at
- *
- * http://aws.amazon.com/apache2.0
- *
- * or in the "license" file accompanying this file. This file is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
package io.temporal.samples.batch.heartbeatingactivity;
/** A helper class that implements record processing. */
diff --git a/core/src/main/java/io/temporal/samples/batch/heartbeatingactivity/RecordProcessorActivity.java b/core/src/main/java/io/temporal/samples/batch/heartbeatingactivity/RecordProcessorActivity.java
index cc0678f8c..e31cd4758 100644
--- a/core/src/main/java/io/temporal/samples/batch/heartbeatingactivity/RecordProcessorActivity.java
+++ b/core/src/main/java/io/temporal/samples/batch/heartbeatingactivity/RecordProcessorActivity.java
@@ -1,22 +1,3 @@
-/*
- * Copyright (c) 2020 Temporal Technologies, Inc. All Rights Reserved
- *
- * Copyright 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
- * Modifications copyright (C) 2017 Uber Technologies, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"). You may not
- * use this file except in compliance with the License. A copy of the License is
- * located at
- *
- * http://aws.amazon.com/apache2.0
- *
- * or in the "license" file accompanying this file. This file is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
package io.temporal.samples.batch.heartbeatingactivity;
import io.temporal.activity.ActivityInterface;
diff --git a/core/src/main/java/io/temporal/samples/batch/heartbeatingactivity/RecordProcessorActivityImpl.java b/core/src/main/java/io/temporal/samples/batch/heartbeatingactivity/RecordProcessorActivityImpl.java
index 4ec9b1bb6..49e70179e 100644
--- a/core/src/main/java/io/temporal/samples/batch/heartbeatingactivity/RecordProcessorActivityImpl.java
+++ b/core/src/main/java/io/temporal/samples/batch/heartbeatingactivity/RecordProcessorActivityImpl.java
@@ -1,22 +1,3 @@
-/*
- * Copyright (c) 2020 Temporal Technologies, Inc. All Rights Reserved
- *
- * Copyright 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
- * Modifications copyright (C) 2017 Uber Technologies, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"). You may not
- * use this file except in compliance with the License. A copy of the License is
- * located at
- *
- * http://aws.amazon.com/apache2.0
- *
- * or in the "license" file accompanying this file. This file is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
package io.temporal.samples.batch.heartbeatingactivity;
import io.temporal.activity.Activity;
diff --git a/core/src/main/java/io/temporal/samples/batch/heartbeatingactivity/RecordProcessorImpl.java b/core/src/main/java/io/temporal/samples/batch/heartbeatingactivity/RecordProcessorImpl.java
index 5d534fffa..9008fb28a 100644
--- a/core/src/main/java/io/temporal/samples/batch/heartbeatingactivity/RecordProcessorImpl.java
+++ b/core/src/main/java/io/temporal/samples/batch/heartbeatingactivity/RecordProcessorImpl.java
@@ -1,22 +1,3 @@
-/*
- * Copyright (c) 2020 Temporal Technologies, Inc. All Rights Reserved
- *
- * Copyright 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
- * Modifications copyright (C) 2017 Uber Technologies, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"). You may not
- * use this file except in compliance with the License. A copy of the License is
- * located at
- *
- * http://aws.amazon.com/apache2.0
- *
- * or in the "license" file accompanying this file. This file is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
package io.temporal.samples.batch.heartbeatingactivity;
import org.slf4j.Logger;
diff --git a/core/src/main/java/io/temporal/samples/batch/heartbeatingactivity/SingleRecord.java b/core/src/main/java/io/temporal/samples/batch/heartbeatingactivity/SingleRecord.java
index bec3fdd6c..1a1d6abfe 100644
--- a/core/src/main/java/io/temporal/samples/batch/heartbeatingactivity/SingleRecord.java
+++ b/core/src/main/java/io/temporal/samples/batch/heartbeatingactivity/SingleRecord.java
@@ -1,22 +1,3 @@
-/*
- * Copyright (c) 2020 Temporal Technologies, Inc. All Rights Reserved
- *
- * Copyright 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
- * Modifications copyright (C) 2017 Uber Technologies, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"). You may not
- * use this file except in compliance with the License. A copy of the License is
- * located at
- *
- * http://aws.amazon.com/apache2.0
- *
- * or in the "license" file accompanying this file. This file is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
package io.temporal.samples.batch.heartbeatingactivity;
/** Record to process. A real application would add a use case specific data. */
diff --git a/core/src/main/java/io/temporal/samples/batch/iterator/IteratorBatchStarter.java b/core/src/main/java/io/temporal/samples/batch/iterator/IteratorBatchStarter.java
index 8e9530c36..fa43c467f 100644
--- a/core/src/main/java/io/temporal/samples/batch/iterator/IteratorBatchStarter.java
+++ b/core/src/main/java/io/temporal/samples/batch/iterator/IteratorBatchStarter.java
@@ -1,22 +1,3 @@
-/*
- * Copyright (c) 2020 Temporal Technologies, Inc. All Rights Reserved
- *
- * Copyright 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
- * Modifications copyright (C) 2017 Uber Technologies, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"). You may not
- * use this file except in compliance with the License. A copy of the License is
- * located at
- *
- * http://aws.amazon.com/apache2.0
- *
- * or in the "license" file accompanying this file. This file is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
package io.temporal.samples.batch.iterator;
import static io.temporal.samples.batch.iterator.IteratorBatchWorker.TASK_QUEUE;
@@ -24,14 +5,26 @@
import io.temporal.api.common.v1.WorkflowExecution;
import io.temporal.client.WorkflowClient;
import io.temporal.client.WorkflowOptions;
+import io.temporal.envconfig.ClientConfigProfile;
import io.temporal.serviceclient.WorkflowServiceStubs;
+import java.io.IOException;
/** Starts a single execution of IteratorBatchWorkflow. */
public class IteratorBatchStarter {
public static void main(String[] args) {
- WorkflowServiceStubs service = WorkflowServiceStubs.newLocalServiceStubs();
- WorkflowClient workflowClient = WorkflowClient.newInstance(service);
+ // Load configuration from environment and files
+ ClientConfigProfile profile;
+ try {
+ profile = ClientConfigProfile.load();
+ } catch (IOException e) {
+ throw new RuntimeException("Failed to load client configuration", e);
+ }
+
+ WorkflowServiceStubs service =
+ WorkflowServiceStubs.newServiceStubs(profile.toWorkflowServiceStubsOptions());
+ WorkflowClient workflowClient =
+ WorkflowClient.newInstance(service, profile.toWorkflowClientOptions());
WorkflowOptions options = WorkflowOptions.newBuilder().setTaskQueue(TASK_QUEUE).build();
IteratorBatchWorkflow batchWorkflow =
workflowClient.newWorkflowStub(IteratorBatchWorkflow.class, options);
diff --git a/core/src/main/java/io/temporal/samples/batch/iterator/IteratorBatchWorker.java b/core/src/main/java/io/temporal/samples/batch/iterator/IteratorBatchWorker.java
index ecb9edf38..adc023d7b 100644
--- a/core/src/main/java/io/temporal/samples/batch/iterator/IteratorBatchWorker.java
+++ b/core/src/main/java/io/temporal/samples/batch/iterator/IteratorBatchWorker.java
@@ -1,28 +1,11 @@
-/*
- * Copyright (c) 2020 Temporal Technologies, Inc. All Rights Reserved
- *
- * Copyright 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
- * Modifications copyright (C) 2017 Uber Technologies, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"). You may not
- * use this file except in compliance with the License. A copy of the License is
- * located at
- *
- * http://aws.amazon.com/apache2.0
- *
- * or in the "license" file accompanying this file. This file is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
package io.temporal.samples.batch.iterator;
import io.temporal.client.WorkflowClient;
+import io.temporal.envconfig.ClientConfigProfile;
import io.temporal.serviceclient.WorkflowServiceStubs;
import io.temporal.worker.Worker;
import io.temporal.worker.WorkerFactory;
+import java.io.IOException;
/**
* A worker process that hosts implementations of IteratorBatchWorkflow and RecordProcessorWorkflow
@@ -33,8 +16,17 @@ public final class IteratorBatchWorker {
static final String TASK_QUEUE = "IteratorBatch";
public static void main(String[] args) {
- WorkflowServiceStubs service = WorkflowServiceStubs.newLocalServiceStubs();
- WorkflowClient client = WorkflowClient.newInstance(service);
+ // Load configuration from environment and files
+ ClientConfigProfile profile;
+ try {
+ profile = ClientConfigProfile.load();
+ } catch (IOException e) {
+ throw new RuntimeException("Failed to load client configuration", e);
+ }
+
+ WorkflowServiceStubs service =
+ WorkflowServiceStubs.newServiceStubs(profile.toWorkflowServiceStubsOptions());
+ WorkflowClient client = WorkflowClient.newInstance(service, profile.toWorkflowClientOptions());
WorkerFactory factory = WorkerFactory.newInstance(client);
Worker worker = factory.newWorker(TASK_QUEUE);
diff --git a/core/src/main/java/io/temporal/samples/batch/iterator/IteratorBatchWorkflow.java b/core/src/main/java/io/temporal/samples/batch/iterator/IteratorBatchWorkflow.java
index c5d55de3a..991cdd257 100644
--- a/core/src/main/java/io/temporal/samples/batch/iterator/IteratorBatchWorkflow.java
+++ b/core/src/main/java/io/temporal/samples/batch/iterator/IteratorBatchWorkflow.java
@@ -1,22 +1,3 @@
-/*
- * Copyright (c) 2020 Temporal Technologies, Inc. All Rights Reserved
- *
- * Copyright 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
- * Modifications copyright (C) 2017 Uber Technologies, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"). You may not
- * use this file except in compliance with the License. A copy of the License is
- * located at
- *
- * http://aws.amazon.com/apache2.0
- *
- * or in the "license" file accompanying this file. This file is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
package io.temporal.samples.batch.iterator;
import io.temporal.workflow.WorkflowInterface;
diff --git a/core/src/main/java/io/temporal/samples/batch/iterator/IteratorBatchWorkflowImpl.java b/core/src/main/java/io/temporal/samples/batch/iterator/IteratorBatchWorkflowImpl.java
index 44a56a5a8..fa294ec70 100644
--- a/core/src/main/java/io/temporal/samples/batch/iterator/IteratorBatchWorkflowImpl.java
+++ b/core/src/main/java/io/temporal/samples/batch/iterator/IteratorBatchWorkflowImpl.java
@@ -1,22 +1,3 @@
-/*
- * Copyright (c) 2020 Temporal Technologies, Inc. All Rights Reserved
- *
- * Copyright 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
- * Modifications copyright (C) 2017 Uber Technologies, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"). You may not
- * use this file except in compliance with the License. A copy of the License is
- * located at
- *
- * http://aws.amazon.com/apache2.0
- *
- * or in the "license" file accompanying this file. This file is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
package io.temporal.samples.batch.iterator;
import io.temporal.activity.ActivityOptions;
diff --git a/core/src/main/java/io/temporal/samples/batch/iterator/RecordLoader.java b/core/src/main/java/io/temporal/samples/batch/iterator/RecordLoader.java
index 9f1974993..dc8ee0737 100644
--- a/core/src/main/java/io/temporal/samples/batch/iterator/RecordLoader.java
+++ b/core/src/main/java/io/temporal/samples/batch/iterator/RecordLoader.java
@@ -1,22 +1,3 @@
-/*
- * Copyright (c) 2020 Temporal Technologies, Inc. All Rights Reserved
- *
- * Copyright 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
- * Modifications copyright (C) 2017 Uber Technologies, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"). You may not
- * use this file except in compliance with the License. A copy of the License is
- * located at
- *
- * http://aws.amazon.com/apache2.0
- *
- * or in the "license" file accompanying this file. This file is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
package io.temporal.samples.batch.iterator;
import io.temporal.activity.ActivityInterface;
diff --git a/core/src/main/java/io/temporal/samples/batch/iterator/RecordLoaderImpl.java b/core/src/main/java/io/temporal/samples/batch/iterator/RecordLoaderImpl.java
index 72fbd0189..b7102ce24 100644
--- a/core/src/main/java/io/temporal/samples/batch/iterator/RecordLoaderImpl.java
+++ b/core/src/main/java/io/temporal/samples/batch/iterator/RecordLoaderImpl.java
@@ -1,22 +1,3 @@
-/*
- * Copyright (c) 2020 Temporal Technologies, Inc. All Rights Reserved
- *
- * Copyright 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
- * Modifications copyright (C) 2017 Uber Technologies, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"). You may not
- * use this file except in compliance with the License. A copy of the License is
- * located at
- *
- * http://aws.amazon.com/apache2.0
- *
- * or in the "license" file accompanying this file. This file is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
package io.temporal.samples.batch.iterator;
import java.util.ArrayList;
diff --git a/core/src/main/java/io/temporal/samples/batch/iterator/RecordProcessorWorkflow.java b/core/src/main/java/io/temporal/samples/batch/iterator/RecordProcessorWorkflow.java
index 703716a55..498da8567 100644
--- a/core/src/main/java/io/temporal/samples/batch/iterator/RecordProcessorWorkflow.java
+++ b/core/src/main/java/io/temporal/samples/batch/iterator/RecordProcessorWorkflow.java
@@ -1,22 +1,3 @@
-/*
- * Copyright (c) 2020 Temporal Technologies, Inc. All Rights Reserved
- *
- * Copyright 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
- * Modifications copyright (C) 2017 Uber Technologies, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"). You may not
- * use this file except in compliance with the License. A copy of the License is
- * located at
- *
- * http://aws.amazon.com/apache2.0
- *
- * or in the "license" file accompanying this file. This file is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
package io.temporal.samples.batch.iterator;
import io.temporal.workflow.WorkflowInterface;
diff --git a/core/src/main/java/io/temporal/samples/batch/iterator/RecordProcessorWorkflowImpl.java b/core/src/main/java/io/temporal/samples/batch/iterator/RecordProcessorWorkflowImpl.java
index 12535f7aa..78e7eeb88 100644
--- a/core/src/main/java/io/temporal/samples/batch/iterator/RecordProcessorWorkflowImpl.java
+++ b/core/src/main/java/io/temporal/samples/batch/iterator/RecordProcessorWorkflowImpl.java
@@ -1,22 +1,3 @@
-/*
- * Copyright (c) 2020 Temporal Technologies, Inc. All Rights Reserved
- *
- * Copyright 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
- * Modifications copyright (C) 2017 Uber Technologies, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"). You may not
- * use this file except in compliance with the License. A copy of the License is
- * located at
- *
- * http://aws.amazon.com/apache2.0
- *
- * or in the "license" file accompanying this file. This file is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
package io.temporal.samples.batch.iterator;
import io.temporal.workflow.Workflow;
diff --git a/core/src/main/java/io/temporal/samples/batch/iterator/SingleRecord.java b/core/src/main/java/io/temporal/samples/batch/iterator/SingleRecord.java
index ea40ee807..8379a0dd2 100644
--- a/core/src/main/java/io/temporal/samples/batch/iterator/SingleRecord.java
+++ b/core/src/main/java/io/temporal/samples/batch/iterator/SingleRecord.java
@@ -1,22 +1,3 @@
-/*
- * Copyright (c) 2020 Temporal Technologies, Inc. All Rights Reserved
- *
- * Copyright 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
- * Modifications copyright (C) 2017 Uber Technologies, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"). You may not
- * use this file except in compliance with the License. A copy of the License is
- * located at
- *
- * http://aws.amazon.com/apache2.0
- *
- * or in the "license" file accompanying this file. This file is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
package io.temporal.samples.batch.iterator;
/** Record to process. A real application would add a use case specific data. */
diff --git a/core/src/main/java/io/temporal/samples/batch/slidingwindow/BatchProgress.java b/core/src/main/java/io/temporal/samples/batch/slidingwindow/BatchProgress.java
index a09b56479..4924e47a0 100644
--- a/core/src/main/java/io/temporal/samples/batch/slidingwindow/BatchProgress.java
+++ b/core/src/main/java/io/temporal/samples/batch/slidingwindow/BatchProgress.java
@@ -1,22 +1,3 @@
-/*
- * Copyright (c) 2020 Temporal Technologies, Inc. All Rights Reserved
- *
- * Copyright 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
- * Modifications copyright (C) 2017 Uber Technologies, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"). You may not
- * use this file except in compliance with the License. A copy of the License is
- * located at
- *
- * http://aws.amazon.com/apache2.0
- *
- * or in the "license" file accompanying this file. This file is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
package io.temporal.samples.batch.slidingwindow;
import java.util.Set;
diff --git a/core/src/main/java/io/temporal/samples/batch/slidingwindow/BatchWorkflow.java b/core/src/main/java/io/temporal/samples/batch/slidingwindow/BatchWorkflow.java
index 40eb14c7b..fad65b362 100644
--- a/core/src/main/java/io/temporal/samples/batch/slidingwindow/BatchWorkflow.java
+++ b/core/src/main/java/io/temporal/samples/batch/slidingwindow/BatchWorkflow.java
@@ -1,22 +1,3 @@
-/*
- * Copyright (c) 2020 Temporal Technologies, Inc. All Rights Reserved
- *
- * Copyright 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
- * Modifications copyright (C) 2017 Uber Technologies, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"). You may not
- * use this file except in compliance with the License. A copy of the License is
- * located at
- *
- * http://aws.amazon.com/apache2.0
- *
- * or in the "license" file accompanying this file. This file is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
package io.temporal.samples.batch.slidingwindow;
import io.temporal.workflow.WorkflowInterface;
diff --git a/core/src/main/java/io/temporal/samples/batch/slidingwindow/BatchWorkflowImpl.java b/core/src/main/java/io/temporal/samples/batch/slidingwindow/BatchWorkflowImpl.java
index 2e96dc8ba..6838ce922 100644
--- a/core/src/main/java/io/temporal/samples/batch/slidingwindow/BatchWorkflowImpl.java
+++ b/core/src/main/java/io/temporal/samples/batch/slidingwindow/BatchWorkflowImpl.java
@@ -1,22 +1,3 @@
-/*
- * Copyright (c) 2020 Temporal Technologies, Inc. All Rights Reserved
- *
- * Copyright 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
- * Modifications copyright (C) 2017 Uber Technologies, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"). You may not
- * use this file except in compliance with the License. A copy of the License is
- * located at
- *
- * http://aws.amazon.com/apache2.0
- *
- * or in the "license" file accompanying this file. This file is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
package io.temporal.samples.batch.slidingwindow;
import io.temporal.activity.ActivityOptions;
diff --git a/core/src/main/java/io/temporal/samples/batch/slidingwindow/ProcessBatchInput.java b/core/src/main/java/io/temporal/samples/batch/slidingwindow/ProcessBatchInput.java
index 4f4013e56..98d720ed2 100644
--- a/core/src/main/java/io/temporal/samples/batch/slidingwindow/ProcessBatchInput.java
+++ b/core/src/main/java/io/temporal/samples/batch/slidingwindow/ProcessBatchInput.java
@@ -1,22 +1,3 @@
-/*
- * Copyright (c) 2020 Temporal Technologies, Inc. All Rights Reserved
- *
- * Copyright 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
- * Modifications copyright (C) 2017 Uber Technologies, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"). You may not
- * use this file except in compliance with the License. A copy of the License is
- * located at
- *
- * http://aws.amazon.com/apache2.0
- *
- * or in the "license" file accompanying this file. This file is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
package io.temporal.samples.batch.slidingwindow;
import java.util.HashSet;
diff --git a/core/src/main/java/io/temporal/samples/batch/slidingwindow/RecordIterable.java b/core/src/main/java/io/temporal/samples/batch/slidingwindow/RecordIterable.java
index b9eece15d..276629534 100644
--- a/core/src/main/java/io/temporal/samples/batch/slidingwindow/RecordIterable.java
+++ b/core/src/main/java/io/temporal/samples/batch/slidingwindow/RecordIterable.java
@@ -1,22 +1,3 @@
-/*
- * Copyright (c) 2020 Temporal Technologies, Inc. All Rights Reserved
- *
- * Copyright 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
- * Modifications copyright (C) 2017 Uber Technologies, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"). You may not
- * use this file except in compliance with the License. A copy of the License is
- * located at
- *
- * http://aws.amazon.com/apache2.0
- *
- * or in the "license" file accompanying this file. This file is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
package io.temporal.samples.batch.slidingwindow;
import io.temporal.activity.ActivityOptions;
diff --git a/core/src/main/java/io/temporal/samples/batch/slidingwindow/RecordLoader.java b/core/src/main/java/io/temporal/samples/batch/slidingwindow/RecordLoader.java
index f0dbf70bc..c8257a570 100644
--- a/core/src/main/java/io/temporal/samples/batch/slidingwindow/RecordLoader.java
+++ b/core/src/main/java/io/temporal/samples/batch/slidingwindow/RecordLoader.java
@@ -1,22 +1,3 @@
-/*
- * Copyright (c) 2020 Temporal Technologies, Inc. All Rights Reserved
- *
- * Copyright 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
- * Modifications copyright (C) 2017 Uber Technologies, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"). You may not
- * use this file except in compliance with the License. A copy of the License is
- * located at
- *
- * http://aws.amazon.com/apache2.0
- *
- * or in the "license" file accompanying this file. This file is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
package io.temporal.samples.batch.slidingwindow;
import io.temporal.activity.ActivityInterface;
diff --git a/core/src/main/java/io/temporal/samples/batch/slidingwindow/RecordLoaderImpl.java b/core/src/main/java/io/temporal/samples/batch/slidingwindow/RecordLoaderImpl.java
index b97379574..169987ded 100644
--- a/core/src/main/java/io/temporal/samples/batch/slidingwindow/RecordLoaderImpl.java
+++ b/core/src/main/java/io/temporal/samples/batch/slidingwindow/RecordLoaderImpl.java
@@ -1,22 +1,3 @@
-/*
- * Copyright (c) 2020 Temporal Technologies, Inc. All Rights Reserved
- *
- * Copyright 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
- * Modifications copyright (C) 2017 Uber Technologies, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"). You may not
- * use this file except in compliance with the License. A copy of the License is
- * located at
- *
- * http://aws.amazon.com/apache2.0
- *
- * or in the "license" file accompanying this file. This file is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
package io.temporal.samples.batch.slidingwindow;
import java.util.ArrayList;
diff --git a/core/src/main/java/io/temporal/samples/batch/slidingwindow/RecordProcessorWorkflow.java b/core/src/main/java/io/temporal/samples/batch/slidingwindow/RecordProcessorWorkflow.java
index e4647aa68..35945052f 100644
--- a/core/src/main/java/io/temporal/samples/batch/slidingwindow/RecordProcessorWorkflow.java
+++ b/core/src/main/java/io/temporal/samples/batch/slidingwindow/RecordProcessorWorkflow.java
@@ -1,22 +1,3 @@
-/*
- * Copyright (c) 2020 Temporal Technologies, Inc. All Rights Reserved
- *
- * Copyright 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
- * Modifications copyright (C) 2017 Uber Technologies, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"). You may not
- * use this file except in compliance with the License. A copy of the License is
- * located at
- *
- * http://aws.amazon.com/apache2.0
- *
- * or in the "license" file accompanying this file. This file is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
package io.temporal.samples.batch.slidingwindow;
import io.temporal.workflow.WorkflowInterface;
diff --git a/core/src/main/java/io/temporal/samples/batch/slidingwindow/RecordProcessorWorkflowImpl.java b/core/src/main/java/io/temporal/samples/batch/slidingwindow/RecordProcessorWorkflowImpl.java
index 94d294874..9bd767111 100644
--- a/core/src/main/java/io/temporal/samples/batch/slidingwindow/RecordProcessorWorkflowImpl.java
+++ b/core/src/main/java/io/temporal/samples/batch/slidingwindow/RecordProcessorWorkflowImpl.java
@@ -1,22 +1,3 @@
-/*
- * Copyright (c) 2020 Temporal Technologies, Inc. All Rights Reserved
- *
- * Copyright 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
- * Modifications copyright (C) 2017 Uber Technologies, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"). You may not
- * use this file except in compliance with the License. A copy of the License is
- * located at
- *
- * http://aws.amazon.com/apache2.0
- *
- * or in the "license" file accompanying this file. This file is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
package io.temporal.samples.batch.slidingwindow;
import io.temporal.workflow.Workflow;
diff --git a/core/src/main/java/io/temporal/samples/batch/slidingwindow/SingleRecord.java b/core/src/main/java/io/temporal/samples/batch/slidingwindow/SingleRecord.java
index ab2f29636..9205051f3 100644
--- a/core/src/main/java/io/temporal/samples/batch/slidingwindow/SingleRecord.java
+++ b/core/src/main/java/io/temporal/samples/batch/slidingwindow/SingleRecord.java
@@ -1,22 +1,3 @@
-/*
- * Copyright (c) 2020 Temporal Technologies, Inc. All Rights Reserved
- *
- * Copyright 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
- * Modifications copyright (C) 2017 Uber Technologies, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"). You may not
- * use this file except in compliance with the License. A copy of the License is
- * located at
- *
- * http://aws.amazon.com/apache2.0
- *
- * or in the "license" file accompanying this file. This file is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
package io.temporal.samples.batch.slidingwindow;
/** Record to process. */
diff --git a/core/src/main/java/io/temporal/samples/batch/slidingwindow/SlidingWindowBatchStarter.java b/core/src/main/java/io/temporal/samples/batch/slidingwindow/SlidingWindowBatchStarter.java
index 8c3329c37..e3a6b062d 100644
--- a/core/src/main/java/io/temporal/samples/batch/slidingwindow/SlidingWindowBatchStarter.java
+++ b/core/src/main/java/io/temporal/samples/batch/slidingwindow/SlidingWindowBatchStarter.java
@@ -1,36 +1,29 @@
-/*
- * Copyright (c) 2020 Temporal Technologies, Inc. All Rights Reserved
- *
- * Copyright 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
- * Modifications copyright (C) 2017 Uber Technologies, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"). You may not
- * use this file except in compliance with the License. A copy of the License is
- * located at
- *
- * http://aws.amazon.com/apache2.0
- *
- * or in the "license" file accompanying this file. This file is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
package io.temporal.samples.batch.slidingwindow;
import static io.temporal.samples.batch.slidingwindow.SlidingWindowBatchWorker.TASK_QUEUE;
import io.temporal.client.WorkflowClient;
import io.temporal.client.WorkflowOptions;
+import io.temporal.envconfig.ClientConfigProfile;
import io.temporal.serviceclient.WorkflowServiceStubs;
+import java.io.IOException;
public class SlidingWindowBatchStarter {
@SuppressWarnings("CatchAndPrintStackTrace")
public static void main(String[] args) {
- WorkflowServiceStubs service = WorkflowServiceStubs.newLocalServiceStubs();
- WorkflowClient workflowClient = WorkflowClient.newInstance(service);
+ // Load configuration from environment and files
+ ClientConfigProfile profile;
+ try {
+ profile = ClientConfigProfile.load();
+ } catch (IOException e) {
+ throw new RuntimeException("Failed to load client configuration", e);
+ }
+
+ WorkflowServiceStubs service =
+ WorkflowServiceStubs.newServiceStubs(profile.toWorkflowServiceStubsOptions());
+ WorkflowClient workflowClient =
+ WorkflowClient.newInstance(service, profile.toWorkflowClientOptions());
WorkflowOptions options = WorkflowOptions.newBuilder().setTaskQueue(TASK_QUEUE).build();
BatchWorkflow batchWorkflow = workflowClient.newWorkflowStub(BatchWorkflow.class, options);
WorkflowClient.start(batchWorkflow::processBatch, 10, 25, 3);
diff --git a/core/src/main/java/io/temporal/samples/batch/slidingwindow/SlidingWindowBatchWorker.java b/core/src/main/java/io/temporal/samples/batch/slidingwindow/SlidingWindowBatchWorker.java
index 2b1b6c1c4..20caa5ead 100644
--- a/core/src/main/java/io/temporal/samples/batch/slidingwindow/SlidingWindowBatchWorker.java
+++ b/core/src/main/java/io/temporal/samples/batch/slidingwindow/SlidingWindowBatchWorker.java
@@ -1,28 +1,11 @@
-/*
- * Copyright (c) 2020 Temporal Technologies, Inc. All Rights Reserved
- *
- * Copyright 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
- * Modifications copyright (C) 2017 Uber Technologies, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"). You may not
- * use this file except in compliance with the License. A copy of the License is
- * located at
- *
- * http://aws.amazon.com/apache2.0
- *
- * or in the "license" file accompanying this file. This file is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
package io.temporal.samples.batch.slidingwindow;
import io.temporal.client.WorkflowClient;
+import io.temporal.envconfig.ClientConfigProfile;
import io.temporal.serviceclient.WorkflowServiceStubs;
import io.temporal.worker.Worker;
import io.temporal.worker.WorkerFactory;
+import java.io.IOException;
/** Hosts sliding window batch sample workflow and activity implementations. */
public final class SlidingWindowBatchWorker {
@@ -30,8 +13,17 @@ public final class SlidingWindowBatchWorker {
static final String TASK_QUEUE = "SlidingWindow";
public static void main(String[] args) {
- WorkflowServiceStubs service = WorkflowServiceStubs.newLocalServiceStubs();
- WorkflowClient client = WorkflowClient.newInstance(service);
+ // Load configuration from environment and files
+ ClientConfigProfile profile;
+ try {
+ profile = ClientConfigProfile.load();
+ } catch (IOException e) {
+ throw new RuntimeException("Failed to load client configuration", e);
+ }
+
+ WorkflowServiceStubs service =
+ WorkflowServiceStubs.newServiceStubs(profile.toWorkflowServiceStubsOptions());
+ WorkflowClient client = WorkflowClient.newInstance(service, profile.toWorkflowClientOptions());
WorkerFactory factory = WorkerFactory.newInstance(client);
Worker worker = factory.newWorker(TASK_QUEUE);
diff --git a/core/src/main/java/io/temporal/samples/batch/slidingwindow/SlidingWindowBatchWorkflow.java b/core/src/main/java/io/temporal/samples/batch/slidingwindow/SlidingWindowBatchWorkflow.java
index 3a49126d6..5b1ac9723 100644
--- a/core/src/main/java/io/temporal/samples/batch/slidingwindow/SlidingWindowBatchWorkflow.java
+++ b/core/src/main/java/io/temporal/samples/batch/slidingwindow/SlidingWindowBatchWorkflow.java
@@ -1,22 +1,3 @@
-/*
- * Copyright (c) 2020 Temporal Technologies, Inc. All Rights Reserved
- *
- * Copyright 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
- * Modifications copyright (C) 2017 Uber Technologies, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"). You may not
- * use this file except in compliance with the License. A copy of the License is
- * located at
- *
- * http://aws.amazon.com/apache2.0
- *
- * or in the "license" file accompanying this file. This file is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
package io.temporal.samples.batch.slidingwindow;
import io.temporal.workflow.QueryMethod;
diff --git a/core/src/main/java/io/temporal/samples/batch/slidingwindow/SlidingWindowBatchWorkflowImpl.java b/core/src/main/java/io/temporal/samples/batch/slidingwindow/SlidingWindowBatchWorkflowImpl.java
index 91b6d9955..33bb42418 100644
--- a/core/src/main/java/io/temporal/samples/batch/slidingwindow/SlidingWindowBatchWorkflowImpl.java
+++ b/core/src/main/java/io/temporal/samples/batch/slidingwindow/SlidingWindowBatchWorkflowImpl.java
@@ -1,22 +1,3 @@
-/*
- * Copyright (c) 2020 Temporal Technologies, Inc. All Rights Reserved
- *
- * Copyright 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
- * Modifications copyright (C) 2017 Uber Technologies, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"). You may not
- * use this file except in compliance with the License. A copy of the License is
- * located at
- *
- * http://aws.amazon.com/apache2.0
- *
- * or in the "license" file accompanying this file. This file is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
package io.temporal.samples.batch.slidingwindow;
import io.temporal.api.common.v1.WorkflowExecution;
diff --git a/core/src/main/java/io/temporal/samples/bookingsaga/Booking.java b/core/src/main/java/io/temporal/samples/bookingsaga/Booking.java
index 3b9eb73ff..7e4594a7d 100644
--- a/core/src/main/java/io/temporal/samples/bookingsaga/Booking.java
+++ b/core/src/main/java/io/temporal/samples/bookingsaga/Booking.java
@@ -1,22 +1,3 @@
-/*
- * Copyright (c) 2020 Temporal Technologies, Inc. All Rights Reserved
- *
- * Copyright 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
- * Modifications copyright (C) 2017 Uber Technologies, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"). You may not
- * use this file except in compliance with the License. A copy of the License is
- * located at
- *
- * http://aws.amazon.com/apache2.0
- *
- * or in the "license" file accompanying this file. This file is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
package io.temporal.samples.bookingsaga;
public final class Booking {
diff --git a/core/src/main/java/io/temporal/samples/bookingsaga/TripBookingActivities.java b/core/src/main/java/io/temporal/samples/bookingsaga/TripBookingActivities.java
index b8e8db77f..31df78291 100644
--- a/core/src/main/java/io/temporal/samples/bookingsaga/TripBookingActivities.java
+++ b/core/src/main/java/io/temporal/samples/bookingsaga/TripBookingActivities.java
@@ -1,22 +1,3 @@
-/*
- * Copyright (c) 2020 Temporal Technologies, Inc. All Rights Reserved
- *
- * Copyright 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
- * Modifications copyright (C) 2017 Uber Technologies, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"). You may not
- * use this file except in compliance with the License. A copy of the License is
- * located at
- *
- * http://aws.amazon.com/apache2.0
- *
- * or in the "license" file accompanying this file. This file is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
package io.temporal.samples.bookingsaga;
import io.temporal.activity.ActivityInterface;
diff --git a/core/src/main/java/io/temporal/samples/bookingsaga/TripBookingActivitiesImpl.java b/core/src/main/java/io/temporal/samples/bookingsaga/TripBookingActivitiesImpl.java
index 5fbfd91bd..76115d15f 100644
--- a/core/src/main/java/io/temporal/samples/bookingsaga/TripBookingActivitiesImpl.java
+++ b/core/src/main/java/io/temporal/samples/bookingsaga/TripBookingActivitiesImpl.java
@@ -1,22 +1,3 @@
-/*
- * Copyright (c) 2020 Temporal Technologies, Inc. All Rights Reserved
- *
- * Copyright 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
- * Modifications copyright (C) 2017 Uber Technologies, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"). You may not
- * use this file except in compliance with the License. A copy of the License is
- * located at
- *
- * http://aws.amazon.com/apache2.0
- *
- * or in the "license" file accompanying this file. This file is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
package io.temporal.samples.bookingsaga;
import io.temporal.failure.ApplicationFailure;
diff --git a/core/src/main/java/io/temporal/samples/bookingsaga/TripBookingClient.java b/core/src/main/java/io/temporal/samples/bookingsaga/TripBookingClient.java
index 075eaa718..cb7d1e594 100644
--- a/core/src/main/java/io/temporal/samples/bookingsaga/TripBookingClient.java
+++ b/core/src/main/java/io/temporal/samples/bookingsaga/TripBookingClient.java
@@ -1,38 +1,30 @@
-/*
- * Copyright (c) 2020 Temporal Technologies, Inc. All Rights Reserved
- *
- * Copyright 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
- * Modifications copyright (C) 2017 Uber Technologies, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"). You may not
- * use this file except in compliance with the License. A copy of the License is
- * located at
- *
- * http://aws.amazon.com/apache2.0
- *
- * or in the "license" file accompanying this file. This file is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
package io.temporal.samples.bookingsaga;
import com.google.common.base.Throwables;
import io.temporal.client.WorkflowClient;
import io.temporal.client.WorkflowOptions;
+import io.temporal.envconfig.ClientConfigProfile;
import io.temporal.serviceclient.WorkflowServiceStubs;
+import java.io.IOException;
public class TripBookingClient {
static final String TASK_QUEUE = "TripBooking";
public static void main(String[] args) {
- // gRPC stubs wrapper that talks to the local docker instance of temporal service.
- WorkflowServiceStubs service = WorkflowServiceStubs.newLocalServiceStubs();
+ // Load configuration from environment and files
+ ClientConfigProfile profile;
+ try {
+ profile = ClientConfigProfile.load();
+ } catch (IOException e) {
+ throw new RuntimeException("Failed to load client configuration", e);
+ }
+
+ // gRPC stubs wrapper that talks to the temporal service.
+ WorkflowServiceStubs service =
+ WorkflowServiceStubs.newServiceStubs(profile.toWorkflowServiceStubsOptions());
// client that can be used to start and signal workflows
- WorkflowClient client = WorkflowClient.newInstance(service);
+ WorkflowClient client = WorkflowClient.newInstance(service, profile.toWorkflowClientOptions());
WorkflowOptions options =
WorkflowOptions.newBuilder().setTaskQueue(TASK_QUEUE).setWorkflowId("Booking1").build();
diff --git a/core/src/main/java/io/temporal/samples/bookingsaga/TripBookingWorker.java b/core/src/main/java/io/temporal/samples/bookingsaga/TripBookingWorker.java
index abfe004a9..6c0fb87b2 100644
--- a/core/src/main/java/io/temporal/samples/bookingsaga/TripBookingWorker.java
+++ b/core/src/main/java/io/temporal/samples/bookingsaga/TripBookingWorker.java
@@ -1,37 +1,29 @@
-/*
- * Copyright (c) 2020 Temporal Technologies, Inc. All Rights Reserved
- *
- * Copyright 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
- * Modifications copyright (C) 2017 Uber Technologies, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"). You may not
- * use this file except in compliance with the License. A copy of the License is
- * located at
- *
- * http://aws.amazon.com/apache2.0
- *
- * or in the "license" file accompanying this file. This file is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
package io.temporal.samples.bookingsaga;
import io.temporal.client.WorkflowClient;
+import io.temporal.envconfig.ClientConfigProfile;
import io.temporal.serviceclient.WorkflowServiceStubs;
import io.temporal.worker.Worker;
import io.temporal.worker.WorkerFactory;
+import java.io.IOException;
public class TripBookingWorker {
@SuppressWarnings("CatchAndPrintStackTrace")
public static void main(String[] args) {
- // gRPC stubs wrapper that talks to the local docker instance of temporal service.
- WorkflowServiceStubs service = WorkflowServiceStubs.newLocalServiceStubs();
+ // Load configuration from environment and files
+ ClientConfigProfile profile;
+ try {
+ profile = ClientConfigProfile.load();
+ } catch (IOException e) {
+ throw new RuntimeException("Failed to load client configuration", e);
+ }
+
+ // gRPC stubs wrapper that talks to the temporal service.
+ WorkflowServiceStubs service =
+ WorkflowServiceStubs.newServiceStubs(profile.toWorkflowServiceStubsOptions());
// client that can be used to start and signal workflows
- WorkflowClient client = WorkflowClient.newInstance(service);
+ WorkflowClient client = WorkflowClient.newInstance(service, profile.toWorkflowClientOptions());
// worker factory that can be used to create workers for specific task queues
WorkerFactory factory = WorkerFactory.newInstance(client);
diff --git a/core/src/main/java/io/temporal/samples/bookingsaga/TripBookingWorkflow.java b/core/src/main/java/io/temporal/samples/bookingsaga/TripBookingWorkflow.java
index e9ec8f10e..dccffee77 100644
--- a/core/src/main/java/io/temporal/samples/bookingsaga/TripBookingWorkflow.java
+++ b/core/src/main/java/io/temporal/samples/bookingsaga/TripBookingWorkflow.java
@@ -1,22 +1,3 @@
-/*
- * Copyright (c) 2020 Temporal Technologies, Inc. All Rights Reserved
- *
- * Copyright 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
- * Modifications copyright (C) 2017 Uber Technologies, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"). You may not
- * use this file except in compliance with the License. A copy of the License is
- * located at
- *
- * http://aws.amazon.com/apache2.0
- *
- * or in the "license" file accompanying this file. This file is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
package io.temporal.samples.bookingsaga;
import io.temporal.workflow.WorkflowInterface;
diff --git a/core/src/main/java/io/temporal/samples/bookingsaga/TripBookingWorkflowImpl.java b/core/src/main/java/io/temporal/samples/bookingsaga/TripBookingWorkflowImpl.java
index b4558ed4a..1e13d6d75 100644
--- a/core/src/main/java/io/temporal/samples/bookingsaga/TripBookingWorkflowImpl.java
+++ b/core/src/main/java/io/temporal/samples/bookingsaga/TripBookingWorkflowImpl.java
@@ -1,22 +1,3 @@
-/*
- * Copyright (c) 2020 Temporal Technologies, Inc. All Rights Reserved
- *
- * Copyright 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
- * Modifications copyright (C) 2017 Uber Technologies, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"). You may not
- * use this file except in compliance with the License. A copy of the License is
- * located at
- *
- * http://aws.amazon.com/apache2.0
- *
- * or in the "license" file accompanying this file. This file is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
package io.temporal.samples.bookingsaga;
import io.temporal.activity.ActivityOptions;
diff --git a/core/src/main/java/io/temporal/samples/bookingsyncsaga/Booking.java b/core/src/main/java/io/temporal/samples/bookingsyncsaga/Booking.java
index a6a0a4e28..d096e4305 100644
--- a/core/src/main/java/io/temporal/samples/bookingsyncsaga/Booking.java
+++ b/core/src/main/java/io/temporal/samples/bookingsyncsaga/Booking.java
@@ -1,22 +1,3 @@
-/*
- * Copyright (c) 2020 Temporal Technologies, Inc. All Rights Reserved
- *
- * Copyright 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
- * Modifications copyright (C) 2017 Uber Technologies, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"). You may not
- * use this file except in compliance with the License. A copy of the License is
- * located at
- *
- * http://aws.amazon.com/apache2.0
- *
- * or in the "license" file accompanying this file. This file is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
package io.temporal.samples.bookingsyncsaga;
public final class Booking {
diff --git a/core/src/main/java/io/temporal/samples/bookingsyncsaga/TripBookingActivities.java b/core/src/main/java/io/temporal/samples/bookingsyncsaga/TripBookingActivities.java
index a826eb57e..cce0d8828 100644
--- a/core/src/main/java/io/temporal/samples/bookingsyncsaga/TripBookingActivities.java
+++ b/core/src/main/java/io/temporal/samples/bookingsyncsaga/TripBookingActivities.java
@@ -1,22 +1,3 @@
-/*
- * Copyright (c) 2020 Temporal Technologies, Inc. All Rights Reserved
- *
- * Copyright 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
- * Modifications copyright (C) 2017 Uber Technologies, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"). You may not
- * use this file except in compliance with the License. A copy of the License is
- * located at
- *
- * http://aws.amazon.com/apache2.0
- *
- * or in the "license" file accompanying this file. This file is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
package io.temporal.samples.bookingsyncsaga;
import io.temporal.activity.ActivityInterface;
diff --git a/core/src/main/java/io/temporal/samples/bookingsyncsaga/TripBookingActivitiesImpl.java b/core/src/main/java/io/temporal/samples/bookingsyncsaga/TripBookingActivitiesImpl.java
index bb0bc5de1..3ee3f73b3 100644
--- a/core/src/main/java/io/temporal/samples/bookingsyncsaga/TripBookingActivitiesImpl.java
+++ b/core/src/main/java/io/temporal/samples/bookingsyncsaga/TripBookingActivitiesImpl.java
@@ -1,22 +1,3 @@
-/*
- * Copyright (c) 2020 Temporal Technologies, Inc. All Rights Reserved
- *
- * Copyright 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
- * Modifications copyright (C) 2017 Uber Technologies, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"). You may not
- * use this file except in compliance with the License. A copy of the License is
- * located at
- *
- * http://aws.amazon.com/apache2.0
- *
- * or in the "license" file accompanying this file. This file is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
package io.temporal.samples.bookingsyncsaga;
import io.temporal.failure.ApplicationFailure;
diff --git a/core/src/main/java/io/temporal/samples/bookingsyncsaga/TripBookingClient.java b/core/src/main/java/io/temporal/samples/bookingsyncsaga/TripBookingClient.java
index e4857c4ea..74aa32b86 100644
--- a/core/src/main/java/io/temporal/samples/bookingsyncsaga/TripBookingClient.java
+++ b/core/src/main/java/io/temporal/samples/bookingsyncsaga/TripBookingClient.java
@@ -1,38 +1,30 @@
-/*
- * Copyright (c) 2020 Temporal Technologies, Inc. All Rights Reserved
- *
- * Copyright 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
- * Modifications copyright (C) 2017 Uber Technologies, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"). You may not
- * use this file except in compliance with the License. A copy of the License is
- * located at
- *
- * http://aws.amazon.com/apache2.0
- *
- * or in the "license" file accompanying this file. This file is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
package io.temporal.samples.bookingsyncsaga;
import com.google.common.base.Throwables;
import io.temporal.client.WorkflowClient;
import io.temporal.client.WorkflowOptions;
+import io.temporal.envconfig.ClientConfigProfile;
import io.temporal.serviceclient.WorkflowServiceStubs;
+import java.io.IOException;
public class TripBookingClient {
static final String TASK_QUEUE = "TripBookingSync";
public static void main(String[] args) {
- // gRPC stubs wrapper that talks to the local docker instance of temporal service.
- WorkflowServiceStubs service = WorkflowServiceStubs.newLocalServiceStubs();
+ // Load configuration from environment and files
+ ClientConfigProfile profile;
+ try {
+ profile = ClientConfigProfile.load();
+ } catch (IOException e) {
+ throw new RuntimeException("Failed to load client configuration", e);
+ }
+
+ // gRPC stubs wrapper that talks to the temporal service.
+ WorkflowServiceStubs service =
+ WorkflowServiceStubs.newServiceStubs(profile.toWorkflowServiceStubsOptions());
// client that can be used to start and signal workflows
- WorkflowClient client = WorkflowClient.newInstance(service);
+ WorkflowClient client = WorkflowClient.newInstance(service, profile.toWorkflowClientOptions());
WorkflowOptions options =
WorkflowOptions.newBuilder().setTaskQueue(TASK_QUEUE).setWorkflowId("Booking1").build();
diff --git a/core/src/main/java/io/temporal/samples/bookingsyncsaga/TripBookingWorker.java b/core/src/main/java/io/temporal/samples/bookingsyncsaga/TripBookingWorker.java
index 263d4e405..c70dc9481 100644
--- a/core/src/main/java/io/temporal/samples/bookingsyncsaga/TripBookingWorker.java
+++ b/core/src/main/java/io/temporal/samples/bookingsyncsaga/TripBookingWorker.java
@@ -1,37 +1,29 @@
-/*
- * Copyright (c) 2020 Temporal Technologies, Inc. All Rights Reserved
- *
- * Copyright 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
- * Modifications copyright (C) 2017 Uber Technologies, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"). You may not
- * use this file except in compliance with the License. A copy of the License is
- * located at
- *
- * http://aws.amazon.com/apache2.0
- *
- * or in the "license" file accompanying this file. This file is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
package io.temporal.samples.bookingsyncsaga;
import io.temporal.client.WorkflowClient;
+import io.temporal.envconfig.ClientConfigProfile;
import io.temporal.serviceclient.WorkflowServiceStubs;
import io.temporal.worker.Worker;
import io.temporal.worker.WorkerFactory;
+import java.io.IOException;
public class TripBookingWorker {
@SuppressWarnings("CatchAndPrintStackTrace")
public static void main(String[] args) {
// gRPC stubs wrapper that talks to the local docker instance of temporal service.
- WorkflowServiceStubs service = WorkflowServiceStubs.newLocalServiceStubs();
+ // Load configuration from environment and files
+ ClientConfigProfile profile;
+ try {
+ profile = ClientConfigProfile.load();
+ } catch (IOException e) {
+ throw new RuntimeException("Failed to load client configuration", e);
+ }
+
+ WorkflowServiceStubs service =
+ WorkflowServiceStubs.newServiceStubs(profile.toWorkflowServiceStubsOptions());
// client that can be used to start and signal workflows
- WorkflowClient client = WorkflowClient.newInstance(service);
+ WorkflowClient client = WorkflowClient.newInstance(service, profile.toWorkflowClientOptions());
// worker factory that can be used to create workers for specific task queues
WorkerFactory factory = WorkerFactory.newInstance(client);
diff --git a/core/src/main/java/io/temporal/samples/bookingsyncsaga/TripBookingWorkflow.java b/core/src/main/java/io/temporal/samples/bookingsyncsaga/TripBookingWorkflow.java
index 99ab6bf79..933f67bb1 100644
--- a/core/src/main/java/io/temporal/samples/bookingsyncsaga/TripBookingWorkflow.java
+++ b/core/src/main/java/io/temporal/samples/bookingsyncsaga/TripBookingWorkflow.java
@@ -1,22 +1,3 @@
-/*
- * Copyright (c) 2020 Temporal Technologies, Inc. All Rights Reserved
- *
- * Copyright 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
- * Modifications copyright (C) 2017 Uber Technologies, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"). You may not
- * use this file except in compliance with the License. A copy of the License is
- * located at
- *
- * http://aws.amazon.com/apache2.0
- *
- * or in the "license" file accompanying this file. This file is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
package io.temporal.samples.bookingsyncsaga;
import io.temporal.workflow.UpdateMethod;
diff --git a/core/src/main/java/io/temporal/samples/bookingsyncsaga/TripBookingWorkflowImpl.java b/core/src/main/java/io/temporal/samples/bookingsyncsaga/TripBookingWorkflowImpl.java
index 8f8c640cc..e6971b3f0 100644
--- a/core/src/main/java/io/temporal/samples/bookingsyncsaga/TripBookingWorkflowImpl.java
+++ b/core/src/main/java/io/temporal/samples/bookingsyncsaga/TripBookingWorkflowImpl.java
@@ -1,22 +1,3 @@
-/*
- * Copyright (c) 2020 Temporal Technologies, Inc. All Rights Reserved
- *
- * Copyright 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
- * Modifications copyright (C) 2017 Uber Technologies, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"). You may not
- * use this file except in compliance with the License. A copy of the License is
- * located at
- *
- * http://aws.amazon.com/apache2.0
- *
- * or in the "license" file accompanying this file. This file is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
package io.temporal.samples.bookingsyncsaga;
import io.temporal.activity.ActivityOptions;
diff --git a/core/src/main/java/io/temporal/samples/common/QueryWorkflowExecution.java b/core/src/main/java/io/temporal/samples/common/QueryWorkflowExecution.java
index 4a56eb83a..9f9cbe797 100644
--- a/core/src/main/java/io/temporal/samples/common/QueryWorkflowExecution.java
+++ b/core/src/main/java/io/temporal/samples/common/QueryWorkflowExecution.java
@@ -1,28 +1,11 @@
-/*
- * Copyright (c) 2020 Temporal Technologies, Inc. All Rights Reserved
- *
- * Copyright 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
- * Modifications copyright (C) 2017 Uber Technologies, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"). You may not
- * use this file except in compliance with the License. A copy of the License is
- * located at
- *
- * http://aws.amazon.com/apache2.0
- *
- * or in the "license" file accompanying this file. This file is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
package io.temporal.samples.common;
import io.temporal.api.common.v1.WorkflowExecution;
import io.temporal.client.WorkflowClient;
import io.temporal.client.WorkflowStub;
+import io.temporal.envconfig.ClientConfigProfile;
import io.temporal.serviceclient.WorkflowServiceStubs;
+import java.io.IOException;
import java.util.Optional;
/**
@@ -46,9 +29,18 @@ public static void main(String[] args) {
String runId = args.length == 3 ? args[2] : "";
// gRPC stubs wrapper that talks to the local docker instance of temporal service.
- WorkflowServiceStubs service = WorkflowServiceStubs.newLocalServiceStubs();
+ // Load configuration from environment and files
+ ClientConfigProfile profile;
+ try {
+ profile = ClientConfigProfile.load();
+ } catch (IOException e) {
+ throw new RuntimeException("Failed to load client configuration", e);
+ }
+
+ WorkflowServiceStubs service =
+ WorkflowServiceStubs.newServiceStubs(profile.toWorkflowServiceStubsOptions());
- WorkflowClient client = WorkflowClient.newInstance(service);
+ WorkflowClient client = WorkflowClient.newInstance(service, profile.toWorkflowClientOptions());
WorkflowExecution workflowExecution =
WorkflowExecution.newBuilder().setWorkflowId(workflowId).setRunId(runId).build();
diff --git a/core/src/main/java/io/temporal/samples/countinterceptor/ClientCounter.java b/core/src/main/java/io/temporal/samples/countinterceptor/ClientCounter.java
index d0bbf7f3b..d47b876c5 100644
--- a/core/src/main/java/io/temporal/samples/countinterceptor/ClientCounter.java
+++ b/core/src/main/java/io/temporal/samples/countinterceptor/ClientCounter.java
@@ -1,22 +1,3 @@
-/*
- * Copyright (c) 2020 Temporal Technologies, Inc. All Rights Reserved
- *
- * Copyright 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
- * Modifications copyright (C) 2017 Uber Technologies, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"). You may not
- * use this file except in compliance with the License. A copy of the License is
- * located at
- *
- * http://aws.amazon.com/apache2.0
- *
- * or in the "license" file accompanying this file. This file is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
package io.temporal.samples.countinterceptor;
import java.util.AbstractMap;
diff --git a/core/src/main/java/io/temporal/samples/countinterceptor/InterceptorStarter.java b/core/src/main/java/io/temporal/samples/countinterceptor/InterceptorStarter.java
index c3c8280c7..30c73c14f 100644
--- a/core/src/main/java/io/temporal/samples/countinterceptor/InterceptorStarter.java
+++ b/core/src/main/java/io/temporal/samples/countinterceptor/InterceptorStarter.java
@@ -1,22 +1,3 @@
-/*
- * Copyright (c) 2020 Temporal Technologies, Inc. All Rights Reserved
- *
- * Copyright 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
- * Modifications copyright (C) 2017 Uber Technologies, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"). You may not
- * use this file except in compliance with the License. A copy of the License is
- * located at
- *
- * http://aws.amazon.com/apache2.0
- *
- * or in the "license" file accompanying this file. This file is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
package io.temporal.samples.countinterceptor;
import io.temporal.client.WorkflowClient;
@@ -24,6 +5,7 @@
import io.temporal.client.WorkflowOptions;
import io.temporal.client.WorkflowStub;
import io.temporal.common.interceptors.WorkflowClientInterceptor;
+import io.temporal.envconfig.ClientConfigProfile;
import io.temporal.samples.countinterceptor.activities.MyActivitiesImpl;
import io.temporal.samples.countinterceptor.workflow.MyChildWorkflowImpl;
import io.temporal.samples.countinterceptor.workflow.MyWorkflow;
@@ -32,6 +14,7 @@
import io.temporal.worker.Worker;
import io.temporal.worker.WorkerFactory;
import io.temporal.worker.WorkerFactoryOptions;
+import java.io.IOException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -48,7 +31,16 @@ public static void main(String[] args) {
final ClientCounter clientCounter = new ClientCounter();
final WorkflowClientInterceptor clientInterceptor = new SimpleClientInterceptor(clientCounter);
- WorkflowServiceStubs service = WorkflowServiceStubs.newLocalServiceStubs();
+ // Load configuration from environment and files
+ ClientConfigProfile profile;
+ try {
+ profile = ClientConfigProfile.load();
+ } catch (IOException e) {
+ throw new RuntimeException("Failed to load client configuration", e);
+ }
+
+ WorkflowServiceStubs service =
+ WorkflowServiceStubs.newServiceStubs(profile.toWorkflowServiceStubsOptions());
WorkflowClient client =
WorkflowClient.newInstance(
service, WorkflowClientOptions.newBuilder().setInterceptors(clientInterceptor).build());
diff --git a/core/src/main/java/io/temporal/samples/countinterceptor/SimpleClientCallsInterceptor.java b/core/src/main/java/io/temporal/samples/countinterceptor/SimpleClientCallsInterceptor.java
index c6deda735..5c9d457fe 100644
--- a/core/src/main/java/io/temporal/samples/countinterceptor/SimpleClientCallsInterceptor.java
+++ b/core/src/main/java/io/temporal/samples/countinterceptor/SimpleClientCallsInterceptor.java
@@ -1,22 +1,3 @@
-/*
- * Copyright (c) 2020 Temporal Technologies, Inc. All Rights Reserved
- *
- * Copyright 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
- * Modifications copyright (C) 2017 Uber Technologies, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"). You may not
- * use this file except in compliance with the License. A copy of the License is
- * located at
- *
- * http://aws.amazon.com/apache2.0
- *
- * or in the "license" file accompanying this file. This file is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
package io.temporal.samples.countinterceptor;
import io.temporal.common.interceptors.WorkflowClientCallsInterceptor;
diff --git a/core/src/main/java/io/temporal/samples/countinterceptor/SimpleClientInterceptor.java b/core/src/main/java/io/temporal/samples/countinterceptor/SimpleClientInterceptor.java
index aafc7625c..6757db210 100644
--- a/core/src/main/java/io/temporal/samples/countinterceptor/SimpleClientInterceptor.java
+++ b/core/src/main/java/io/temporal/samples/countinterceptor/SimpleClientInterceptor.java
@@ -1,22 +1,3 @@
-/*
- * Copyright (c) 2020 Temporal Technologies, Inc. All Rights Reserved
- *
- * Copyright 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
- * Modifications copyright (C) 2017 Uber Technologies, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"). You may not
- * use this file except in compliance with the License. A copy of the License is
- * located at
- *
- * http://aws.amazon.com/apache2.0
- *
- * or in the "license" file accompanying this file. This file is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
package io.temporal.samples.countinterceptor;
import io.temporal.common.interceptors.WorkflowClientCallsInterceptor;
diff --git a/core/src/main/java/io/temporal/samples/countinterceptor/SimpleCountActivityInboundCallsInterceptor.java b/core/src/main/java/io/temporal/samples/countinterceptor/SimpleCountActivityInboundCallsInterceptor.java
index a866680ff..2793d6ff4 100644
--- a/core/src/main/java/io/temporal/samples/countinterceptor/SimpleCountActivityInboundCallsInterceptor.java
+++ b/core/src/main/java/io/temporal/samples/countinterceptor/SimpleCountActivityInboundCallsInterceptor.java
@@ -1,22 +1,3 @@
-/*
- * Copyright (c) 2020 Temporal Technologies, Inc. All Rights Reserved
- *
- * Copyright 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
- * Modifications copyright (C) 2017 Uber Technologies, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"). You may not
- * use this file except in compliance with the License. A copy of the License is
- * located at
- *
- * http://aws.amazon.com/apache2.0
- *
- * or in the "license" file accompanying this file. This file is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
package io.temporal.samples.countinterceptor;
import io.temporal.activity.ActivityExecutionContext;
diff --git a/core/src/main/java/io/temporal/samples/countinterceptor/SimpleCountWorkerInterceptor.java b/core/src/main/java/io/temporal/samples/countinterceptor/SimpleCountWorkerInterceptor.java
index 156002e42..6b48ff1ac 100644
--- a/core/src/main/java/io/temporal/samples/countinterceptor/SimpleCountWorkerInterceptor.java
+++ b/core/src/main/java/io/temporal/samples/countinterceptor/SimpleCountWorkerInterceptor.java
@@ -1,22 +1,3 @@
-/*
- * Copyright (c) 2020 Temporal Technologies, Inc. All Rights Reserved
- *
- * Copyright 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
- * Modifications copyright (C) 2017 Uber Technologies, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"). You may not
- * use this file except in compliance with the License. A copy of the License is
- * located at
- *
- * http://aws.amazon.com/apache2.0
- *
- * or in the "license" file accompanying this file. This file is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
package io.temporal.samples.countinterceptor;
import io.temporal.common.interceptors.*;
diff --git a/core/src/main/java/io/temporal/samples/countinterceptor/SimpleCountWorkflowInboundCallsInterceptor.java b/core/src/main/java/io/temporal/samples/countinterceptor/SimpleCountWorkflowInboundCallsInterceptor.java
index 8acd6d177..ff4cc4942 100644
--- a/core/src/main/java/io/temporal/samples/countinterceptor/SimpleCountWorkflowInboundCallsInterceptor.java
+++ b/core/src/main/java/io/temporal/samples/countinterceptor/SimpleCountWorkflowInboundCallsInterceptor.java
@@ -1,22 +1,3 @@
-/*
- * Copyright (c) 2020 Temporal Technologies, Inc. All Rights Reserved
- *
- * Copyright 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
- * Modifications copyright (C) 2017 Uber Technologies, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"). You may not
- * use this file except in compliance with the License. A copy of the License is
- * located at
- *
- * http://aws.amazon.com/apache2.0
- *
- * or in the "license" file accompanying this file. This file is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
package io.temporal.samples.countinterceptor;
import io.temporal.common.interceptors.WorkflowInboundCallsInterceptor;
diff --git a/core/src/main/java/io/temporal/samples/countinterceptor/SimpleCountWorkflowOutboundCallsInterceptor.java b/core/src/main/java/io/temporal/samples/countinterceptor/SimpleCountWorkflowOutboundCallsInterceptor.java
index 1add50445..2ddc564f6 100644
--- a/core/src/main/java/io/temporal/samples/countinterceptor/SimpleCountWorkflowOutboundCallsInterceptor.java
+++ b/core/src/main/java/io/temporal/samples/countinterceptor/SimpleCountWorkflowOutboundCallsInterceptor.java
@@ -1,22 +1,3 @@
-/*
- * Copyright (c) 2020 Temporal Technologies, Inc. All Rights Reserved
- *
- * Copyright 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
- * Modifications copyright (C) 2017 Uber Technologies, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"). You may not
- * use this file except in compliance with the License. A copy of the License is
- * located at
- *
- * http://aws.amazon.com/apache2.0
- *
- * or in the "license" file accompanying this file. This file is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
package io.temporal.samples.countinterceptor;
import io.temporal.common.interceptors.WorkflowOutboundCallsInterceptor;
diff --git a/core/src/main/java/io/temporal/samples/countinterceptor/WorkerCounter.java b/core/src/main/java/io/temporal/samples/countinterceptor/WorkerCounter.java
index d6d35abfd..4b7a4a779 100644
--- a/core/src/main/java/io/temporal/samples/countinterceptor/WorkerCounter.java
+++ b/core/src/main/java/io/temporal/samples/countinterceptor/WorkerCounter.java
@@ -1,22 +1,3 @@
-/*
- * Copyright (c) 2020 Temporal Technologies, Inc. All Rights Reserved
- *
- * Copyright 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
- * Modifications copyright (C) 2017 Uber Technologies, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"). You may not
- * use this file except in compliance with the License. A copy of the License is
- * located at
- *
- * http://aws.amazon.com/apache2.0
- *
- * or in the "license" file accompanying this file. This file is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
package io.temporal.samples.countinterceptor;
import java.util.AbstractMap;
diff --git a/core/src/main/java/io/temporal/samples/countinterceptor/activities/MyActivities.java b/core/src/main/java/io/temporal/samples/countinterceptor/activities/MyActivities.java
index 5935003e9..6ff303e71 100644
--- a/core/src/main/java/io/temporal/samples/countinterceptor/activities/MyActivities.java
+++ b/core/src/main/java/io/temporal/samples/countinterceptor/activities/MyActivities.java
@@ -1,22 +1,3 @@
-/*
- * Copyright (c) 2020 Temporal Technologies, Inc. All Rights Reserved
- *
- * Copyright 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
- * Modifications copyright (C) 2017 Uber Technologies, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"). You may not
- * use this file except in compliance with the License. A copy of the License is
- * located at
- *
- * http://aws.amazon.com/apache2.0
- *
- * or in the "license" file accompanying this file. This file is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
package io.temporal.samples.countinterceptor.activities;
import io.temporal.activity.ActivityInterface;
diff --git a/core/src/main/java/io/temporal/samples/countinterceptor/activities/MyActivitiesImpl.java b/core/src/main/java/io/temporal/samples/countinterceptor/activities/MyActivitiesImpl.java
index b2ca5edf2..6ab501d53 100644
--- a/core/src/main/java/io/temporal/samples/countinterceptor/activities/MyActivitiesImpl.java
+++ b/core/src/main/java/io/temporal/samples/countinterceptor/activities/MyActivitiesImpl.java
@@ -1,22 +1,3 @@
-/*
- * Copyright (c) 2020 Temporal Technologies, Inc. All Rights Reserved
- *
- * Copyright 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
- * Modifications copyright (C) 2017 Uber Technologies, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"). You may not
- * use this file except in compliance with the License. A copy of the License is
- * located at
- *
- * http://aws.amazon.com/apache2.0
- *
- * or in the "license" file accompanying this file. This file is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
package io.temporal.samples.countinterceptor.activities;
public class MyActivitiesImpl implements MyActivities {
diff --git a/core/src/main/java/io/temporal/samples/countinterceptor/workflow/MyChildWorkflow.java b/core/src/main/java/io/temporal/samples/countinterceptor/workflow/MyChildWorkflow.java
index 36e5099da..0434026f8 100644
--- a/core/src/main/java/io/temporal/samples/countinterceptor/workflow/MyChildWorkflow.java
+++ b/core/src/main/java/io/temporal/samples/countinterceptor/workflow/MyChildWorkflow.java
@@ -1,22 +1,3 @@
-/*
- * Copyright (c) 2020 Temporal Technologies, Inc. All Rights Reserved
- *
- * Copyright 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
- * Modifications copyright (C) 2017 Uber Technologies, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"). You may not
- * use this file except in compliance with the License. A copy of the License is
- * located at
- *
- * http://aws.amazon.com/apache2.0
- *
- * or in the "license" file accompanying this file. This file is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
package io.temporal.samples.countinterceptor.workflow;
import io.temporal.workflow.WorkflowInterface;
diff --git a/core/src/main/java/io/temporal/samples/countinterceptor/workflow/MyChildWorkflowImpl.java b/core/src/main/java/io/temporal/samples/countinterceptor/workflow/MyChildWorkflowImpl.java
index d4a944071..68cdf7c02 100644
--- a/core/src/main/java/io/temporal/samples/countinterceptor/workflow/MyChildWorkflowImpl.java
+++ b/core/src/main/java/io/temporal/samples/countinterceptor/workflow/MyChildWorkflowImpl.java
@@ -1,22 +1,3 @@
-/*
- * Copyright (c) 2020 Temporal Technologies, Inc. All Rights Reserved
- *
- * Copyright 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
- * Modifications copyright (C) 2017 Uber Technologies, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"). You may not
- * use this file except in compliance with the License. A copy of the License is
- * located at
- *
- * http://aws.amazon.com/apache2.0
- *
- * or in the "license" file accompanying this file. This file is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
package io.temporal.samples.countinterceptor.workflow;
import io.temporal.activity.ActivityOptions;
diff --git a/core/src/main/java/io/temporal/samples/countinterceptor/workflow/MyWorkflow.java b/core/src/main/java/io/temporal/samples/countinterceptor/workflow/MyWorkflow.java
index 8541fc604..5714391f5 100644
--- a/core/src/main/java/io/temporal/samples/countinterceptor/workflow/MyWorkflow.java
+++ b/core/src/main/java/io/temporal/samples/countinterceptor/workflow/MyWorkflow.java
@@ -1,22 +1,3 @@
-/*
- * Copyright (c) 2020 Temporal Technologies, Inc. All Rights Reserved
- *
- * Copyright 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
- * Modifications copyright (C) 2017 Uber Technologies, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"). You may not
- * use this file except in compliance with the License. A copy of the License is
- * located at
- *
- * http://aws.amazon.com/apache2.0
- *
- * or in the "license" file accompanying this file. This file is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
package io.temporal.samples.countinterceptor.workflow;
import io.temporal.workflow.QueryMethod;
diff --git a/core/src/main/java/io/temporal/samples/countinterceptor/workflow/MyWorkflowImpl.java b/core/src/main/java/io/temporal/samples/countinterceptor/workflow/MyWorkflowImpl.java
index f20876e16..f187af94c 100644
--- a/core/src/main/java/io/temporal/samples/countinterceptor/workflow/MyWorkflowImpl.java
+++ b/core/src/main/java/io/temporal/samples/countinterceptor/workflow/MyWorkflowImpl.java
@@ -1,22 +1,3 @@
-/*
- * Copyright (c) 2020 Temporal Technologies, Inc. All Rights Reserved
- *
- * Copyright 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
- * Modifications copyright (C) 2017 Uber Technologies, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"). You may not
- * use this file except in compliance with the License. A copy of the License is
- * located at
- *
- * http://aws.amazon.com/apache2.0
- *
- * or in the "license" file accompanying this file. This file is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
package io.temporal.samples.countinterceptor.workflow;
import io.temporal.workflow.ChildWorkflowOptions;
diff --git a/core/src/main/java/io/temporal/samples/customannotation/BenignExceptionTypes.java b/core/src/main/java/io/temporal/samples/customannotation/BenignExceptionTypes.java
new file mode 100644
index 000000000..a97ebd26c
--- /dev/null
+++ b/core/src/main/java/io/temporal/samples/customannotation/BenignExceptionTypes.java
@@ -0,0 +1,18 @@
+package io.temporal.samples.customannotation;
+
+import java.lang.annotation.*;
+
+/**
+ * BenignExceptionTypes is an annotation that can be used to specify an exception type is benign and
+ * not an issue worth logging.
+ *
+ *
For this annotation to work, {@link BenignExceptionTypesAnnotationInterceptor} must be passed
+ * as a worker interceptor to the worker factory.
+ */
+@Documented
+@Target(ElementType.METHOD)
+@Retention(RetentionPolicy.RUNTIME)
+public @interface BenignExceptionTypes {
+ /** Type of exceptions that should be considered benign and not logged as errors. */
+ Class extends Exception>[] value();
+}
diff --git a/core/src/main/java/io/temporal/samples/customannotation/BenignExceptionTypesAnnotationInterceptor.java b/core/src/main/java/io/temporal/samples/customannotation/BenignExceptionTypesAnnotationInterceptor.java
new file mode 100644
index 000000000..71ee51a9d
--- /dev/null
+++ b/core/src/main/java/io/temporal/samples/customannotation/BenignExceptionTypesAnnotationInterceptor.java
@@ -0,0 +1,113 @@
+/*
+ * Copyright (c) 2020 Temporal Technologies, Inc. All Rights Reserved
+ *
+ * Copyright 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
+ *
+ * Modifications copyright (C) 2017 Uber Technologies, Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"). You may not
+ * use this file except in compliance with the License. A copy of the License is
+ * located at
+ *
+ * http://aws.amazon.com/apache2.0
+ *
+ * or in the "license" file accompanying this file. This file is distributed on
+ * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied. See the License for the specific language governing
+ * permissions and limitations under the License.
+ */
+
+package io.temporal.samples.customannotation;
+
+import io.temporal.activity.ActivityExecutionContext;
+import io.temporal.common.interceptors.ActivityInboundCallsInterceptor;
+import io.temporal.common.interceptors.WorkerInterceptorBase;
+import io.temporal.common.metadata.POJOActivityImplMetadata;
+import io.temporal.common.metadata.POJOActivityMethodMetadata;
+import io.temporal.failure.ApplicationErrorCategory;
+import io.temporal.failure.ApplicationFailure;
+import io.temporal.failure.TemporalFailure;
+import java.lang.reflect.Method;
+import java.util.Arrays;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+/**
+ * Checks if the activity method has the {@link BenignExceptionTypes} annotation. If it does, it
+ * will throw an ApplicationFailure with {@link ApplicationErrorCategory#BENIGN}.
+ */
+public class BenignExceptionTypesAnnotationInterceptor extends WorkerInterceptorBase {
+
+ @Override
+ public ActivityInboundCallsInterceptor interceptActivity(ActivityInboundCallsInterceptor next) {
+ return new ActivityInboundCallsInterceptorAnnotation(next);
+ }
+
+ public static class ActivityInboundCallsInterceptorAnnotation
+ extends io.temporal.common.interceptors.ActivityInboundCallsInterceptorBase {
+ private final ActivityInboundCallsInterceptor next;
+ private Set> benignExceptionTypes = new HashSet<>();
+
+ public ActivityInboundCallsInterceptorAnnotation(ActivityInboundCallsInterceptor next) {
+ super(next);
+ this.next = next;
+ }
+
+ @Override
+ public void init(ActivityExecutionContext context) {
+ List activityMethods =
+ POJOActivityImplMetadata.newInstance(context.getInstance().getClass())
+ .getActivityMethods();
+ POJOActivityMethodMetadata currentActivityMethod =
+ activityMethods.stream()
+ .filter(x -> x.getActivityTypeName().equals(context.getInfo().getActivityType()))
+ .findFirst()
+ .get();
+ // Get the implementation method from the interface method
+ Method implementationMethod;
+ try {
+ implementationMethod =
+ context
+ .getInstance()
+ .getClass()
+ .getMethod(
+ currentActivityMethod.getMethod().getName(),
+ currentActivityMethod.getMethod().getParameterTypes());
+ } catch (NoSuchMethodException e) {
+ throw new RuntimeException(e);
+ }
+ // Get the @BenignExceptionTypes annotations from the implementation method
+ BenignExceptionTypes an = implementationMethod.getAnnotation(BenignExceptionTypes.class);
+ if (an != null && an.value() != null) {
+ benignExceptionTypes = new HashSet<>(Arrays.asList(an.value()));
+ }
+ next.init(context);
+ }
+
+ @Override
+ public ActivityOutput execute(ActivityInput input) {
+ if (benignExceptionTypes.isEmpty()) {
+ return next.execute(input);
+ }
+ try {
+ return next.execute(input);
+ } catch (TemporalFailure tf) {
+ throw tf;
+ } catch (Exception e) {
+ if (benignExceptionTypes.contains(e.getClass())) {
+ // If the exception is in the list of benign exceptions, throw an ApplicationFailure
+ // with a BENIGN category
+ throw ApplicationFailure.newBuilder()
+ .setMessage(e.getMessage())
+ .setType(e.getClass().getName())
+ .setCause(e)
+ .setCategory(ApplicationErrorCategory.BENIGN)
+ .build();
+ }
+ // If the exception is not in the list of benign exceptions, rethrow it
+ throw e;
+ }
+ }
+ }
+}
diff --git a/core/src/main/java/io/temporal/samples/customannotation/CustomAnnotation.java b/core/src/main/java/io/temporal/samples/customannotation/CustomAnnotation.java
new file mode 100644
index 000000000..db6df4229
--- /dev/null
+++ b/core/src/main/java/io/temporal/samples/customannotation/CustomAnnotation.java
@@ -0,0 +1,208 @@
+/*
+ * Copyright (c) 2020 Temporal Technologies, Inc. All Rights Reserved
+ *
+ * Copyright 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
+ *
+ * Modifications copyright (C) 2017 Uber Technologies, Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"). You may not
+ * use this file except in compliance with the License. A copy of the License is
+ * located at
+ *
+ * http://aws.amazon.com/apache2.0
+ *
+ * or in the "license" file accompanying this file. This file is distributed on
+ * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied. See the License for the specific language governing
+ * permissions and limitations under the License.
+ */
+
+package io.temporal.samples.customannotation;
+
+import io.temporal.activity.ActivityInterface;
+import io.temporal.activity.ActivityMethod;
+import io.temporal.activity.ActivityOptions;
+import io.temporal.client.WorkflowClient;
+import io.temporal.client.WorkflowOptions;
+import io.temporal.envconfig.ClientConfigProfile;
+import io.temporal.serviceclient.WorkflowServiceStubs;
+import io.temporal.worker.Worker;
+import io.temporal.worker.WorkerFactory;
+import io.temporal.worker.WorkerFactoryOptions;
+import io.temporal.workflow.Workflow;
+import io.temporal.workflow.WorkflowInterface;
+import io.temporal.workflow.WorkflowMethod;
+import java.io.IOException;
+import java.time.Duration;
+
+public class CustomAnnotation {
+
+ // Define the task queue name
+ static final String TASK_QUEUE = "CustomAnnotationTaskQueue";
+
+ // Define our workflow unique id
+ static final String WORKFLOW_ID = "CustomAnnotationWorkflow";
+
+ /**
+ * The Workflow Definition's Interface must contain one method annotated with @WorkflowMethod.
+ *
+ * Workflow Definitions should not contain any heavyweight computations, non-deterministic
+ * code, network calls, database operations, etc. Those things should be handled by the
+ * Activities.
+ *
+ * @see WorkflowInterface
+ * @see WorkflowMethod
+ */
+ @WorkflowInterface
+ public interface GreetingWorkflow {
+
+ /**
+ * This is the method that is executed when the Workflow Execution is started. The Workflow
+ * Execution completes when this method finishes execution.
+ */
+ @WorkflowMethod
+ String getGreeting(String name);
+ }
+
+ /**
+ * This is the Activity Definition's Interface. Activities are building blocks of any Temporal
+ * Workflow and contain any business logic that could perform long running computation, network
+ * calls, etc.
+ *
+ *
Annotating Activity Definition methods with @ActivityMethod is optional.
+ *
+ * @see ActivityInterface
+ * @see ActivityMethod
+ */
+ @ActivityInterface
+ public interface GreetingActivities {
+
+ /** Define your activity method which can be called during workflow execution */
+ String composeGreeting(String greeting, String name);
+ }
+
+ // Define the workflow implementation which implements our getGreeting workflow method.
+ public static class GreetingWorkflowImpl implements GreetingWorkflow {
+
+ /**
+ * Define the GreetingActivities stub. Activity stubs are proxies for activity invocations that
+ * are executed outside of the workflow thread on the activity worker, that can be on a
+ * different host. Temporal is going to dispatch the activity results back to the workflow and
+ * unblock the stub as soon as activity is completed on the activity worker.
+ */
+ private final GreetingActivities activities =
+ Workflow.newActivityStub(
+ GreetingActivities.class,
+ ActivityOptions.newBuilder().setStartToCloseTimeout(Duration.ofSeconds(10)).build());
+
+ @Override
+ public String getGreeting(String name) {
+ // This is a blocking call that returns only after activity is completed.
+ return activities.composeGreeting("Hello", name);
+ }
+ }
+
+ /**
+ * Implementation of our workflow activity interface. It overwrites our defined composeGreeting
+ * activity method.
+ */
+ static class GreetingActivitiesImpl implements GreetingActivities {
+ private int callCount;
+
+ /**
+ * Our activity implementation simulates a failure 3 times. Given our previously set
+ * RetryOptions, our workflow is going to retry our activity execution.
+ */
+ @Override
+ @BenignExceptionTypes({IllegalStateException.class})
+ public synchronized String composeGreeting(String greeting, String name) {
+ if (++callCount < 4) {
+ System.out.println("composeGreeting activity is going to fail");
+ throw new IllegalStateException("not yet");
+ }
+
+ // after 3 unsuccessful retries we finally can complete our activity execution
+ System.out.println("composeGreeting activity is going to complete");
+ return greeting + " " + name + "!";
+ }
+ }
+
+ /**
+ * With our Workflow and Activities defined, we can now start execution. The main method starts
+ * the worker and then the workflow.
+ */
+ public static void main(String[] args) {
+
+ // Get a Workflow service stub.
+ // Load configuration from environment and files
+ ClientConfigProfile profile;
+ try {
+ profile = ClientConfigProfile.load();
+ } catch (IOException e) {
+ throw new RuntimeException("Failed to load client configuration", e);
+ }
+
+ WorkflowServiceStubs service =
+ WorkflowServiceStubs.newServiceStubs(profile.toWorkflowServiceStubsOptions());
+
+ /*
+ * Get a Workflow service client which can be used to start, Signal, and Query Workflow Executions.
+ */
+ WorkflowClient client = WorkflowClient.newInstance(service, profile.toWorkflowClientOptions());
+
+ /*
+ * Define the workflow factory. It is used to create workflow workers for a specific task queue.
+ */
+ WorkerFactory factory =
+ WorkerFactory.newInstance(
+ client,
+ WorkerFactoryOptions.newBuilder()
+ .setWorkerInterceptors(new BenignExceptionTypesAnnotationInterceptor())
+ .build());
+
+ /*
+ * Define the workflow worker. Workflow workers listen to a defined task queue and process
+ * workflows and activities.
+ */
+ Worker worker = factory.newWorker(TASK_QUEUE);
+
+ /*
+ * Register our workflow implementation with the worker.
+ * Workflow implementations must be known to the worker at runtime in
+ * order to dispatch workflow tasks.
+ */
+ worker.registerWorkflowImplementationTypes(GreetingWorkflowImpl.class);
+
+ /*
+ * Register our Activity Types with the Worker. Since Activities are stateless and thread-safe,
+ * the Activity Type is a shared instance.
+ */
+ worker.registerActivitiesImplementations(new GreetingActivitiesImpl());
+
+ /*
+ * Start all the workers registered for a specific task queue.
+ * The started workers then start polling for workflows and activities.
+ */
+ factory.start();
+
+ // Set our workflow options
+ WorkflowOptions workflowOptions =
+ WorkflowOptions.newBuilder().setWorkflowId(WORKFLOW_ID).setTaskQueue(TASK_QUEUE).build();
+
+ // Create the workflow client stub. It is used to start our workflow execution.
+ GreetingWorkflow workflow = client.newWorkflowStub(GreetingWorkflow.class, workflowOptions);
+
+ /*
+ * Execute our workflow and wait for it to complete. The call to our getGreeting method is
+ * synchronous.
+ *
+ * See {@link io.temporal.samples.hello.HelloSignal} for an example of starting workflow
+ * without waiting synchronously for its result.
+ */
+ String greeting = workflow.getGreeting("World");
+
+ // Display workflow execution results
+ System.out.println(greeting);
+ System.exit(0);
+ }
+}
diff --git a/core/src/main/java/io/temporal/samples/customannotation/README.md b/core/src/main/java/io/temporal/samples/customannotation/README.md
new file mode 100644
index 000000000..f04b25915
--- /dev/null
+++ b/core/src/main/java/io/temporal/samples/customannotation/README.md
@@ -0,0 +1,9 @@
+# Custom annotation
+
+The sample demonstrates how to create a custom annotation using an interceptor. In this case the annotation allows specifying an exception of a certain type is benign.
+
+This samples shows a custom annotation on an activity method, but the same approach can be used for workflow methods or Nexus operations.
+
+```bash
+./gradlew -q execute -PmainClass=io.temporal.samples.customannotation.CustomAnnotation
+```
diff --git a/core/src/main/java/io/temporal/samples/customchangeversion/CustomChangeVersionActivities.java b/core/src/main/java/io/temporal/samples/customchangeversion/CustomChangeVersionActivities.java
index d42d0455f..5d49812cc 100644
--- a/core/src/main/java/io/temporal/samples/customchangeversion/CustomChangeVersionActivities.java
+++ b/core/src/main/java/io/temporal/samples/customchangeversion/CustomChangeVersionActivities.java
@@ -1,22 +1,3 @@
-/*
- * Copyright (c) 2020 Temporal Technologies, Inc. All Rights Reserved
- *
- * Copyright 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
- * Modifications copyright (C) 2017 Uber Technologies, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"). You may not
- * use this file except in compliance with the License. A copy of the License is
- * located at
- *
- * http://aws.amazon.com/apache2.0
- *
- * or in the "license" file accompanying this file. This file is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
package io.temporal.samples.customchangeversion;
import io.temporal.activity.ActivityInterface;
diff --git a/core/src/main/java/io/temporal/samples/customchangeversion/CustomChangeVersionActivitiesImpl.java b/core/src/main/java/io/temporal/samples/customchangeversion/CustomChangeVersionActivitiesImpl.java
index 874171ff3..113d306bd 100644
--- a/core/src/main/java/io/temporal/samples/customchangeversion/CustomChangeVersionActivitiesImpl.java
+++ b/core/src/main/java/io/temporal/samples/customchangeversion/CustomChangeVersionActivitiesImpl.java
@@ -1,22 +1,3 @@
-/*
- * Copyright (c) 2020 Temporal Technologies, Inc. All Rights Reserved
- *
- * Copyright 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
- * Modifications copyright (C) 2017 Uber Technologies, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"). You may not
- * use this file except in compliance with the License. A copy of the License is
- * located at
- *
- * http://aws.amazon.com/apache2.0
- *
- * or in the "license" file accompanying this file. This file is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
package io.temporal.samples.customchangeversion;
public class CustomChangeVersionActivitiesImpl implements CustomChangeVersionActivities {
diff --git a/core/src/main/java/io/temporal/samples/customchangeversion/CustomChangeVersionStarter.java b/core/src/main/java/io/temporal/samples/customchangeversion/CustomChangeVersionStarter.java
index e1200360b..3bd8497b7 100644
--- a/core/src/main/java/io/temporal/samples/customchangeversion/CustomChangeVersionStarter.java
+++ b/core/src/main/java/io/temporal/samples/customchangeversion/CustomChangeVersionStarter.java
@@ -1,22 +1,3 @@
-/*
- * Copyright (c) 2020 Temporal Technologies, Inc. All Rights Reserved
- *
- * Copyright 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
- * Modifications copyright (C) 2017 Uber Technologies, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"). You may not
- * use this file except in compliance with the License. A copy of the License is
- * located at
- *
- * http://aws.amazon.com/apache2.0
- *
- * or in the "license" file accompanying this file. This file is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
package io.temporal.samples.customchangeversion;
import io.grpc.StatusRuntimeException;
@@ -27,22 +8,33 @@
import io.temporal.client.WorkflowServiceException;
import io.temporal.common.SearchAttributeKey;
import io.temporal.common.SearchAttributes;
+import io.temporal.envconfig.ClientConfigProfile;
import io.temporal.serviceclient.OperatorServiceStubs;
import io.temporal.serviceclient.OperatorServiceStubsOptions;
import io.temporal.serviceclient.WorkflowServiceStubs;
import io.temporal.worker.Worker;
import io.temporal.worker.WorkerFactory;
+import java.io.IOException;
import java.util.Collections;
public class CustomChangeVersionStarter {
private static SearchAttributeKey CUSTOM_CHANGE_VERSION =
SearchAttributeKey.forKeyword("CustomChangeVersion");
- private static final WorkflowServiceStubs service = WorkflowServiceStubs.newLocalServiceStubs();
- private static final WorkflowClient client = WorkflowClient.newInstance(service);
private static final String taskQueue = "customChangeVersionTaskQueue";
private static final String workflowId = "CustomChangeVersionWorkflow";
public static void main(String[] args) {
+ // Load configuration from environment and files
+ ClientConfigProfile profile;
+ try {
+ profile = ClientConfigProfile.load();
+ } catch (IOException e) {
+ throw new RuntimeException("Failed to load client configuration", e);
+ }
+
+ WorkflowServiceStubs service =
+ WorkflowServiceStubs.newServiceStubs(profile.toWorkflowServiceStubsOptions());
+ WorkflowClient client = WorkflowClient.newInstance(service, profile.toWorkflowClientOptions());
WorkerFactory workerFactory = WorkerFactory.newInstance(client);
Worker worker = workerFactory.newWorker(taskQueue);
diff --git a/core/src/main/java/io/temporal/samples/customchangeversion/CustomChangeVersionWorkflow.java b/core/src/main/java/io/temporal/samples/customchangeversion/CustomChangeVersionWorkflow.java
index 20d090990..cd9703973 100644
--- a/core/src/main/java/io/temporal/samples/customchangeversion/CustomChangeVersionWorkflow.java
+++ b/core/src/main/java/io/temporal/samples/customchangeversion/CustomChangeVersionWorkflow.java
@@ -1,22 +1,3 @@
-/*
- * Copyright (c) 2020 Temporal Technologies, Inc. All Rights Reserved
- *
- * Copyright 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
- * Modifications copyright (C) 2017 Uber Technologies, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"). You may not
- * use this file except in compliance with the License. A copy of the License is
- * located at
- *
- * http://aws.amazon.com/apache2.0
- *
- * or in the "license" file accompanying this file. This file is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
package io.temporal.samples.customchangeversion;
import io.temporal.workflow.WorkflowInterface;
diff --git a/core/src/main/java/io/temporal/samples/customchangeversion/CustomChangeVersionWorkflowImpl.java b/core/src/main/java/io/temporal/samples/customchangeversion/CustomChangeVersionWorkflowImpl.java
index 51d3ca3eb..c72673899 100644
--- a/core/src/main/java/io/temporal/samples/customchangeversion/CustomChangeVersionWorkflowImpl.java
+++ b/core/src/main/java/io/temporal/samples/customchangeversion/CustomChangeVersionWorkflowImpl.java
@@ -1,22 +1,3 @@
-/*
- * Copyright (c) 2020 Temporal Technologies, Inc. All Rights Reserved
- *
- * Copyright 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
- * Modifications copyright (C) 2017 Uber Technologies, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"). You may not
- * use this file except in compliance with the License. A copy of the License is
- * located at
- *
- * http://aws.amazon.com/apache2.0
- *
- * or in the "license" file accompanying this file. This file is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
package io.temporal.samples.customchangeversion;
import io.temporal.activity.ActivityOptions;
diff --git a/core/src/main/java/io/temporal/samples/dsl/DslActivities.java b/core/src/main/java/io/temporal/samples/dsl/DslActivities.java
index dce8e8bae..0fb98f114 100644
--- a/core/src/main/java/io/temporal/samples/dsl/DslActivities.java
+++ b/core/src/main/java/io/temporal/samples/dsl/DslActivities.java
@@ -1,22 +1,3 @@
-/*
- * Copyright (c) 2020 Temporal Technologies, Inc. All Rights Reserved
- *
- * Copyright 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
- * Modifications copyright (C) 2017 Uber Technologies, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"). You may not
- * use this file except in compliance with the License. A copy of the License is
- * located at
- *
- * http://aws.amazon.com/apache2.0
- *
- * or in the "license" file accompanying this file. This file is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
package io.temporal.samples.dsl;
import io.temporal.activity.ActivityInterface;
diff --git a/core/src/main/java/io/temporal/samples/dsl/DslActivitiesImpl.java b/core/src/main/java/io/temporal/samples/dsl/DslActivitiesImpl.java
index 77aa5df06..d02116316 100644
--- a/core/src/main/java/io/temporal/samples/dsl/DslActivitiesImpl.java
+++ b/core/src/main/java/io/temporal/samples/dsl/DslActivitiesImpl.java
@@ -1,22 +1,3 @@
-/*
- * Copyright (c) 2020 Temporal Technologies, Inc. All Rights Reserved
- *
- * Copyright 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
- * Modifications copyright (C) 2017 Uber Technologies, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"). You may not
- * use this file except in compliance with the License. A copy of the License is
- * located at
- *
- * http://aws.amazon.com/apache2.0
- *
- * or in the "license" file accompanying this file. This file is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
package io.temporal.samples.dsl;
import java.util.concurrent.TimeUnit;
diff --git a/core/src/main/java/io/temporal/samples/dsl/DslWorkflow.java b/core/src/main/java/io/temporal/samples/dsl/DslWorkflow.java
index 9863a43db..22745b809 100644
--- a/core/src/main/java/io/temporal/samples/dsl/DslWorkflow.java
+++ b/core/src/main/java/io/temporal/samples/dsl/DslWorkflow.java
@@ -1,22 +1,3 @@
-/*
- * Copyright (c) 2020 Temporal Technologies, Inc. All Rights Reserved
- *
- * Copyright 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
- * Modifications copyright (C) 2017 Uber Technologies, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"). You may not
- * use this file except in compliance with the License. A copy of the License is
- * located at
- *
- * http://aws.amazon.com/apache2.0
- *
- * or in the "license" file accompanying this file. This file is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
package io.temporal.samples.dsl;
import io.temporal.samples.dsl.model.Flow;
diff --git a/core/src/main/java/io/temporal/samples/dsl/DslWorkflowImpl.java b/core/src/main/java/io/temporal/samples/dsl/DslWorkflowImpl.java
index e89d9c52e..db75fab37 100644
--- a/core/src/main/java/io/temporal/samples/dsl/DslWorkflowImpl.java
+++ b/core/src/main/java/io/temporal/samples/dsl/DslWorkflowImpl.java
@@ -1,22 +1,3 @@
-/*
- * Copyright (c) 2020 Temporal Technologies, Inc. All Rights Reserved
- *
- * Copyright 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
- * Modifications copyright (C) 2017 Uber Technologies, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"). You may not
- * use this file except in compliance with the License. A copy of the License is
- * located at
- *
- * http://aws.amazon.com/apache2.0
- *
- * or in the "license" file accompanying this file. This file is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
package io.temporal.samples.dsl;
import io.temporal.activity.ActivityOptions;
diff --git a/core/src/main/java/io/temporal/samples/dsl/Starter.java b/core/src/main/java/io/temporal/samples/dsl/Starter.java
index 47b2a5035..257531048 100644
--- a/core/src/main/java/io/temporal/samples/dsl/Starter.java
+++ b/core/src/main/java/io/temporal/samples/dsl/Starter.java
@@ -1,43 +1,31 @@
-/*
- * Copyright (c) 2020 Temporal Technologies, Inc. All Rights Reserved
- *
- * Copyright 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
- * Modifications copyright (C) 2017 Uber Technologies, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"). You may not
- * use this file except in compliance with the License. A copy of the License is
- * located at
- *
- * http://aws.amazon.com/apache2.0
- *
- * or in the "license" file accompanying this file. This file is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
package io.temporal.samples.dsl;
import com.fasterxml.jackson.databind.ObjectMapper;
import io.temporal.client.WorkflowClient;
import io.temporal.client.WorkflowOptions;
+import io.temporal.envconfig.ClientConfigProfile;
import io.temporal.samples.dsl.model.Flow;
import io.temporal.serviceclient.WorkflowServiceStubs;
import io.temporal.worker.Worker;
import io.temporal.worker.WorkerFactory;
+import java.io.IOException;
public class Starter {
- public static final WorkflowServiceStubs service = WorkflowServiceStubs.newLocalServiceStubs();
- public static final WorkflowClient client = WorkflowClient.newInstance(service);
- public static final WorkerFactory factory = WorkerFactory.newInstance(client);
-
public static void main(String[] args) {
Flow flow = getFlowFromResource();
- WorkflowServiceStubs service = WorkflowServiceStubs.newLocalServiceStubs();
- WorkflowClient client = WorkflowClient.newInstance(service);
+ // Load configuration from environment and files
+ ClientConfigProfile profile;
+ try {
+ profile = ClientConfigProfile.load();
+ } catch (IOException e) {
+ throw new RuntimeException("Failed to load client configuration", e);
+ }
+
+ WorkflowServiceStubs service =
+ WorkflowServiceStubs.newServiceStubs(profile.toWorkflowServiceStubsOptions());
+ WorkflowClient client = WorkflowClient.newInstance(service, profile.toWorkflowClientOptions());
WorkerFactory factory = WorkerFactory.newInstance(client);
Worker worker = factory.newWorker("dsl-task-queue");
worker.registerWorkflowImplementationTypes(DslWorkflowImpl.class);
diff --git a/core/src/main/java/io/temporal/samples/dsl/model/Flow.java b/core/src/main/java/io/temporal/samples/dsl/model/Flow.java
index 22e9d3254..a458c0124 100644
--- a/core/src/main/java/io/temporal/samples/dsl/model/Flow.java
+++ b/core/src/main/java/io/temporal/samples/dsl/model/Flow.java
@@ -1,22 +1,3 @@
-/*
- * Copyright (c) 2020 Temporal Technologies, Inc. All Rights Reserved
- *
- * Copyright 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
- * Modifications copyright (C) 2017 Uber Technologies, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"). You may not
- * use this file except in compliance with the License. A copy of the License is
- * located at
- *
- * http://aws.amazon.com/apache2.0
- *
- * or in the "license" file accompanying this file. This file is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
package io.temporal.samples.dsl.model;
import java.util.List;
diff --git a/core/src/main/java/io/temporal/samples/dsl/model/FlowAction.java b/core/src/main/java/io/temporal/samples/dsl/model/FlowAction.java
index f1f9a367c..c85bf8b6f 100644
--- a/core/src/main/java/io/temporal/samples/dsl/model/FlowAction.java
+++ b/core/src/main/java/io/temporal/samples/dsl/model/FlowAction.java
@@ -1,22 +1,3 @@
-/*
- * Copyright (c) 2020 Temporal Technologies, Inc. All Rights Reserved
- *
- * Copyright 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
- * Modifications copyright (C) 2017 Uber Technologies, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"). You may not
- * use this file except in compliance with the License. A copy of the License is
- * located at
- *
- * http://aws.amazon.com/apache2.0
- *
- * or in the "license" file accompanying this file. This file is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
package io.temporal.samples.dsl.model;
public class FlowAction {
diff --git a/core/src/main/java/io/temporal/samples/earlyreturn/EarlyReturnClient.java b/core/src/main/java/io/temporal/samples/earlyreturn/EarlyReturnClient.java
index 36da78d87..3abd20a7c 100644
--- a/core/src/main/java/io/temporal/samples/earlyreturn/EarlyReturnClient.java
+++ b/core/src/main/java/io/temporal/samples/earlyreturn/EarlyReturnClient.java
@@ -1,27 +1,10 @@
-/*
- * Copyright (c) 2020 Temporal Technologies, Inc. All Rights Reserved
- *
- * Copyright 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
- * Modifications copyright (C) 2017 Uber Technologies, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"). You may not
- * use this file except in compliance with the License. A copy of the License is
- * located at
- *
- * http://aws.amazon.com/apache2.0
- *
- * or in the "license" file accompanying this file. This file is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
package io.temporal.samples.earlyreturn;
import io.temporal.api.enums.v1.WorkflowIdConflictPolicy;
import io.temporal.client.*;
+import io.temporal.envconfig.ClientConfigProfile;
import io.temporal.serviceclient.WorkflowServiceStubs;
+import java.io.IOException;
public class EarlyReturnClient {
private static final String TASK_QUEUE = "EarlyReturnTaskQueue";
@@ -34,8 +17,17 @@ public static void main(String[] args) {
// Set up the WorkflowClient
public static WorkflowClient setupWorkflowClient() {
- WorkflowServiceStubs service = WorkflowServiceStubs.newLocalServiceStubs();
- return WorkflowClient.newInstance(service);
+ // Load configuration from environment and files
+ ClientConfigProfile profile;
+ try {
+ profile = ClientConfigProfile.load();
+ } catch (IOException e) {
+ throw new RuntimeException("Failed to load client configuration", e);
+ }
+
+ WorkflowServiceStubs service =
+ WorkflowServiceStubs.newServiceStubs(profile.toWorkflowServiceStubsOptions());
+ return WorkflowClient.newInstance(service, profile.toWorkflowClientOptions());
}
// Run workflow using 'updateWithStart'
diff --git a/core/src/main/java/io/temporal/samples/earlyreturn/EarlyReturnWorker.java b/core/src/main/java/io/temporal/samples/earlyreturn/EarlyReturnWorker.java
index 222368ec6..97ef9320a 100644
--- a/core/src/main/java/io/temporal/samples/earlyreturn/EarlyReturnWorker.java
+++ b/core/src/main/java/io/temporal/samples/earlyreturn/EarlyReturnWorker.java
@@ -1,22 +1,3 @@
-/*
- * Copyright (c) 2020 Temporal Technologies, Inc. All Rights Reserved
- *
- * Copyright 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
- * Modifications copyright (C) 2017 Uber Technologies, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"). You may not
- * use this file except in compliance with the License. A copy of the License is
- * located at
- *
- * http://aws.amazon.com/apache2.0
- *
- * or in the "license" file accompanying this file. This file is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
package io.temporal.samples.earlyreturn;
import io.temporal.client.WorkflowClient;
diff --git a/core/src/main/java/io/temporal/samples/earlyreturn/Transaction.java b/core/src/main/java/io/temporal/samples/earlyreturn/Transaction.java
index 0f910b4fd..a005c6808 100644
--- a/core/src/main/java/io/temporal/samples/earlyreturn/Transaction.java
+++ b/core/src/main/java/io/temporal/samples/earlyreturn/Transaction.java
@@ -1,22 +1,3 @@
-/*
- * Copyright (c) 2020 Temporal Technologies, Inc. All Rights Reserved
- *
- * Copyright 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
- * Modifications copyright (C) 2017 Uber Technologies, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"). You may not
- * use this file except in compliance with the License. A copy of the License is
- * located at
- *
- * http://aws.amazon.com/apache2.0
- *
- * or in the "license" file accompanying this file. This file is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
package io.temporal.samples.earlyreturn;
import com.fasterxml.jackson.annotation.JsonCreator;
diff --git a/core/src/main/java/io/temporal/samples/earlyreturn/TransactionActivities.java b/core/src/main/java/io/temporal/samples/earlyreturn/TransactionActivities.java
index 8f3e866f8..4b7f26997 100644
--- a/core/src/main/java/io/temporal/samples/earlyreturn/TransactionActivities.java
+++ b/core/src/main/java/io/temporal/samples/earlyreturn/TransactionActivities.java
@@ -1,22 +1,3 @@
-/*
- * Copyright (c) 2020 Temporal Technologies, Inc. All Rights Reserved
- *
- * Copyright 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
- * Modifications copyright (C) 2017 Uber Technologies, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"). You may not
- * use this file except in compliance with the License. A copy of the License is
- * located at
- *
- * http://aws.amazon.com/apache2.0
- *
- * or in the "license" file accompanying this file. This file is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
package io.temporal.samples.earlyreturn;
import io.temporal.activity.ActivityInterface;
diff --git a/core/src/main/java/io/temporal/samples/earlyreturn/TransactionActivitiesImpl.java b/core/src/main/java/io/temporal/samples/earlyreturn/TransactionActivitiesImpl.java
index 52dc61806..33c3d3435 100644
--- a/core/src/main/java/io/temporal/samples/earlyreturn/TransactionActivitiesImpl.java
+++ b/core/src/main/java/io/temporal/samples/earlyreturn/TransactionActivitiesImpl.java
@@ -1,22 +1,3 @@
-/*
- * Copyright (c) 2020 Temporal Technologies, Inc. All Rights Reserved
- *
- * Copyright 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
- * Modifications copyright (C) 2017 Uber Technologies, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"). You may not
- * use this file except in compliance with the License. A copy of the License is
- * located at
- *
- * http://aws.amazon.com/apache2.0
- *
- * or in the "license" file accompanying this file. This file is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
package io.temporal.samples.earlyreturn;
import io.temporal.failure.ApplicationFailure;
diff --git a/core/src/main/java/io/temporal/samples/earlyreturn/TransactionRequest.java b/core/src/main/java/io/temporal/samples/earlyreturn/TransactionRequest.java
index c174a63f8..5f01ae66e 100644
--- a/core/src/main/java/io/temporal/samples/earlyreturn/TransactionRequest.java
+++ b/core/src/main/java/io/temporal/samples/earlyreturn/TransactionRequest.java
@@ -1,22 +1,3 @@
-/*
- * Copyright (c) 2020 Temporal Technologies, Inc. All Rights Reserved
- *
- * Copyright 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
- * Modifications copyright (C) 2017 Uber Technologies, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"). You may not
- * use this file except in compliance with the License. A copy of the License is
- * located at
- *
- * http://aws.amazon.com/apache2.0
- *
- * or in the "license" file accompanying this file. This file is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
package io.temporal.samples.earlyreturn;
import com.fasterxml.jackson.annotation.JsonCreator;
diff --git a/core/src/main/java/io/temporal/samples/earlyreturn/TransactionWorkflow.java b/core/src/main/java/io/temporal/samples/earlyreturn/TransactionWorkflow.java
index 2d1ef6f5f..28d4f3321 100644
--- a/core/src/main/java/io/temporal/samples/earlyreturn/TransactionWorkflow.java
+++ b/core/src/main/java/io/temporal/samples/earlyreturn/TransactionWorkflow.java
@@ -1,22 +1,3 @@
-/*
- * Copyright (c) 2020 Temporal Technologies, Inc. All Rights Reserved
- *
- * Copyright 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
- * Modifications copyright (C) 2017 Uber Technologies, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"). You may not
- * use this file except in compliance with the License. A copy of the License is
- * located at
- *
- * http://aws.amazon.com/apache2.0
- *
- * or in the "license" file accompanying this file. This file is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
package io.temporal.samples.earlyreturn;
import io.temporal.workflow.UpdateMethod;
diff --git a/core/src/main/java/io/temporal/samples/earlyreturn/TransactionWorkflowImpl.java b/core/src/main/java/io/temporal/samples/earlyreturn/TransactionWorkflowImpl.java
index 8f7c86d34..9a162687b 100644
--- a/core/src/main/java/io/temporal/samples/earlyreturn/TransactionWorkflowImpl.java
+++ b/core/src/main/java/io/temporal/samples/earlyreturn/TransactionWorkflowImpl.java
@@ -1,22 +1,3 @@
-/*
- * Copyright (c) 2020 Temporal Technologies, Inc. All Rights Reserved
- *
- * Copyright 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
- * Modifications copyright (C) 2017 Uber Technologies, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"). You may not
- * use this file except in compliance with the License. A copy of the License is
- * located at
- *
- * http://aws.amazon.com/apache2.0
- *
- * or in the "license" file accompanying this file. This file is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
package io.temporal.samples.earlyreturn;
import io.temporal.activity.ActivityOptions;
diff --git a/core/src/main/java/io/temporal/samples/earlyreturn/TxResult.java b/core/src/main/java/io/temporal/samples/earlyreturn/TxResult.java
index 04c9a9862..6a815c62d 100644
--- a/core/src/main/java/io/temporal/samples/earlyreturn/TxResult.java
+++ b/core/src/main/java/io/temporal/samples/earlyreturn/TxResult.java
@@ -1,22 +1,3 @@
-/*
- * Copyright (c) 2020 Temporal Technologies, Inc. All Rights Reserved
- *
- * Copyright 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
- * Modifications copyright (C) 2017 Uber Technologies, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"). You may not
- * use this file except in compliance with the License. A copy of the License is
- * located at
- *
- * http://aws.amazon.com/apache2.0
- *
- * or in the "license" file accompanying this file. This file is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
package io.temporal.samples.earlyreturn;
import com.fasterxml.jackson.annotation.JsonCreator;
diff --git a/core/src/main/java/io/temporal/samples/encodefailures/CustomerAgeCheck.java b/core/src/main/java/io/temporal/samples/encodefailures/CustomerAgeCheck.java
index d302fc8fe..0b6ad7b25 100644
--- a/core/src/main/java/io/temporal/samples/encodefailures/CustomerAgeCheck.java
+++ b/core/src/main/java/io/temporal/samples/encodefailures/CustomerAgeCheck.java
@@ -1,22 +1,3 @@
-/*
- * Copyright (c) 2020 Temporal Technologies, Inc. All Rights Reserved
- *
- * Copyright 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
- * Modifications copyright (C) 2017 Uber Technologies, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"). You may not
- * use this file except in compliance with the License. A copy of the License is
- * located at
- *
- * http://aws.amazon.com/apache2.0
- *
- * or in the "license" file accompanying this file. This file is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
package io.temporal.samples.encodefailures;
import io.temporal.workflow.WorkflowInterface;
diff --git a/core/src/main/java/io/temporal/samples/encodefailures/CustomerAgeCheckImpl.java b/core/src/main/java/io/temporal/samples/encodefailures/CustomerAgeCheckImpl.java
index ab3571c5d..72eb1b689 100644
--- a/core/src/main/java/io/temporal/samples/encodefailures/CustomerAgeCheckImpl.java
+++ b/core/src/main/java/io/temporal/samples/encodefailures/CustomerAgeCheckImpl.java
@@ -1,22 +1,3 @@
-/*
- * Copyright (c) 2020 Temporal Technologies, Inc. All Rights Reserved
- *
- * Copyright 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
- * Modifications copyright (C) 2017 Uber Technologies, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"). You may not
- * use this file except in compliance with the License. A copy of the License is
- * located at
- *
- * http://aws.amazon.com/apache2.0
- *
- * or in the "license" file accompanying this file. This file is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
package io.temporal.samples.encodefailures;
import io.temporal.workflow.Workflow;
diff --git a/core/src/main/java/io/temporal/samples/encodefailures/InvalidCustomerException.java b/core/src/main/java/io/temporal/samples/encodefailures/InvalidCustomerException.java
index d8eefbdd5..20ad3a2ce 100644
--- a/core/src/main/java/io/temporal/samples/encodefailures/InvalidCustomerException.java
+++ b/core/src/main/java/io/temporal/samples/encodefailures/InvalidCustomerException.java
@@ -1,22 +1,3 @@
-/*
- * Copyright (c) 2020 Temporal Technologies, Inc. All Rights Reserved
- *
- * Copyright 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
- * Modifications copyright (C) 2017 Uber Technologies, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"). You may not
- * use this file except in compliance with the License. A copy of the License is
- * located at
- *
- * http://aws.amazon.com/apache2.0
- *
- * or in the "license" file accompanying this file. This file is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
package io.temporal.samples.encodefailures;
public class InvalidCustomerException extends Exception {
diff --git a/core/src/main/java/io/temporal/samples/encodefailures/MyCustomer.java b/core/src/main/java/io/temporal/samples/encodefailures/MyCustomer.java
index 30a6def44..a61503c77 100644
--- a/core/src/main/java/io/temporal/samples/encodefailures/MyCustomer.java
+++ b/core/src/main/java/io/temporal/samples/encodefailures/MyCustomer.java
@@ -1,22 +1,3 @@
-/*
- * Copyright (c) 2020 Temporal Technologies, Inc. All Rights Reserved
- *
- * Copyright 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
- * Modifications copyright (C) 2017 Uber Technologies, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"). You may not
- * use this file except in compliance with the License. A copy of the License is
- * located at
- *
- * http://aws.amazon.com/apache2.0
- *
- * or in the "license" file accompanying this file. This file is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
package io.temporal.samples.encodefailures;
public class MyCustomer {
diff --git a/core/src/main/java/io/temporal/samples/encodefailures/SimplePrefixPayloadCodec.java b/core/src/main/java/io/temporal/samples/encodefailures/SimplePrefixPayloadCodec.java
index a25bccef4..7c5984e23 100644
--- a/core/src/main/java/io/temporal/samples/encodefailures/SimplePrefixPayloadCodec.java
+++ b/core/src/main/java/io/temporal/samples/encodefailures/SimplePrefixPayloadCodec.java
@@ -1,22 +1,3 @@
-/*
- * Copyright (c) 2020 Temporal Technologies, Inc. All Rights Reserved
- *
- * Copyright 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
- * Modifications copyright (C) 2017 Uber Technologies, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"). You may not
- * use this file except in compliance with the License. A copy of the License is
- * located at
- *
- * http://aws.amazon.com/apache2.0
- *
- * or in the "license" file accompanying this file. This file is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
package io.temporal.samples.encodefailures;
import com.google.protobuf.ByteString;
diff --git a/core/src/main/java/io/temporal/samples/encodefailures/Starter.java b/core/src/main/java/io/temporal/samples/encodefailures/Starter.java
index 5bdd35888..f08766881 100644
--- a/core/src/main/java/io/temporal/samples/encodefailures/Starter.java
+++ b/core/src/main/java/io/temporal/samples/encodefailures/Starter.java
@@ -1,22 +1,3 @@
-/*
- * Copyright (c) 2020 Temporal Technologies, Inc. All Rights Reserved
- *
- * Copyright 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
- * Modifications copyright (C) 2017 Uber Technologies, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"). You may not
- * use this file except in compliance with the License. A copy of the License is
- * located at
- *
- * http://aws.amazon.com/apache2.0
- *
- * or in the "license" file accompanying this file. This file is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
package io.temporal.samples.encodefailures;
import io.temporal.api.common.v1.Payload;
@@ -27,10 +8,12 @@
import io.temporal.client.WorkflowOptions;
import io.temporal.common.converter.CodecDataConverter;
import io.temporal.common.converter.DefaultDataConverter;
+import io.temporal.envconfig.ClientConfigProfile;
import io.temporal.serviceclient.WorkflowServiceStubs;
import io.temporal.worker.Worker;
import io.temporal.worker.WorkerFactory;
import io.temporal.worker.WorkflowImplementationOptions;
+import java.io.IOException;
import java.util.Collections;
public class Starter {
@@ -38,7 +21,16 @@ public class Starter {
private static final String WORKFLOW_ID = "CustomerValidationWorkflow";
public static void main(String[] args) {
- WorkflowServiceStubs service = WorkflowServiceStubs.newLocalServiceStubs();
+ // Load configuration from environment and files
+ ClientConfigProfile profile;
+ try {
+ profile = ClientConfigProfile.load();
+ } catch (IOException e) {
+ throw new RuntimeException("Failed to load client configuration", e);
+ }
+
+ WorkflowServiceStubs service =
+ WorkflowServiceStubs.newServiceStubs(profile.toWorkflowServiceStubsOptions());
// CodecDataConverter defines our data converter and codec
// sets encodeFailureAttributes to true
diff --git a/core/src/main/java/io/temporal/samples/encryptedpayloads/CryptCodec.java b/core/src/main/java/io/temporal/samples/encryptedpayloads/CryptCodec.java
index e8fc71c7a..96f445a46 100644
--- a/core/src/main/java/io/temporal/samples/encryptedpayloads/CryptCodec.java
+++ b/core/src/main/java/io/temporal/samples/encryptedpayloads/CryptCodec.java
@@ -1,22 +1,3 @@
-/*
- * Copyright (c) 2020 Temporal Technologies, Inc. All Rights Reserved
- *
- * Copyright 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
- * Modifications copyright (C) 2017 Uber Technologies, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"). You may not
- * use this file except in compliance with the License. A copy of the License is
- * located at
- *
- * http://aws.amazon.com/apache2.0
- *
- * or in the "license" file accompanying this file. This file is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
package io.temporal.samples.encryptedpayloads;
import com.google.protobuf.ByteString;
diff --git a/core/src/main/java/io/temporal/samples/encryptedpayloads/EncryptedPayloadsActivity.java b/core/src/main/java/io/temporal/samples/encryptedpayloads/EncryptedPayloadsActivity.java
index 88c8a1d78..83f10d95c 100644
--- a/core/src/main/java/io/temporal/samples/encryptedpayloads/EncryptedPayloadsActivity.java
+++ b/core/src/main/java/io/temporal/samples/encryptedpayloads/EncryptedPayloadsActivity.java
@@ -1,22 +1,3 @@
-/*
- * Copyright (c) 2020 Temporal Technologies, Inc. All Rights Reserved
- *
- * Copyright 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
- * Modifications copyright (C) 2017 Uber Technologies, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"). You may not
- * use this file except in compliance with the License. A copy of the License is
- * located at
- *
- * http://aws.amazon.com/apache2.0
- *
- * or in the "license" file accompanying this file. This file is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
package io.temporal.samples.encryptedpayloads;
import io.temporal.activity.ActivityInterface;
@@ -27,12 +8,14 @@
import io.temporal.client.WorkflowOptions;
import io.temporal.common.converter.CodecDataConverter;
import io.temporal.common.converter.DefaultDataConverter;
+import io.temporal.envconfig.ClientConfigProfile;
import io.temporal.serviceclient.WorkflowServiceStubs;
import io.temporal.worker.Worker;
import io.temporal.worker.WorkerFactory;
import io.temporal.workflow.Workflow;
import io.temporal.workflow.WorkflowInterface;
import io.temporal.workflow.WorkflowMethod;
+import java.io.IOException;
import java.time.Duration;
import java.util.Collections;
@@ -87,7 +70,16 @@ public String composeGreeting(String greeting, String name) {
public static void main(String[] args) {
// gRPC stubs wrapper that talks to the local docker instance of temporal service.
- WorkflowServiceStubs service = WorkflowServiceStubs.newLocalServiceStubs();
+ // Load configuration from environment and files
+ ClientConfigProfile profile;
+ try {
+ profile = ClientConfigProfile.load();
+ } catch (IOException e) {
+ throw new RuntimeException("Failed to load client configuration", e);
+ }
+
+ WorkflowServiceStubs service =
+ WorkflowServiceStubs.newServiceStubs(profile.toWorkflowServiceStubsOptions());
// client that can be used to start and signal workflows
WorkflowClient client =
WorkflowClient.newInstance(
diff --git a/core/src/main/java/io/temporal/samples/envconfig/LoadFromFile.java b/core/src/main/java/io/temporal/samples/envconfig/LoadFromFile.java
new file mode 100644
index 000000000..cee9df5a5
--- /dev/null
+++ b/core/src/main/java/io/temporal/samples/envconfig/LoadFromFile.java
@@ -0,0 +1,81 @@
+package io.temporal.samples.envconfig;
+
+// @@@SNIPSTART java-env-config-profile
+import io.temporal.client.WorkflowClient;
+import io.temporal.client.WorkflowClientOptions;
+import io.temporal.envconfig.ClientConfigProfile;
+import io.temporal.envconfig.LoadClientConfigProfileOptions;
+import io.temporal.serviceclient.WorkflowServiceStubs;
+import io.temporal.serviceclient.WorkflowServiceStubsOptions;
+import java.nio.file.Paths;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * This sample demonstrates loading the default environment configuration profile from a TOML file.
+ */
+public class LoadFromFile {
+
+ private static final Logger logger = LoggerFactory.getLogger(LoadFromFile.class);
+
+ public static void main(String[] args) {
+ try {
+ // For this sample to be self-contained, we explicitly provide the path to
+ // the config.toml file included in this directory.
+ // By default though, the config.toml file will be loaded from
+ // ~/.config/temporal/temporal.toml (or the equivalent standard config directory on your OS).
+ String configFilePath =
+ Paths.get(LoadFromFile.class.getResource("/config.toml").toURI()).toString();
+
+ logger.info("--- Loading 'default' profile from {} ---", configFilePath);
+
+ // Load client profile from file. By default, this loads the "default" profile
+ // and applies any environment variable overrides.
+ ClientConfigProfile profile =
+ ClientConfigProfile.load(
+ LoadClientConfigProfileOptions.newBuilder()
+ .setConfigFilePath(configFilePath)
+ .build());
+
+ // Convert profile to client options (equivalent to Python's load_client_connect_config)
+ WorkflowServiceStubsOptions serviceStubsOptions = profile.toWorkflowServiceStubsOptions();
+ WorkflowClientOptions clientOptions = profile.toWorkflowClientOptions();
+
+ logger.info("Loaded 'default' profile from {}", configFilePath);
+ logger.info(" Address: {}", serviceStubsOptions.getTarget());
+ logger.info(" Namespace: {}", clientOptions.getNamespace());
+ if (serviceStubsOptions.getHeaders() != null
+ && !serviceStubsOptions.getHeaders().keys().isEmpty()) {
+ logger.info(" gRPC Metadata keys: {}", serviceStubsOptions.getHeaders().keys());
+ }
+
+ logger.info("\nAttempting to connect to client...");
+
+ try {
+ // Create the workflow client using the loaded configuration
+ WorkflowClient client =
+ WorkflowClient.newInstance(
+ WorkflowServiceStubs.newServiceStubs(serviceStubsOptions), clientOptions);
+
+ // Test the connection by getting system info
+ var systemInfo =
+ client
+ .getWorkflowServiceStubs()
+ .blockingStub()
+ .getSystemInfo(
+ io.temporal.api.workflowservice.v1.GetSystemInfoRequest.getDefaultInstance());
+
+ logger.info("✅ Client connected successfully!");
+ logger.info(" Server version: {}", systemInfo.getServerVersion());
+
+ } catch (Exception e) {
+ logger.error("❌ Failed to connect: {}", e.getMessage());
+ }
+
+ } catch (Exception e) {
+ logger.error("Failed to load configuration: {}", e.getMessage(), e);
+ System.exit(1);
+ }
+ }
+}
+// @@@SNIPEND
diff --git a/core/src/main/java/io/temporal/samples/envconfig/LoadProfile.java b/core/src/main/java/io/temporal/samples/envconfig/LoadProfile.java
new file mode 100644
index 000000000..20270e1f0
--- /dev/null
+++ b/core/src/main/java/io/temporal/samples/envconfig/LoadProfile.java
@@ -0,0 +1,89 @@
+package io.temporal.samples.envconfig;
+
+// @@@SNIPSTART java-env-config-profile-with-overrides
+import io.temporal.client.WorkflowClient;
+import io.temporal.client.WorkflowClientOptions;
+import io.temporal.envconfig.ClientConfigProfile;
+import io.temporal.envconfig.LoadClientConfigProfileOptions;
+import io.temporal.serviceclient.WorkflowServiceStubs;
+import io.temporal.serviceclient.WorkflowServiceStubsOptions;
+import java.nio.file.Paths;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * This sample demonstrates loading a specific profile from a TOML configuration file with
+ * programmatic overrides.
+ */
+public class LoadProfile {
+
+ private static final Logger logger = LoggerFactory.getLogger(LoadProfile.class);
+
+ public static void main(String[] args) {
+ String profileName = "staging";
+
+ try {
+ // For this sample to be self-contained, we explicitly provide the path to
+ // the config.toml file included in this directory.
+ String configFilePath =
+ Paths.get(LoadProfile.class.getResource("/config.toml").toURI()).toString();
+
+ logger.info("--- Loading '{}' profile from {} ---", profileName, configFilePath);
+
+ // Load specific profile from file with environment variable overrides
+ ClientConfigProfile profile =
+ ClientConfigProfile.load(
+ LoadClientConfigProfileOptions.newBuilder()
+ .setConfigFilePath(configFilePath)
+ .setConfigFileProfile(profileName)
+ .build());
+
+ // Demonstrate programmatic override - fix the incorrect address from staging profile
+ logger.info("\n--- Applying programmatic override ---");
+ ClientConfigProfile.Builder profileBuilder = profile.toBuilder();
+ profileBuilder.setAddress("localhost:7233"); // Override the incorrect address
+ profile = profileBuilder.build();
+ logger.info(" Overridden address to: {}", profile.getAddress());
+
+ // Convert profile to client options (equivalent to Python's load_client_connect_config)
+ WorkflowServiceStubsOptions serviceStubsOptions = profile.toWorkflowServiceStubsOptions();
+ WorkflowClientOptions clientOptions = profile.toWorkflowClientOptions();
+
+ logger.info("Loaded '{}' profile from {}", profileName, configFilePath);
+ logger.info(" Address: {}", serviceStubsOptions.getTarget());
+ logger.info(" Namespace: {}", clientOptions.getNamespace());
+ if (serviceStubsOptions.getHeaders() != null
+ && !serviceStubsOptions.getHeaders().keys().isEmpty()) {
+ logger.info(" gRPC Metadata keys: {}", serviceStubsOptions.getHeaders().keys());
+ }
+
+ logger.info("\nAttempting to connect to client...");
+
+ try {
+ // Create the workflow client using the loaded configuration
+ WorkflowClient client =
+ WorkflowClient.newInstance(
+ WorkflowServiceStubs.newServiceStubs(serviceStubsOptions), clientOptions);
+
+ // Test the connection by getting system info
+ var systemInfo =
+ client
+ .getWorkflowServiceStubs()
+ .blockingStub()
+ .getSystemInfo(
+ io.temporal.api.workflowservice.v1.GetSystemInfoRequest.getDefaultInstance());
+
+ logger.info("✅ Client connected successfully!");
+ logger.info(" Server version: {}", systemInfo.getServerVersion());
+
+ } catch (Exception e) {
+ logger.error("❌ Failed to connect: {}", e.getMessage());
+ }
+
+ } catch (Exception e) {
+ logger.error("Failed to load configuration: {}", e.getMessage(), e);
+ System.exit(1);
+ }
+ }
+}
+// @@@SNIPEND
diff --git a/core/src/main/java/io/temporal/samples/envconfig/README.md b/core/src/main/java/io/temporal/samples/envconfig/README.md
new file mode 100644
index 000000000..0cb5df5c1
--- /dev/null
+++ b/core/src/main/java/io/temporal/samples/envconfig/README.md
@@ -0,0 +1,18 @@
+# Environment Configuration Sample
+
+This sample demonstrates how to configure a Temporal client using TOML configuration files. This allows you to manage connection settings across different environments without hardcoding them.
+
+The `config.toml` file defines three profiles:
+- `[profile.default]`: Local development configuration
+- `[profile.staging]`: Configuration with incorrect address to demonstrate overrides
+- `[profile.prod]`: Example production configuration (not runnable)
+
+**Load from file (default profile):**
+```bash
+./gradlew -q execute -PmainClass=io.temporal.samples.envconfig.LoadFromFile
+```
+
+**Load specific profile with overrides:**
+```bash
+./gradlew -q execute -PmainClass=io.temporal.samples.envconfig.LoadProfile
+```
\ No newline at end of file
diff --git a/core/src/main/java/io/temporal/samples/excludefrominterceptor/RunMyWorkflows.java b/core/src/main/java/io/temporal/samples/excludefrominterceptor/RunMyWorkflows.java
index 164b4972d..4efe7d1f6 100644
--- a/core/src/main/java/io/temporal/samples/excludefrominterceptor/RunMyWorkflows.java
+++ b/core/src/main/java/io/temporal/samples/excludefrominterceptor/RunMyWorkflows.java
@@ -1,27 +1,9 @@
-/*
- * Copyright (c) 2020 Temporal Technologies, Inc. All Rights Reserved
- *
- * Copyright 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
- * Modifications copyright (C) 2017 Uber Technologies, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"). You may not
- * use this file except in compliance with the License. A copy of the License is
- * located at
- *
- * http://aws.amazon.com/apache2.0
- *
- * or in the "license" file accompanying this file. This file is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
package io.temporal.samples.excludefrominterceptor;
import io.temporal.client.WorkflowClient;
import io.temporal.client.WorkflowOptions;
import io.temporal.client.WorkflowStub;
+import io.temporal.envconfig.ClientConfigProfile;
import io.temporal.samples.excludefrominterceptor.activities.ForInterceptorActivitiesImpl;
import io.temporal.samples.excludefrominterceptor.activities.MyActivitiesImpl;
import io.temporal.samples.excludefrominterceptor.interceptor.MyWorkerInterceptor;
@@ -30,13 +12,23 @@
import io.temporal.worker.Worker;
import io.temporal.worker.WorkerFactory;
import io.temporal.worker.WorkerFactoryOptions;
+import java.io.IOException;
import java.util.Arrays;
import java.util.concurrent.CompletableFuture;
public class RunMyWorkflows {
public static void main(String[] args) {
- WorkflowServiceStubs service = WorkflowServiceStubs.newLocalServiceStubs();
- WorkflowClient client = WorkflowClient.newInstance(service);
+ // Load configuration from environment and files
+ ClientConfigProfile profile;
+ try {
+ profile = ClientConfigProfile.load();
+ } catch (IOException e) {
+ throw new RuntimeException("Failed to load client configuration", e);
+ }
+
+ WorkflowServiceStubs service =
+ WorkflowServiceStubs.newServiceStubs(profile.toWorkflowServiceStubsOptions());
+ WorkflowClient client = WorkflowClient.newInstance(service, profile.toWorkflowClientOptions());
WorkerFactoryOptions wfo =
WorkerFactoryOptions.newBuilder()
diff --git a/core/src/main/java/io/temporal/samples/excludefrominterceptor/activities/ForInterceptorActivities.java b/core/src/main/java/io/temporal/samples/excludefrominterceptor/activities/ForInterceptorActivities.java
index 118cd7279..dd3a3f0d2 100644
--- a/core/src/main/java/io/temporal/samples/excludefrominterceptor/activities/ForInterceptorActivities.java
+++ b/core/src/main/java/io/temporal/samples/excludefrominterceptor/activities/ForInterceptorActivities.java
@@ -1,22 +1,3 @@
-/*
- * Copyright (c) 2020 Temporal Technologies, Inc. All Rights Reserved
- *
- * Copyright 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
- * Modifications copyright (C) 2017 Uber Technologies, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"). You may not
- * use this file except in compliance with the License. A copy of the License is
- * located at
- *
- * http://aws.amazon.com/apache2.0
- *
- * or in the "license" file accompanying this file. This file is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
package io.temporal.samples.excludefrominterceptor.activities;
import io.temporal.activity.ActivityInterface;
diff --git a/core/src/main/java/io/temporal/samples/excludefrominterceptor/activities/ForInterceptorActivitiesImpl.java b/core/src/main/java/io/temporal/samples/excludefrominterceptor/activities/ForInterceptorActivitiesImpl.java
index 1d5fc7025..d00fd5d71 100644
--- a/core/src/main/java/io/temporal/samples/excludefrominterceptor/activities/ForInterceptorActivitiesImpl.java
+++ b/core/src/main/java/io/temporal/samples/excludefrominterceptor/activities/ForInterceptorActivitiesImpl.java
@@ -1,22 +1,3 @@
-/*
- * Copyright (c) 2020 Temporal Technologies, Inc. All Rights Reserved
- *
- * Copyright 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
- * Modifications copyright (C) 2017 Uber Technologies, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"). You may not
- * use this file except in compliance with the License. A copy of the License is
- * located at
- *
- * http://aws.amazon.com/apache2.0
- *
- * or in the "license" file accompanying this file. This file is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
package io.temporal.samples.excludefrominterceptor.activities;
public class ForInterceptorActivitiesImpl implements ForInterceptorActivities {
diff --git a/core/src/main/java/io/temporal/samples/excludefrominterceptor/activities/MyActivities.java b/core/src/main/java/io/temporal/samples/excludefrominterceptor/activities/MyActivities.java
index 106916fc8..94d090a67 100644
--- a/core/src/main/java/io/temporal/samples/excludefrominterceptor/activities/MyActivities.java
+++ b/core/src/main/java/io/temporal/samples/excludefrominterceptor/activities/MyActivities.java
@@ -1,22 +1,3 @@
-/*
- * Copyright (c) 2020 Temporal Technologies, Inc. All Rights Reserved
- *
- * Copyright 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
- * Modifications copyright (C) 2017 Uber Technologies, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"). You may not
- * use this file except in compliance with the License. A copy of the License is
- * located at
- *
- * http://aws.amazon.com/apache2.0
- *
- * or in the "license" file accompanying this file. This file is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
package io.temporal.samples.excludefrominterceptor.activities;
import io.temporal.activity.ActivityInterface;
diff --git a/core/src/main/java/io/temporal/samples/excludefrominterceptor/activities/MyActivitiesImpl.java b/core/src/main/java/io/temporal/samples/excludefrominterceptor/activities/MyActivitiesImpl.java
index 48fe29a86..cfa787d0d 100644
--- a/core/src/main/java/io/temporal/samples/excludefrominterceptor/activities/MyActivitiesImpl.java
+++ b/core/src/main/java/io/temporal/samples/excludefrominterceptor/activities/MyActivitiesImpl.java
@@ -1,22 +1,3 @@
-/*
- * Copyright (c) 2020 Temporal Technologies, Inc. All Rights Reserved
- *
- * Copyright 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
- * Modifications copyright (C) 2017 Uber Technologies, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"). You may not
- * use this file except in compliance with the License. A copy of the License is
- * located at
- *
- * http://aws.amazon.com/apache2.0
- *
- * or in the "license" file accompanying this file. This file is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
package io.temporal.samples.excludefrominterceptor.activities;
public class MyActivitiesImpl implements MyActivities {
diff --git a/core/src/main/java/io/temporal/samples/excludefrominterceptor/interceptor/MyActivityInboundCallsInterceptor.java b/core/src/main/java/io/temporal/samples/excludefrominterceptor/interceptor/MyActivityInboundCallsInterceptor.java
index 69c79429a..91058012b 100644
--- a/core/src/main/java/io/temporal/samples/excludefrominterceptor/interceptor/MyActivityInboundCallsInterceptor.java
+++ b/core/src/main/java/io/temporal/samples/excludefrominterceptor/interceptor/MyActivityInboundCallsInterceptor.java
@@ -1,22 +1,3 @@
-/*
- * Copyright (c) 2020 Temporal Technologies, Inc. All Rights Reserved
- *
- * Copyright 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
- * Modifications copyright (C) 2017 Uber Technologies, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"). You may not
- * use this file except in compliance with the License. A copy of the License is
- * located at
- *
- * http://aws.amazon.com/apache2.0
- *
- * or in the "license" file accompanying this file. This file is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
package io.temporal.samples.excludefrominterceptor.interceptor;
import io.temporal.activity.ActivityExecutionContext;
diff --git a/core/src/main/java/io/temporal/samples/excludefrominterceptor/interceptor/MyWorkerInterceptor.java b/core/src/main/java/io/temporal/samples/excludefrominterceptor/interceptor/MyWorkerInterceptor.java
index 761f39b70..a52e17c2d 100644
--- a/core/src/main/java/io/temporal/samples/excludefrominterceptor/interceptor/MyWorkerInterceptor.java
+++ b/core/src/main/java/io/temporal/samples/excludefrominterceptor/interceptor/MyWorkerInterceptor.java
@@ -1,22 +1,3 @@
-/*
- * Copyright (c) 2020 Temporal Technologies, Inc. All Rights Reserved
- *
- * Copyright 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
- * Modifications copyright (C) 2017 Uber Technologies, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"). You may not
- * use this file except in compliance with the License. A copy of the License is
- * located at
- *
- * http://aws.amazon.com/apache2.0
- *
- * or in the "license" file accompanying this file. This file is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
package io.temporal.samples.excludefrominterceptor.interceptor;
import io.temporal.common.interceptors.*;
diff --git a/core/src/main/java/io/temporal/samples/excludefrominterceptor/interceptor/MyWorkflowInboundCallsInterceptor.java b/core/src/main/java/io/temporal/samples/excludefrominterceptor/interceptor/MyWorkflowInboundCallsInterceptor.java
index 023a098bf..7c3bc47e6 100644
--- a/core/src/main/java/io/temporal/samples/excludefrominterceptor/interceptor/MyWorkflowInboundCallsInterceptor.java
+++ b/core/src/main/java/io/temporal/samples/excludefrominterceptor/interceptor/MyWorkflowInboundCallsInterceptor.java
@@ -1,22 +1,3 @@
-/*
- * Copyright (c) 2020 Temporal Technologies, Inc. All Rights Reserved
- *
- * Copyright 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
- * Modifications copyright (C) 2017 Uber Technologies, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"). You may not
- * use this file except in compliance with the License. A copy of the License is
- * located at
- *
- * http://aws.amazon.com/apache2.0
- *
- * or in the "license" file accompanying this file. This file is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
package io.temporal.samples.excludefrominterceptor.interceptor;
import io.temporal.activity.ActivityOptions;
diff --git a/core/src/main/java/io/temporal/samples/excludefrominterceptor/interceptor/MyWorkflowOutboundCallsInterceptor.java b/core/src/main/java/io/temporal/samples/excludefrominterceptor/interceptor/MyWorkflowOutboundCallsInterceptor.java
index 9d99acb8a..bca1503b3 100644
--- a/core/src/main/java/io/temporal/samples/excludefrominterceptor/interceptor/MyWorkflowOutboundCallsInterceptor.java
+++ b/core/src/main/java/io/temporal/samples/excludefrominterceptor/interceptor/MyWorkflowOutboundCallsInterceptor.java
@@ -1,22 +1,3 @@
-/*
- * Copyright (c) 2020 Temporal Technologies, Inc. All Rights Reserved
- *
- * Copyright 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
- * Modifications copyright (C) 2017 Uber Technologies, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"). You may not
- * use this file except in compliance with the License. A copy of the License is
- * located at
- *
- * http://aws.amazon.com/apache2.0
- *
- * or in the "license" file accompanying this file. This file is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
package io.temporal.samples.excludefrominterceptor.interceptor;
import io.temporal.activity.ActivityOptions;
diff --git a/core/src/main/java/io/temporal/samples/excludefrominterceptor/workflows/MyWorkflow.java b/core/src/main/java/io/temporal/samples/excludefrominterceptor/workflows/MyWorkflow.java
index 6c334f97a..f0eeff451 100644
--- a/core/src/main/java/io/temporal/samples/excludefrominterceptor/workflows/MyWorkflow.java
+++ b/core/src/main/java/io/temporal/samples/excludefrominterceptor/workflows/MyWorkflow.java
@@ -1,22 +1,3 @@
-/*
- * Copyright (c) 2020 Temporal Technologies, Inc. All Rights Reserved
- *
- * Copyright 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
- * Modifications copyright (C) 2017 Uber Technologies, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"). You may not
- * use this file except in compliance with the License. A copy of the License is
- * located at
- *
- * http://aws.amazon.com/apache2.0
- *
- * or in the "license" file accompanying this file. This file is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
package io.temporal.samples.excludefrominterceptor.workflows;
import io.temporal.workflow.WorkflowMethod;
diff --git a/core/src/main/java/io/temporal/samples/excludefrominterceptor/workflows/MyWorkflowOne.java b/core/src/main/java/io/temporal/samples/excludefrominterceptor/workflows/MyWorkflowOne.java
index d7be4d3d0..acc5c4379 100644
--- a/core/src/main/java/io/temporal/samples/excludefrominterceptor/workflows/MyWorkflowOne.java
+++ b/core/src/main/java/io/temporal/samples/excludefrominterceptor/workflows/MyWorkflowOne.java
@@ -1,22 +1,3 @@
-/*
- * Copyright (c) 2020 Temporal Technologies, Inc. All Rights Reserved
- *
- * Copyright 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
- * Modifications copyright (C) 2017 Uber Technologies, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"). You may not
- * use this file except in compliance with the License. A copy of the License is
- * located at
- *
- * http://aws.amazon.com/apache2.0
- *
- * or in the "license" file accompanying this file. This file is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
package io.temporal.samples.excludefrominterceptor.workflows;
import io.temporal.workflow.WorkflowInterface;
diff --git a/core/src/main/java/io/temporal/samples/excludefrominterceptor/workflows/MyWorkflowOneImpl.java b/core/src/main/java/io/temporal/samples/excludefrominterceptor/workflows/MyWorkflowOneImpl.java
index 1409bce40..f4d7960dc 100644
--- a/core/src/main/java/io/temporal/samples/excludefrominterceptor/workflows/MyWorkflowOneImpl.java
+++ b/core/src/main/java/io/temporal/samples/excludefrominterceptor/workflows/MyWorkflowOneImpl.java
@@ -1,22 +1,3 @@
-/*
- * Copyright (c) 2020 Temporal Technologies, Inc. All Rights Reserved
- *
- * Copyright 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
- * Modifications copyright (C) 2017 Uber Technologies, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"). You may not
- * use this file except in compliance with the License. A copy of the License is
- * located at
- *
- * http://aws.amazon.com/apache2.0
- *
- * or in the "license" file accompanying this file. This file is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
package io.temporal.samples.excludefrominterceptor.workflows;
import io.temporal.activity.ActivityOptions;
diff --git a/core/src/main/java/io/temporal/samples/excludefrominterceptor/workflows/MyWorkflowTwo.java b/core/src/main/java/io/temporal/samples/excludefrominterceptor/workflows/MyWorkflowTwo.java
index 07d6b8dc6..4acb44493 100644
--- a/core/src/main/java/io/temporal/samples/excludefrominterceptor/workflows/MyWorkflowTwo.java
+++ b/core/src/main/java/io/temporal/samples/excludefrominterceptor/workflows/MyWorkflowTwo.java
@@ -1,22 +1,3 @@
-/*
- * Copyright (c) 2020 Temporal Technologies, Inc. All Rights Reserved
- *
- * Copyright 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
- * Modifications copyright (C) 2017 Uber Technologies, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"). You may not
- * use this file except in compliance with the License. A copy of the License is
- * located at
- *
- * http://aws.amazon.com/apache2.0
- *
- * or in the "license" file accompanying this file. This file is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
package io.temporal.samples.excludefrominterceptor.workflows;
import io.temporal.workflow.WorkflowInterface;
diff --git a/core/src/main/java/io/temporal/samples/excludefrominterceptor/workflows/MyWorkflowTwoImpl.java b/core/src/main/java/io/temporal/samples/excludefrominterceptor/workflows/MyWorkflowTwoImpl.java
index e4b012b99..a976353b3 100644
--- a/core/src/main/java/io/temporal/samples/excludefrominterceptor/workflows/MyWorkflowTwoImpl.java
+++ b/core/src/main/java/io/temporal/samples/excludefrominterceptor/workflows/MyWorkflowTwoImpl.java
@@ -1,22 +1,3 @@
-/*
- * Copyright (c) 2020 Temporal Technologies, Inc. All Rights Reserved
- *
- * Copyright 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
- * Modifications copyright (C) 2017 Uber Technologies, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"). You may not
- * use this file except in compliance with the License. A copy of the License is
- * located at
- *
- * http://aws.amazon.com/apache2.0
- *
- * or in the "license" file accompanying this file. This file is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
package io.temporal.samples.excludefrominterceptor.workflows;
import io.temporal.activity.ActivityOptions;
diff --git a/core/src/main/java/io/temporal/samples/fileprocessing/FileProcessingStarter.java b/core/src/main/java/io/temporal/samples/fileprocessing/FileProcessingStarter.java
index aa1f370ee..5020bf519 100644
--- a/core/src/main/java/io/temporal/samples/fileprocessing/FileProcessingStarter.java
+++ b/core/src/main/java/io/temporal/samples/fileprocessing/FileProcessingStarter.java
@@ -1,39 +1,31 @@
-/*
- * Copyright (c) 2020 Temporal Technologies, Inc. All Rights Reserved
- *
- * Copyright 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
- * Modifications copyright (C) 2017 Uber Technologies, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"). You may not
- * use this file except in compliance with the License. A copy of the License is
- * located at
- *
- * http://aws.amazon.com/apache2.0
- *
- * or in the "license" file accompanying this file. This file is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
package io.temporal.samples.fileprocessing;
import static io.temporal.samples.fileprocessing.FileProcessingWorker.TASK_QUEUE;
import io.temporal.client.WorkflowClient;
import io.temporal.client.WorkflowOptions;
+import io.temporal.envconfig.ClientConfigProfile;
import io.temporal.serviceclient.WorkflowServiceStubs;
+import java.io.IOException;
import java.net.URL;
/** Starts a file processing sample workflow. */
public class FileProcessingStarter {
public static void main(String[] args) throws Exception {
- // gRPC stubs wrapper that talks to the local docker instance of temporal service.
- WorkflowServiceStubs service = WorkflowServiceStubs.newLocalServiceStubs();
+ // Load configuration from environment and files
+ ClientConfigProfile profile;
+ try {
+ profile = ClientConfigProfile.load();
+ } catch (IOException e) {
+ throw new RuntimeException("Failed to load client configuration", e);
+ }
+
+ // gRPC stubs wrapper that talks to the temporal service.
+ WorkflowServiceStubs service =
+ WorkflowServiceStubs.newServiceStubs(profile.toWorkflowServiceStubsOptions());
// client that can be used to start and signal workflows
- WorkflowClient client = WorkflowClient.newInstance(service);
+ WorkflowClient client = WorkflowClient.newInstance(service, profile.toWorkflowClientOptions());
FileProcessingWorkflow workflow =
client.newWorkflowStub(
FileProcessingWorkflow.class,
diff --git a/core/src/main/java/io/temporal/samples/fileprocessing/FileProcessingWorker.java b/core/src/main/java/io/temporal/samples/fileprocessing/FileProcessingWorker.java
index 55b2123fa..711ca7343 100644
--- a/core/src/main/java/io/temporal/samples/fileprocessing/FileProcessingWorker.java
+++ b/core/src/main/java/io/temporal/samples/fileprocessing/FileProcessingWorker.java
@@ -1,28 +1,11 @@
-/*
- * Copyright (c) 2020 Temporal Technologies, Inc. All Rights Reserved
- *
- * Copyright 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
- * Modifications copyright (C) 2017 Uber Technologies, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"). You may not
- * use this file except in compliance with the License. A copy of the License is
- * located at
- *
- * http://aws.amazon.com/apache2.0
- *
- * or in the "license" file accompanying this file. This file is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
package io.temporal.samples.fileprocessing;
import io.temporal.client.WorkflowClient;
+import io.temporal.envconfig.ClientConfigProfile;
import io.temporal.serviceclient.WorkflowServiceStubs;
import io.temporal.worker.Worker;
import io.temporal.worker.WorkerFactory;
+import java.io.IOException;
import java.lang.management.ManagementFactory;
/**
@@ -40,10 +23,19 @@ public static void main(String[] args) {
String hostSpecifiTaskQueue = ManagementFactory.getRuntimeMXBean().getName();
- // gRPC stubs wrapper that talks to the local docker instance of temporal service.
- WorkflowServiceStubs service = WorkflowServiceStubs.newLocalServiceStubs();
+ // Load configuration from environment and files
+ ClientConfigProfile profile;
+ try {
+ profile = ClientConfigProfile.load();
+ } catch (IOException e) {
+ throw new RuntimeException("Failed to load client configuration", e);
+ }
+
+ // gRPC stubs wrapper that talks to the temporal service.
+ WorkflowServiceStubs service =
+ WorkflowServiceStubs.newServiceStubs(profile.toWorkflowServiceStubsOptions());
// client that can be used to start and signal workflows
- WorkflowClient client = WorkflowClient.newInstance(service);
+ WorkflowClient client = WorkflowClient.newInstance(service, profile.toWorkflowClientOptions());
// worker factory that can be used to create workers for specific task queues
WorkerFactory factory = WorkerFactory.newInstance(client);
diff --git a/core/src/main/java/io/temporal/samples/fileprocessing/FileProcessingWorkflow.java b/core/src/main/java/io/temporal/samples/fileprocessing/FileProcessingWorkflow.java
index e684ac0c7..c9e88cd58 100644
--- a/core/src/main/java/io/temporal/samples/fileprocessing/FileProcessingWorkflow.java
+++ b/core/src/main/java/io/temporal/samples/fileprocessing/FileProcessingWorkflow.java
@@ -1,22 +1,3 @@
-/*
- * Copyright (c) 2020 Temporal Technologies, Inc. All Rights Reserved
- *
- * Copyright 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
- * Modifications copyright (C) 2017 Uber Technologies, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"). You may not
- * use this file except in compliance with the License. A copy of the License is
- * located at
- *
- * http://aws.amazon.com/apache2.0
- *
- * or in the "license" file accompanying this file. This file is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
package io.temporal.samples.fileprocessing;
import io.temporal.workflow.WorkflowInterface;
diff --git a/core/src/main/java/io/temporal/samples/fileprocessing/FileProcessingWorkflowImpl.java b/core/src/main/java/io/temporal/samples/fileprocessing/FileProcessingWorkflowImpl.java
index f93c3ae63..b810baed8 100644
--- a/core/src/main/java/io/temporal/samples/fileprocessing/FileProcessingWorkflowImpl.java
+++ b/core/src/main/java/io/temporal/samples/fileprocessing/FileProcessingWorkflowImpl.java
@@ -1,22 +1,3 @@
-/*
- * Copyright (c) 2020 Temporal Technologies, Inc. All Rights Reserved
- *
- * Copyright 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
- * Modifications copyright (C) 2017 Uber Technologies, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"). You may not
- * use this file except in compliance with the License. A copy of the License is
- * located at
- *
- * http://aws.amazon.com/apache2.0
- *
- * or in the "license" file accompanying this file. This file is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
package io.temporal.samples.fileprocessing;
import io.temporal.activity.ActivityOptions;
diff --git a/core/src/main/java/io/temporal/samples/fileprocessing/StoreActivities.java b/core/src/main/java/io/temporal/samples/fileprocessing/StoreActivities.java
index 1326a8ad7..e66e5b727 100644
--- a/core/src/main/java/io/temporal/samples/fileprocessing/StoreActivities.java
+++ b/core/src/main/java/io/temporal/samples/fileprocessing/StoreActivities.java
@@ -1,22 +1,3 @@
-/*
- * Copyright (c) 2020 Temporal Technologies, Inc. All Rights Reserved
- *
- * Copyright 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
- * Modifications copyright (C) 2017 Uber Technologies, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"). You may not
- * use this file except in compliance with the License. A copy of the License is
- * located at
- *
- * http://aws.amazon.com/apache2.0
- *
- * or in the "license" file accompanying this file. This file is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
package io.temporal.samples.fileprocessing;
import io.temporal.activity.ActivityInterface;
diff --git a/core/src/main/java/io/temporal/samples/fileprocessing/StoreActivitiesImpl.java b/core/src/main/java/io/temporal/samples/fileprocessing/StoreActivitiesImpl.java
index 905642785..965f4f782 100644
--- a/core/src/main/java/io/temporal/samples/fileprocessing/StoreActivitiesImpl.java
+++ b/core/src/main/java/io/temporal/samples/fileprocessing/StoreActivitiesImpl.java
@@ -1,22 +1,3 @@
-/*
- * Copyright (c) 2020 Temporal Technologies, Inc. All Rights Reserved
- *
- * Copyright 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
- * Modifications copyright (C) 2017 Uber Technologies, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"). You may not
- * use this file except in compliance with the License. A copy of the License is
- * located at
- *
- * http://aws.amazon.com/apache2.0
- *
- * or in the "license" file accompanying this file. This file is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
package io.temporal.samples.fileprocessing;
import com.google.common.io.Files;
diff --git a/core/src/main/java/io/temporal/samples/getresultsasync/MyWorkflow.java b/core/src/main/java/io/temporal/samples/getresultsasync/MyWorkflow.java
index 2dd9455ec..9578fee01 100644
--- a/core/src/main/java/io/temporal/samples/getresultsasync/MyWorkflow.java
+++ b/core/src/main/java/io/temporal/samples/getresultsasync/MyWorkflow.java
@@ -1,22 +1,3 @@
-/*
- * Copyright (c) 2020 Temporal Technologies, Inc. All Rights Reserved
- *
- * Copyright 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
- * Modifications copyright (C) 2017 Uber Technologies, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"). You may not
- * use this file except in compliance with the License. A copy of the License is
- * located at
- *
- * http://aws.amazon.com/apache2.0
- *
- * or in the "license" file accompanying this file. This file is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
package io.temporal.samples.getresultsasync;
import io.temporal.workflow.WorkflowInterface;
diff --git a/core/src/main/java/io/temporal/samples/getresultsasync/MyWorkflowImpl.java b/core/src/main/java/io/temporal/samples/getresultsasync/MyWorkflowImpl.java
index 1036cb185..de362b34f 100644
--- a/core/src/main/java/io/temporal/samples/getresultsasync/MyWorkflowImpl.java
+++ b/core/src/main/java/io/temporal/samples/getresultsasync/MyWorkflowImpl.java
@@ -1,22 +1,3 @@
-/*
- * Copyright (c) 2020 Temporal Technologies, Inc. All Rights Reserved
- *
- * Copyright 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
- * Modifications copyright (C) 2017 Uber Technologies, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"). You may not
- * use this file except in compliance with the License. A copy of the License is
- * located at
- *
- * http://aws.amazon.com/apache2.0
- *
- * or in the "license" file accompanying this file. This file is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
package io.temporal.samples.getresultsasync;
import io.temporal.workflow.Workflow;
diff --git a/core/src/main/java/io/temporal/samples/getresultsasync/Starter.java b/core/src/main/java/io/temporal/samples/getresultsasync/Starter.java
index 573cc7e90..79ac70171 100644
--- a/core/src/main/java/io/temporal/samples/getresultsasync/Starter.java
+++ b/core/src/main/java/io/temporal/samples/getresultsasync/Starter.java
@@ -1,22 +1,3 @@
-/*
- * Copyright (c) 2020 Temporal Technologies, Inc. All Rights Reserved
- *
- * Copyright 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
- * Modifications copyright (C) 2017 Uber Technologies, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"). You may not
- * use this file except in compliance with the License. A copy of the License is
- * located at
- *
- * http://aws.amazon.com/apache2.0
- *
- * or in the "license" file accompanying this file. This file is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
package io.temporal.samples.getresultsasync;
import io.temporal.client.WorkflowClient;
diff --git a/core/src/main/java/io/temporal/samples/getresultsasync/Worker.java b/core/src/main/java/io/temporal/samples/getresultsasync/Worker.java
index 8edb69dbc..4a91026f8 100644
--- a/core/src/main/java/io/temporal/samples/getresultsasync/Worker.java
+++ b/core/src/main/java/io/temporal/samples/getresultsasync/Worker.java
@@ -1,32 +1,30 @@
-/*
- * Copyright (c) 2020 Temporal Technologies, Inc. All Rights Reserved
- *
- * Copyright 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
- * Modifications copyright (C) 2017 Uber Technologies, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"). You may not
- * use this file except in compliance with the License. A copy of the License is
- * located at
- *
- * http://aws.amazon.com/apache2.0
- *
- * or in the "license" file accompanying this file. This file is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
package io.temporal.samples.getresultsasync;
import io.temporal.client.WorkflowClient;
+import io.temporal.envconfig.ClientConfigProfile;
import io.temporal.serviceclient.WorkflowServiceStubs;
import io.temporal.worker.WorkerFactory;
+import java.io.IOException;
public class Worker {
- public static final WorkflowServiceStubs service = WorkflowServiceStubs.newLocalServiceStubs();
- public static final WorkflowClient client = WorkflowClient.newInstance(service);
- public static final WorkerFactory factory = WorkerFactory.newInstance(client);
+ public static final WorkflowServiceStubs service;
+ public static final WorkflowClient client;
+ public static final WorkerFactory factory;
+
+ static {
+ // Load configuration from environment and files
+ ClientConfigProfile profile;
+ try {
+ profile = ClientConfigProfile.load();
+ } catch (IOException e) {
+ throw new RuntimeException("Failed to load client configuration", e);
+ }
+
+ service = WorkflowServiceStubs.newServiceStubs(profile.toWorkflowServiceStubsOptions());
+ client = WorkflowClient.newInstance(service, profile.toWorkflowClientOptions());
+ factory = WorkerFactory.newInstance(client);
+ }
+
public static final String TASK_QUEUE_NAME = "asyncstartqueue";
public static void main(String[] args) {
diff --git a/core/src/main/java/io/temporal/samples/hello/HelloAccumulator.java b/core/src/main/java/io/temporal/samples/hello/HelloAccumulator.java
index c5561df09..2f8d67457 100644
--- a/core/src/main/java/io/temporal/samples/hello/HelloAccumulator.java
+++ b/core/src/main/java/io/temporal/samples/hello/HelloAccumulator.java
@@ -1,22 +1,3 @@
-/*
- * Copyright (c) 2020 Temporal Technologies, Inc. All Rights Reserved
- *
- * Copyright 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
- * Modifications copyright (C) 2017 Uber Technologies, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"). You may not
- * use this file except in compliance with the License. A copy of the License is
- * located at
- *
- * http://aws.amazon.com/apache2.0
- *
- * or in the "license" file accompanying this file. This file is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
package io.temporal.samples.hello;
import io.temporal.activity.ActivityInterface;
@@ -30,6 +11,7 @@
import io.temporal.client.WorkflowNotFoundException;
import io.temporal.client.WorkflowOptions;
import io.temporal.client.WorkflowStub;
+import io.temporal.envconfig.ClientConfigProfile;
import io.temporal.serviceclient.WorkflowServiceStubs;
import io.temporal.worker.Worker;
import io.temporal.worker.WorkerFactory;
@@ -37,6 +19,7 @@
import io.temporal.workflow.Workflow;
import io.temporal.workflow.WorkflowInterface;
import io.temporal.workflow.WorkflowMethod;
+import java.io.IOException;
import java.io.Serializable;
import java.time.Duration;
import java.util.ArrayDeque;
@@ -312,14 +295,17 @@ public void exit() {
*/
public static void main(String[] args) throws Exception {
- // Get a Workflow service stub.
- WorkflowServiceStubs service = WorkflowServiceStubs.newLocalServiceStubs();
+ // Load configuration from environment and files
+ ClientConfigProfile profile;
+ try {
+ profile = ClientConfigProfile.load();
+ } catch (IOException e) {
+ throw new RuntimeException("Failed to load client configuration", e);
+ }
- /*
- * Get a Workflow service client which can be used to start, Signal, and Query
- * Workflow Executions.
- */
- WorkflowClient client = WorkflowClient.newInstance(service);
+ WorkflowServiceStubs service =
+ WorkflowServiceStubs.newServiceStubs(profile.toWorkflowServiceStubsOptions());
+ WorkflowClient client = WorkflowClient.newInstance(service, profile.toWorkflowClientOptions());
client.getWorkflowServiceStubs().healthCheck();
/*
diff --git a/core/src/main/java/io/temporal/samples/hello/HelloActivity.java b/core/src/main/java/io/temporal/samples/hello/HelloActivity.java
index 70f2ebfa0..9b202e0c2 100644
--- a/core/src/main/java/io/temporal/samples/hello/HelloActivity.java
+++ b/core/src/main/java/io/temporal/samples/hello/HelloActivity.java
@@ -1,22 +1,3 @@
-/*
- * Copyright (c) 2020 Temporal Technologies, Inc. All Rights Reserved
- *
- * Copyright 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
- * Modifications copyright (C) 2017 Uber Technologies, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"). You may not
- * use this file except in compliance with the License. A copy of the License is
- * located at
- *
- * http://aws.amazon.com/apache2.0
- *
- * or in the "license" file accompanying this file. This file is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
package io.temporal.samples.hello;
import io.temporal.activity.ActivityInterface;
@@ -24,12 +5,14 @@
import io.temporal.activity.ActivityOptions;
import io.temporal.client.WorkflowClient;
import io.temporal.client.WorkflowOptions;
+import io.temporal.envconfig.ClientConfigProfile;
import io.temporal.serviceclient.WorkflowServiceStubs;
import io.temporal.worker.Worker;
import io.temporal.worker.WorkerFactory;
import io.temporal.workflow.Workflow;
import io.temporal.workflow.WorkflowInterface;
import io.temporal.workflow.WorkflowMethod;
+import java.io.IOException;
import java.time.Duration;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -124,13 +107,22 @@ public String composeGreeting(String greeting, String name) {
*/
public static void main(String[] args) {
+ // Load configuration from environment and files
+ ClientConfigProfile profile;
+ try {
+ profile = ClientConfigProfile.load();
+ } catch (IOException e) {
+ throw new RuntimeException("Failed to load client configuration", e);
+ }
+
// Get a Workflow service stub.
- WorkflowServiceStubs service = WorkflowServiceStubs.newLocalServiceStubs();
+ WorkflowServiceStubs service =
+ WorkflowServiceStubs.newServiceStubs(profile.toWorkflowServiceStubsOptions());
/*
* Get a Workflow service client which can be used to start, Signal, and Query Workflow Executions.
*/
- WorkflowClient client = WorkflowClient.newInstance(service);
+ WorkflowClient client = WorkflowClient.newInstance(service, profile.toWorkflowClientOptions());
/*
* Define the workflow factory. It is used to create workflow workers for a specific task queue.
diff --git a/core/src/main/java/io/temporal/samples/hello/HelloActivityExclusiveChoice.java b/core/src/main/java/io/temporal/samples/hello/HelloActivityExclusiveChoice.java
index 0af214471..3f2309993 100644
--- a/core/src/main/java/io/temporal/samples/hello/HelloActivityExclusiveChoice.java
+++ b/core/src/main/java/io/temporal/samples/hello/HelloActivityExclusiveChoice.java
@@ -1,34 +1,17 @@
-/*
- * Copyright (c) 2020 Temporal Technologies, Inc. All Rights Reserved
- *
- * Copyright 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
- * Modifications copyright (C) 2017 Uber Technologies, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"). You may not
- * use this file except in compliance with the License. A copy of the License is
- * located at
- *
- * http://aws.amazon.com/apache2.0
- *
- * or in the "license" file accompanying this file. This file is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
package io.temporal.samples.hello;
import io.temporal.activity.ActivityInterface;
import io.temporal.activity.ActivityOptions;
import io.temporal.client.WorkflowClient;
import io.temporal.client.WorkflowOptions;
+import io.temporal.envconfig.ClientConfigProfile;
import io.temporal.serviceclient.WorkflowServiceStubs;
import io.temporal.worker.Worker;
import io.temporal.worker.WorkerFactory;
import io.temporal.workflow.Workflow;
import io.temporal.workflow.WorkflowInterface;
import io.temporal.workflow.WorkflowMethod;
+import java.io.IOException;
import java.time.Duration;
import java.util.HashMap;
import java.util.Map;
@@ -184,12 +167,21 @@ public static void main(String[] args) {
* Define the workflow service. It is a gRPC stubs wrapper which talks to the docker instance of
* our locally running Temporal service.
*/
- WorkflowServiceStubs service = WorkflowServiceStubs.newLocalServiceStubs();
+ // Load configuration from environment and files
+ ClientConfigProfile profile;
+ try {
+ profile = ClientConfigProfile.load();
+ } catch (IOException e) {
+ throw new RuntimeException("Failed to load client configuration", e);
+ }
+
+ WorkflowServiceStubs service =
+ WorkflowServiceStubs.newServiceStubs(profile.toWorkflowServiceStubsOptions());
/*
* Get a Workflow service client which can be used to start, Signal, and Query Workflow Executions.
*/
- WorkflowClient client = WorkflowClient.newInstance(service);
+ WorkflowClient client = WorkflowClient.newInstance(service, profile.toWorkflowClientOptions());
/*
* Define the workflow factory. It is used to create workflow workers for a specific task queue.
diff --git a/core/src/main/java/io/temporal/samples/hello/HelloActivityRetry.java b/core/src/main/java/io/temporal/samples/hello/HelloActivityRetry.java
index e7ca4a9d4..4f78cfa2f 100644
--- a/core/src/main/java/io/temporal/samples/hello/HelloActivityRetry.java
+++ b/core/src/main/java/io/temporal/samples/hello/HelloActivityRetry.java
@@ -1,22 +1,3 @@
-/*
- * Copyright (c) 2020 Temporal Technologies, Inc. All Rights Reserved
- *
- * Copyright 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
- * Modifications copyright (C) 2017 Uber Technologies, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"). You may not
- * use this file except in compliance with the License. A copy of the License is
- * located at
- *
- * http://aws.amazon.com/apache2.0
- *
- * or in the "license" file accompanying this file. This file is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
package io.temporal.samples.hello;
import io.temporal.activity.ActivityInterface;
@@ -24,12 +5,14 @@
import io.temporal.client.WorkflowClient;
import io.temporal.client.WorkflowOptions;
import io.temporal.common.RetryOptions;
+import io.temporal.envconfig.ClientConfigProfile;
import io.temporal.serviceclient.WorkflowServiceStubs;
import io.temporal.worker.Worker;
import io.temporal.worker.WorkerFactory;
import io.temporal.workflow.Workflow;
import io.temporal.workflow.WorkflowInterface;
import io.temporal.workflow.WorkflowMethod;
+import java.io.IOException;
import java.time.Duration;
/** Sample Temporal workflow that demonstrates workflow activity retries. */
@@ -159,13 +142,17 @@ public synchronized String composeGreeting(String greeting, String name) {
*/
public static void main(String[] args) {
- // Get a Workflow service stub.
- WorkflowServiceStubs service = WorkflowServiceStubs.newLocalServiceStubs();
+ // Load configuration from environment and files
+ ClientConfigProfile profile;
+ try {
+ profile = ClientConfigProfile.load();
+ } catch (IOException e) {
+ throw new RuntimeException("Failed to load client configuration", e);
+ }
- /*
- * Get a Workflow service client which can be used to start, Signal, and Query Workflow Executions.
- */
- WorkflowClient client = WorkflowClient.newInstance(service);
+ WorkflowServiceStubs service =
+ WorkflowServiceStubs.newServiceStubs(profile.toWorkflowServiceStubsOptions());
+ WorkflowClient client = WorkflowClient.newInstance(service, profile.toWorkflowClientOptions());
/*
* Define the workflow factory. It is used to create workflow workers for a specific task queue.
diff --git a/core/src/main/java/io/temporal/samples/hello/HelloAsync.java b/core/src/main/java/io/temporal/samples/hello/HelloAsync.java
index 99b1e8928..25e8c3c5f 100644
--- a/core/src/main/java/io/temporal/samples/hello/HelloAsync.java
+++ b/core/src/main/java/io/temporal/samples/hello/HelloAsync.java
@@ -1,28 +1,10 @@
-/*
- * Copyright (c) 2020 Temporal Technologies, Inc. All Rights Reserved
- *
- * Copyright 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
- * Modifications copyright (C) 2017 Uber Technologies, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"). You may not
- * use this file except in compliance with the License. A copy of the License is
- * located at
- *
- * http://aws.amazon.com/apache2.0
- *
- * or in the "license" file accompanying this file. This file is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
package io.temporal.samples.hello;
import io.temporal.activity.ActivityInterface;
import io.temporal.activity.ActivityOptions;
import io.temporal.client.WorkflowClient;
import io.temporal.client.WorkflowOptions;
+import io.temporal.envconfig.ClientConfigProfile;
import io.temporal.serviceclient.WorkflowServiceStubs;
import io.temporal.worker.Worker;
import io.temporal.worker.WorkerFactory;
@@ -31,6 +13,7 @@
import io.temporal.workflow.Workflow;
import io.temporal.workflow.WorkflowInterface;
import io.temporal.workflow.WorkflowMethod;
+import java.io.IOException;
import java.time.Duration;
/** Sample Temporal Workflow Definition that demonstrates an asynchronous Activity Execution. */
@@ -129,13 +112,18 @@ public String composeGreeting(String greeting, String name) {
*/
public static void main(String[] args) {
- // Get a Workflow service stub.
- WorkflowServiceStubs service = WorkflowServiceStubs.newLocalServiceStubs();
+ // Load configuration from environment and files
+ ClientConfigProfile profile;
+ try {
+ profile = ClientConfigProfile.load();
+ } catch (IOException e) {
+ throw new RuntimeException("Failed to load client configuration", e);
+ }
- /*
- * Get a Workflow service client which can be used to start, Signal, and Query Workflow Executions.
- */
- WorkflowClient client = WorkflowClient.newInstance(service);
+ // Get a Workflow service stub.
+ WorkflowServiceStubs service =
+ WorkflowServiceStubs.newServiceStubs(profile.toWorkflowServiceStubsOptions());
+ WorkflowClient client = WorkflowClient.newInstance(service, profile.toWorkflowClientOptions());
/*
* Define the workflow factory. It is used to create workflow workers for a specific task queue.
diff --git a/core/src/main/java/io/temporal/samples/hello/HelloAsyncActivityCompletion.java b/core/src/main/java/io/temporal/samples/hello/HelloAsyncActivityCompletion.java
index b2409487d..f52072738 100644
--- a/core/src/main/java/io/temporal/samples/hello/HelloAsyncActivityCompletion.java
+++ b/core/src/main/java/io/temporal/samples/hello/HelloAsyncActivityCompletion.java
@@ -1,34 +1,17 @@
-/*
- * Copyright (c) 2020 Temporal Technologies, Inc. All Rights Reserved
- *
- * Copyright 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
- * Modifications copyright (C) 2017 Uber Technologies, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"). You may not
- * use this file except in compliance with the License. A copy of the License is
- * located at
- *
- * http://aws.amazon.com/apache2.0
- *
- * or in the "license" file accompanying this file. This file is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
package io.temporal.samples.hello;
import io.temporal.activity.*;
import io.temporal.client.ActivityCompletionClient;
import io.temporal.client.WorkflowClient;
import io.temporal.client.WorkflowOptions;
+import io.temporal.envconfig.ClientConfigProfile;
import io.temporal.serviceclient.WorkflowServiceStubs;
import io.temporal.worker.Worker;
import io.temporal.worker.WorkerFactory;
import io.temporal.workflow.Workflow;
import io.temporal.workflow.WorkflowInterface;
import io.temporal.workflow.WorkflowMethod;
+import java.io.IOException;
import java.time.Duration;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ExecutionException;
@@ -162,14 +145,18 @@ private void composeGreetingAsync(byte[] taskToken, String greeting, String name
*/
public static void main(String[] args) throws ExecutionException, InterruptedException {
- // Get a Workflow service stub.
- WorkflowServiceStubs service = WorkflowServiceStubs.newLocalServiceStubs();
+ // Load configuration from environment and files
+ ClientConfigProfile profile;
+ try {
+ profile = ClientConfigProfile.load();
+ } catch (IOException e) {
+ throw new RuntimeException("Failed to load client configuration", e);
+ }
- /*
- * Get a Workflow service client which can be used to start, Signal, and Query Workflow
- * Executions.
- */
- WorkflowClient client = WorkflowClient.newInstance(service);
+ // Get a Workflow service stub.
+ WorkflowServiceStubs service =
+ WorkflowServiceStubs.newServiceStubs(profile.toWorkflowServiceStubsOptions());
+ WorkflowClient client = WorkflowClient.newInstance(service, profile.toWorkflowClientOptions());
/*
* Define the workflow factory. It is used to create workflow workers for a specific task queue.
diff --git a/core/src/main/java/io/temporal/samples/hello/HelloAsyncLambda.java b/core/src/main/java/io/temporal/samples/hello/HelloAsyncLambda.java
index cf860d06a..6b68d85cb 100644
--- a/core/src/main/java/io/temporal/samples/hello/HelloAsyncLambda.java
+++ b/core/src/main/java/io/temporal/samples/hello/HelloAsyncLambda.java
@@ -1,28 +1,10 @@
-/*
- * Copyright (c) 2020 Temporal Technologies, Inc. All Rights Reserved
- *
- * Copyright 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
- * Modifications copyright (C) 2017 Uber Technologies, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"). You may not
- * use this file except in compliance with the License. A copy of the License is
- * located at
- *
- * http://aws.amazon.com/apache2.0
- *
- * or in the "license" file accompanying this file. This file is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
package io.temporal.samples.hello;
import io.temporal.activity.ActivityInterface;
import io.temporal.activity.ActivityOptions;
import io.temporal.client.WorkflowClient;
import io.temporal.client.WorkflowOptions;
+import io.temporal.envconfig.ClientConfigProfile;
import io.temporal.serviceclient.WorkflowServiceStubs;
import io.temporal.worker.Worker;
import io.temporal.worker.WorkerFactory;
@@ -31,6 +13,7 @@
import io.temporal.workflow.Workflow;
import io.temporal.workflow.WorkflowInterface;
import io.temporal.workflow.WorkflowMethod;
+import java.io.IOException;
import java.time.Duration;
/** Sample Temporal Workflow Definition that demonstrates an asynchronous Activity Executions. */
@@ -147,13 +130,18 @@ public String composeGreeting(String greeting, String name) {
*/
public static void main(String[] args) {
- // Get a Workflow service stub.
- WorkflowServiceStubs service = WorkflowServiceStubs.newLocalServiceStubs();
+ // Load configuration from environment and files
+ ClientConfigProfile profile;
+ try {
+ profile = ClientConfigProfile.load();
+ } catch (IOException e) {
+ throw new RuntimeException("Failed to load client configuration", e);
+ }
- /*
- * Get a Workflow service client which can be used to start, Signal, and Query Workflow Executions.
- */
- WorkflowClient client = WorkflowClient.newInstance(service);
+ // Get a Workflow service stub.
+ WorkflowServiceStubs service =
+ WorkflowServiceStubs.newServiceStubs(profile.toWorkflowServiceStubsOptions());
+ WorkflowClient client = WorkflowClient.newInstance(service, profile.toWorkflowClientOptions());
/*
* Define the workflow factory. It is used to create workflow workers for a specific task queue.
diff --git a/core/src/main/java/io/temporal/samples/hello/HelloAwait.java b/core/src/main/java/io/temporal/samples/hello/HelloAwait.java
index 5868534c8..588b9e3fc 100644
--- a/core/src/main/java/io/temporal/samples/hello/HelloAwait.java
+++ b/core/src/main/java/io/temporal/samples/hello/HelloAwait.java
@@ -1,27 +1,9 @@
-/*
- * Copyright (c) 2020 Temporal Technologies, Inc. All Rights Reserved
- *
- * Copyright 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
- * Modifications copyright (C) 2017 Uber Technologies, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"). You may not
- * use this file except in compliance with the License. A copy of the License is
- * located at
- *
- * http://aws.amazon.com/apache2.0
- *
- * or in the "license" file accompanying this file. This file is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
package io.temporal.samples.hello;
import io.temporal.client.WorkflowClient;
import io.temporal.client.WorkflowOptions;
import io.temporal.client.WorkflowStub;
+import io.temporal.envconfig.ClientConfigProfile;
import io.temporal.failure.ApplicationFailure;
import io.temporal.serviceclient.WorkflowServiceStubs;
import io.temporal.worker.Worker;
@@ -30,6 +12,7 @@
import io.temporal.workflow.Workflow;
import io.temporal.workflow.WorkflowInterface;
import io.temporal.workflow.WorkflowMethod;
+import java.io.IOException;
import java.time.Duration;
/**
@@ -99,13 +82,18 @@ public void waitForName(String name) {
*/
public static void main(String[] args) throws Exception {
- // Get a Workflow service stub.
- WorkflowServiceStubs service = WorkflowServiceStubs.newLocalServiceStubs();
+ // Load configuration from environment and files
+ ClientConfigProfile profile;
+ try {
+ profile = ClientConfigProfile.load();
+ } catch (IOException e) {
+ throw new RuntimeException("Failed to load client configuration", e);
+ }
- /*
- * Get a Workflow service client which can be used to start, Await, and Query Workflow Executions.
- */
- WorkflowClient client = WorkflowClient.newInstance(service);
+ // Get a Workflow service stub.
+ WorkflowServiceStubs service =
+ WorkflowServiceStubs.newServiceStubs(profile.toWorkflowServiceStubsOptions());
+ WorkflowClient client = WorkflowClient.newInstance(service, profile.toWorkflowClientOptions());
/*
* Define the workflow factory. It is used to create workflow workers for a specific task queue.
diff --git a/core/src/main/java/io/temporal/samples/hello/HelloCancellationScope.java b/core/src/main/java/io/temporal/samples/hello/HelloCancellationScope.java
index d7b31ce88..c98a6fac5 100644
--- a/core/src/main/java/io/temporal/samples/hello/HelloCancellationScope.java
+++ b/core/src/main/java/io/temporal/samples/hello/HelloCancellationScope.java
@@ -1,22 +1,3 @@
-/*
- * Copyright (c) 2020 Temporal Technologies, Inc. All Rights Reserved
- *
- * Copyright 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
- * Modifications copyright (C) 2017 Uber Technologies, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"). You may not
- * use this file except in compliance with the License. A copy of the License is
- * located at
- *
- * http://aws.amazon.com/apache2.0
- *
- * or in the "license" file accompanying this file. This file is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
package io.temporal.samples.hello;
import io.temporal.activity.Activity;
@@ -27,6 +8,7 @@
import io.temporal.client.ActivityCompletionException;
import io.temporal.client.WorkflowClient;
import io.temporal.client.WorkflowOptions;
+import io.temporal.envconfig.ClientConfigProfile;
import io.temporal.failure.ActivityFailure;
import io.temporal.failure.CanceledFailure;
import io.temporal.serviceclient.WorkflowServiceStubs;
@@ -39,6 +21,7 @@
import io.temporal.workflow.Workflow;
import io.temporal.workflow.WorkflowInterface;
import io.temporal.workflow.WorkflowMethod;
+import java.io.IOException;
import java.time.Duration;
import java.util.ArrayList;
import java.util.List;
@@ -250,13 +233,18 @@ private void sleep(int seconds) {
*/
public static void main(String[] args) {
- // Get a Workflow service stub.
- WorkflowServiceStubs service = WorkflowServiceStubs.newLocalServiceStubs();
+ // Load configuration from environment and files
+ ClientConfigProfile profile;
+ try {
+ profile = ClientConfigProfile.load();
+ } catch (IOException e) {
+ throw new RuntimeException("Failed to load client configuration", e);
+ }
- /*
- * Get a Workflow service client which can be used to start, Signal, and Query Workflow Executions.
- */
- WorkflowClient client = WorkflowClient.newInstance(service);
+ // Get a Workflow service stub.
+ WorkflowServiceStubs service =
+ WorkflowServiceStubs.newServiceStubs(profile.toWorkflowServiceStubsOptions());
+ WorkflowClient client = WorkflowClient.newInstance(service, profile.toWorkflowClientOptions());
/*
* Define the workflow factory. It is used to create workflow workers for a specific task queue.
diff --git a/core/src/main/java/io/temporal/samples/hello/HelloCancellationScopeWithTimer.java b/core/src/main/java/io/temporal/samples/hello/HelloCancellationScopeWithTimer.java
index 0f70bd814..5961b6833 100644
--- a/core/src/main/java/io/temporal/samples/hello/HelloCancellationScopeWithTimer.java
+++ b/core/src/main/java/io/temporal/samples/hello/HelloCancellationScopeWithTimer.java
@@ -1,34 +1,17 @@
-/*
- * Copyright (c) 2020 Temporal Technologies, Inc. All Rights Reserved
- *
- * Copyright 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
- * Modifications copyright (C) 2017 Uber Technologies, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"). You may not
- * use this file except in compliance with the License. A copy of the License is
- * located at
- *
- * http://aws.amazon.com/apache2.0
- *
- * or in the "license" file accompanying this file. This file is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
package io.temporal.samples.hello;
import io.temporal.activity.*;
import io.temporal.client.ActivityCompletionException;
import io.temporal.client.WorkflowClient;
import io.temporal.client.WorkflowOptions;
+import io.temporal.envconfig.ClientConfigProfile;
import io.temporal.failure.ActivityFailure;
import io.temporal.failure.CanceledFailure;
import io.temporal.serviceclient.WorkflowServiceStubs;
import io.temporal.worker.Worker;
import io.temporal.worker.WorkerFactory;
import io.temporal.workflow.*;
+import java.io.IOException;
import java.time.Duration;
import java.util.concurrent.TimeUnit;
@@ -172,12 +155,21 @@ private void sleep(int seconds) {
public static void main(String[] args) {
// Get a Workflow service stub.
- WorkflowServiceStubs service = WorkflowServiceStubs.newLocalServiceStubs();
+ // Load configuration from environment and files
+ ClientConfigProfile profile;
+ try {
+ profile = ClientConfigProfile.load();
+ } catch (IOException e) {
+ throw new RuntimeException("Failed to load client configuration", e);
+ }
+
+ WorkflowServiceStubs service =
+ WorkflowServiceStubs.newServiceStubs(profile.toWorkflowServiceStubsOptions());
/*
* Get a Workflow service client which can be used to start, Signal, and Query Workflow Executions.
*/
- WorkflowClient client = WorkflowClient.newInstance(service);
+ WorkflowClient client = WorkflowClient.newInstance(service, profile.toWorkflowClientOptions());
/*
* Define the workflow factory. It is used to create workflow workers for a specific task queue.
diff --git a/core/src/main/java/io/temporal/samples/hello/HelloChild.java b/core/src/main/java/io/temporal/samples/hello/HelloChild.java
index a916c13c8..4c4c37276 100644
--- a/core/src/main/java/io/temporal/samples/hello/HelloChild.java
+++ b/core/src/main/java/io/temporal/samples/hello/HelloChild.java
@@ -1,26 +1,8 @@
-/*
- * Copyright (c) 2020 Temporal Technologies, Inc. All Rights Reserved
- *
- * Copyright 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
- * Modifications copyright (C) 2017 Uber Technologies, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"). You may not
- * use this file except in compliance with the License. A copy of the License is
- * located at
- *
- * http://aws.amazon.com/apache2.0
- *
- * or in the "license" file accompanying this file. This file is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
package io.temporal.samples.hello;
import io.temporal.client.WorkflowClient;
import io.temporal.client.WorkflowOptions;
+import io.temporal.envconfig.ClientConfigProfile;
import io.temporal.serviceclient.WorkflowServiceStubs;
import io.temporal.worker.Worker;
import io.temporal.worker.WorkerFactory;
@@ -29,6 +11,7 @@
import io.temporal.workflow.Workflow;
import io.temporal.workflow.WorkflowInterface;
import io.temporal.workflow.WorkflowMethod;
+import java.io.IOException;
/**
* Sample Temporal Workflow Definition that demonstrates the execution of a Child Workflow. Child
@@ -124,13 +107,18 @@ public String composeGreeting(String greeting, String name) {
*/
public static void main(String[] args) {
- // Get a Workflow service stub.
- WorkflowServiceStubs service = WorkflowServiceStubs.newLocalServiceStubs();
+ // Load configuration from environment and files
+ ClientConfigProfile profile;
+ try {
+ profile = ClientConfigProfile.load();
+ } catch (IOException e) {
+ throw new RuntimeException("Failed to load client configuration", e);
+ }
- /*
- * Get a Workflow service client which can be used to start, Signal, and Query Workflow Executions.
- */
- WorkflowClient client = WorkflowClient.newInstance(service);
+ // Get a Workflow service stub.
+ WorkflowServiceStubs service =
+ WorkflowServiceStubs.newServiceStubs(profile.toWorkflowServiceStubsOptions());
+ WorkflowClient client = WorkflowClient.newInstance(service, profile.toWorkflowClientOptions());
/*
* Define the worker factory. It is used to create workers for a specific task queue.
diff --git a/core/src/main/java/io/temporal/samples/hello/HelloCron.java b/core/src/main/java/io/temporal/samples/hello/HelloCron.java
index 5e7c9aa01..dafbfe11e 100644
--- a/core/src/main/java/io/temporal/samples/hello/HelloCron.java
+++ b/core/src/main/java/io/temporal/samples/hello/HelloCron.java
@@ -1,22 +1,3 @@
-/*
- * Copyright (c) 2020 Temporal Technologies, Inc. All Rights Reserved
- *
- * Copyright 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
- * Modifications copyright (C) 2017 Uber Technologies, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"). You may not
- * use this file except in compliance with the License. A copy of the License is
- * located at
- *
- * http://aws.amazon.com/apache2.0
- *
- * or in the "license" file accompanying this file. This file is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
package io.temporal.samples.hello;
import io.temporal.activity.Activity;
@@ -26,12 +7,14 @@
import io.temporal.client.WorkflowClient;
import io.temporal.client.WorkflowExecutionAlreadyStarted;
import io.temporal.client.WorkflowOptions;
+import io.temporal.envconfig.ClientConfigProfile;
import io.temporal.serviceclient.WorkflowServiceStubs;
import io.temporal.worker.Worker;
import io.temporal.worker.WorkerFactory;
import io.temporal.workflow.Workflow;
import io.temporal.workflow.WorkflowInterface;
import io.temporal.workflow.WorkflowMethod;
+import java.io.IOException;
import java.time.Duration;
/**
@@ -127,13 +110,18 @@ public void greet(String greeting) {
*/
public static void main(String[] args) {
- // Get a Workflow service stub.
- WorkflowServiceStubs service = WorkflowServiceStubs.newLocalServiceStubs();
+ // Load configuration from environment and files
+ ClientConfigProfile profile;
+ try {
+ profile = ClientConfigProfile.load();
+ } catch (IOException e) {
+ throw new RuntimeException("Failed to load client configuration", e);
+ }
- /*
- * Get a Workflow service client which can be used to start, Signal, and Query Workflow Executions.
- */
- WorkflowClient client = WorkflowClient.newInstance(service);
+ // Get a Workflow service stub.
+ WorkflowServiceStubs service =
+ WorkflowServiceStubs.newServiceStubs(profile.toWorkflowServiceStubsOptions());
+ WorkflowClient client = WorkflowClient.newInstance(service, profile.toWorkflowClientOptions());
/*
* Define the workflow factory. It is used to create workflow workers for a specific task queue.
diff --git a/core/src/main/java/io/temporal/samples/hello/HelloDelayedStart.java b/core/src/main/java/io/temporal/samples/hello/HelloDelayedStart.java
index a0b850854..a407e64d6 100644
--- a/core/src/main/java/io/temporal/samples/hello/HelloDelayedStart.java
+++ b/core/src/main/java/io/temporal/samples/hello/HelloDelayedStart.java
@@ -1,33 +1,16 @@
-/*
- * Copyright (c) 2020 Temporal Technologies, Inc. All Rights Reserved
- *
- * Copyright 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
- * Modifications copyright (C) 2017 Uber Technologies, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"). You may not
- * use this file except in compliance with the License. A copy of the License is
- * located at
- *
- * http://aws.amazon.com/apache2.0
- *
- * or in the "license" file accompanying this file. This file is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
package io.temporal.samples.hello;
import io.temporal.client.WorkflowClient;
import io.temporal.client.WorkflowOptions;
import io.temporal.common.WorkflowExecutionHistory;
+import io.temporal.envconfig.ClientConfigProfile;
import io.temporal.serviceclient.WorkflowServiceStubs;
import io.temporal.worker.Worker;
import io.temporal.worker.WorkerFactory;
import io.temporal.workflow.Workflow;
import io.temporal.workflow.WorkflowInterface;
import io.temporal.workflow.WorkflowMethod;
+import java.io.IOException;
import java.time.Duration;
/** Sample Temporal Workflow Definition that shows how to use delayed start. */
@@ -69,13 +52,18 @@ public void start() {
}
public static void main(String[] args) {
- // Get a Workflow service stub.
- WorkflowServiceStubs service = WorkflowServiceStubs.newLocalServiceStubs();
+ // Load configuration from environment and files
+ ClientConfigProfile profile;
+ try {
+ profile = ClientConfigProfile.load();
+ } catch (IOException e) {
+ throw new RuntimeException("Failed to load client configuration", e);
+ }
- /*
- * Get a Workflow service client which can be used to start, Signal, and Query Workflow Executions.
- */
- WorkflowClient client = WorkflowClient.newInstance(service);
+ // Get a Workflow service stub.
+ WorkflowServiceStubs service =
+ WorkflowServiceStubs.newServiceStubs(profile.toWorkflowServiceStubsOptions());
+ WorkflowClient client = WorkflowClient.newInstance(service, profile.toWorkflowClientOptions());
/*
* Define the workflow factory. It is used to create workflow workers for a specific task queue.
diff --git a/core/src/main/java/io/temporal/samples/hello/HelloDetachedCancellationScope.java b/core/src/main/java/io/temporal/samples/hello/HelloDetachedCancellationScope.java
index 45f4c7509..a40087894 100644
--- a/core/src/main/java/io/temporal/samples/hello/HelloDetachedCancellationScope.java
+++ b/core/src/main/java/io/temporal/samples/hello/HelloDetachedCancellationScope.java
@@ -1,22 +1,3 @@
-/*
- * Copyright (c) 2020 Temporal Technologies, Inc. All Rights Reserved
- *
- * Copyright 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
- * Modifications copyright (C) 2017 Uber Technologies, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"). You may not
- * use this file except in compliance with the License. A copy of the License is
- * located at
- *
- * http://aws.amazon.com/apache2.0
- *
- * or in the "license" file accompanying this file. This file is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
package io.temporal.samples.hello;
import io.temporal.activity.Activity;
@@ -27,11 +8,13 @@
import io.temporal.client.WorkflowFailedException;
import io.temporal.client.WorkflowOptions;
import io.temporal.client.WorkflowStub;
+import io.temporal.envconfig.ClientConfigProfile;
import io.temporal.failure.ActivityFailure;
import io.temporal.serviceclient.WorkflowServiceStubs;
import io.temporal.worker.Worker;
import io.temporal.worker.WorkerFactory;
import io.temporal.workflow.*;
+import java.io.IOException;
import java.time.Duration;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
@@ -151,13 +134,22 @@ public String queryGreeting() {
public static void main(String[] args) throws InterruptedException {
// Get a Workflow service stub.
- WorkflowServiceStubs service = WorkflowServiceStubs.newLocalServiceStubs();
+ // Load configuration from environment and files
+ ClientConfigProfile profile;
+ try {
+ profile = ClientConfigProfile.load();
+ } catch (IOException e) {
+ throw new RuntimeException("Failed to load client configuration", e);
+ }
+
+ WorkflowServiceStubs service =
+ WorkflowServiceStubs.newServiceStubs(profile.toWorkflowServiceStubsOptions());
/*
* Get a Workflow service client which can be used to start, Signal, and Query Workflow
* Executions.
*/
- WorkflowClient client = WorkflowClient.newInstance(service);
+ WorkflowClient client = WorkflowClient.newInstance(service, profile.toWorkflowClientOptions());
/*
* Define the workflow factory. It is used to create workflow workers for a specific task queue.
diff --git a/core/src/main/java/io/temporal/samples/hello/HelloDynamic.java b/core/src/main/java/io/temporal/samples/hello/HelloDynamic.java
index c88a79b5e..f779bdfc3 100644
--- a/core/src/main/java/io/temporal/samples/hello/HelloDynamic.java
+++ b/core/src/main/java/io/temporal/samples/hello/HelloDynamic.java
@@ -1,22 +1,3 @@
-/*
- * Copyright (c) 2020 Temporal Technologies, Inc. All Rights Reserved
- *
- * Copyright 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
- * Modifications copyright (C) 2017 Uber Technologies, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"). You may not
- * use this file except in compliance with the License. A copy of the License is
- * located at
- *
- * http://aws.amazon.com/apache2.0
- *
- * or in the "license" file accompanying this file. This file is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
package io.temporal.samples.hello;
import io.temporal.activity.Activity;
@@ -26,6 +7,7 @@
import io.temporal.client.WorkflowOptions;
import io.temporal.client.WorkflowStub;
import io.temporal.common.converter.EncodedValues;
+import io.temporal.envconfig.ClientConfigProfile;
import io.temporal.serviceclient.WorkflowServiceStubs;
import io.temporal.worker.Worker;
import io.temporal.worker.WorkerFactory;
@@ -33,6 +15,7 @@
import io.temporal.workflow.DynamicSignalHandler;
import io.temporal.workflow.DynamicWorkflow;
import io.temporal.workflow.Workflow;
+import java.io.IOException;
import java.time.Duration;
public class HelloDynamic {
@@ -90,14 +73,18 @@ public Object execute(EncodedValues args) {
*/
public static void main(String[] arg) {
- // Get a Workflow service stub.
- WorkflowServiceStubs service = WorkflowServiceStubs.newLocalServiceStubs();
+ // Load configuration from environment and files
+ ClientConfigProfile profile;
+ try {
+ profile = ClientConfigProfile.load();
+ } catch (IOException e) {
+ throw new RuntimeException("Failed to load client configuration", e);
+ }
- /*
- * Get a Workflow service client which can be used to start, Signal, and Query Workflow
- * Executions.
- */
- WorkflowClient client = WorkflowClient.newInstance(service);
+ // Get a Workflow service stub.
+ WorkflowServiceStubs service =
+ WorkflowServiceStubs.newServiceStubs(profile.toWorkflowServiceStubsOptions());
+ WorkflowClient client = WorkflowClient.newInstance(service, profile.toWorkflowClientOptions());
/*
* Define the workflow factory. It is used to create workflow workers for a specific task queue.
diff --git a/core/src/main/java/io/temporal/samples/hello/HelloEagerWorkflowStart.java b/core/src/main/java/io/temporal/samples/hello/HelloEagerWorkflowStart.java
index c901753a3..4e1a3b533 100644
--- a/core/src/main/java/io/temporal/samples/hello/HelloEagerWorkflowStart.java
+++ b/core/src/main/java/io/temporal/samples/hello/HelloEagerWorkflowStart.java
@@ -1,22 +1,3 @@
-/*
- * Copyright (c) 2020 Temporal Technologies, Inc. All Rights Reserved
- *
- * Copyright 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
- * Modifications copyright (C) 2017 Uber Technologies, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"). You may not
- * use this file except in compliance with the License. A copy of the License is
- * located at
- *
- * http://aws.amazon.com/apache2.0
- *
- * or in the "license" file accompanying this file. This file is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
package io.temporal.samples.hello;
import io.temporal.activity.ActivityInterface;
@@ -24,12 +5,14 @@
import io.temporal.activity.ActivityOptions;
import io.temporal.client.WorkflowClient;
import io.temporal.client.WorkflowOptions;
+import io.temporal.envconfig.ClientConfigProfile;
import io.temporal.serviceclient.WorkflowServiceStubs;
import io.temporal.worker.Worker;
import io.temporal.worker.WorkerFactory;
import io.temporal.workflow.Workflow;
import io.temporal.workflow.WorkflowInterface;
import io.temporal.workflow.WorkflowMethod;
+import java.io.IOException;
import java.time.Duration;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -129,13 +112,18 @@ public String composeGreeting(String greeting, String name) {
*/
public static void main(String[] args) {
- // Get a Workflow service stub.
- WorkflowServiceStubs service = WorkflowServiceStubs.newLocalServiceStubs();
+ // Load configuration from environment and files
+ ClientConfigProfile profile;
+ try {
+ profile = ClientConfigProfile.load();
+ } catch (IOException e) {
+ throw new RuntimeException("Failed to load client configuration", e);
+ }
- /*
- * Get a Workflow service client which can be used to start, Signal, and Query Workflow Executions.
- */
- WorkflowClient client = WorkflowClient.newInstance(service);
+ // Get a Workflow service stub.
+ WorkflowServiceStubs service =
+ WorkflowServiceStubs.newServiceStubs(profile.toWorkflowServiceStubsOptions());
+ WorkflowClient client = WorkflowClient.newInstance(service, profile.toWorkflowClientOptions());
/*
* Define the workflow factory. It is used to create workflow workers for a specific task queue.
diff --git a/core/src/main/java/io/temporal/samples/hello/HelloException.java b/core/src/main/java/io/temporal/samples/hello/HelloException.java
index 33dd03b92..6b0788043 100644
--- a/core/src/main/java/io/temporal/samples/hello/HelloException.java
+++ b/core/src/main/java/io/temporal/samples/hello/HelloException.java
@@ -1,22 +1,3 @@
-/*
- * Copyright (c) 2020 Temporal Technologies, Inc. All Rights Reserved
- *
- * Copyright 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
- * Modifications copyright (C) 2017 Uber Technologies, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"). You may not
- * use this file except in compliance with the License. A copy of the License is
- * located at
- *
- * http://aws.amazon.com/apache2.0
- *
- * or in the "license" file accompanying this file. This file is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
package io.temporal.samples.hello;
import com.google.common.base.Throwables;
@@ -27,6 +8,7 @@
import io.temporal.client.WorkflowException;
import io.temporal.client.WorkflowOptions;
import io.temporal.common.RetryOptions;
+import io.temporal.envconfig.ClientConfigProfile;
import io.temporal.serviceclient.WorkflowServiceStubs;
import io.temporal.worker.Worker;
import io.temporal.worker.WorkerFactory;
@@ -172,13 +154,18 @@ public String composeGreeting(String greeting, String name) {
*/
public static void main(String[] args) {
- // Define the workflow service.
- WorkflowServiceStubs service = WorkflowServiceStubs.newLocalServiceStubs();
+ // Load configuration from environment and files
+ ClientConfigProfile profile;
+ try {
+ profile = ClientConfigProfile.load();
+ } catch (IOException e) {
+ throw new RuntimeException("Failed to load client configuration", e);
+ }
- /*
- * Get a Workflow service client which can be used to start, Signal, and Query Workflow Executions.
- */
- WorkflowClient client = WorkflowClient.newInstance(service);
+ // Define the workflow service.
+ WorkflowServiceStubs service =
+ WorkflowServiceStubs.newServiceStubs(profile.toWorkflowServiceStubsOptions());
+ WorkflowClient client = WorkflowClient.newInstance(service, profile.toWorkflowClientOptions());
/*
* Define the workflow factory. It is used to create workflow workers for a specific task queue.
diff --git a/core/src/main/java/io/temporal/samples/hello/HelloLocalActivity.java b/core/src/main/java/io/temporal/samples/hello/HelloLocalActivity.java
index 7925712e0..c82a76e06 100644
--- a/core/src/main/java/io/temporal/samples/hello/HelloLocalActivity.java
+++ b/core/src/main/java/io/temporal/samples/hello/HelloLocalActivity.java
@@ -1,22 +1,3 @@
-/*
- * Copyright (c) 2020 Temporal Technologies, Inc. All Rights Reserved
- *
- * Copyright 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
- * Modifications copyright (C) 2017 Uber Technologies, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"). You may not
- * use this file except in compliance with the License. A copy of the License is
- * located at
- *
- * http://aws.amazon.com/apache2.0
- *
- * or in the "license" file accompanying this file. This file is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
package io.temporal.samples.hello;
import io.temporal.activity.ActivityInterface;
@@ -24,12 +5,14 @@
import io.temporal.activity.LocalActivityOptions;
import io.temporal.client.WorkflowClient;
import io.temporal.client.WorkflowOptions;
+import io.temporal.envconfig.ClientConfigProfile;
import io.temporal.serviceclient.WorkflowServiceStubs;
import io.temporal.worker.Worker;
import io.temporal.worker.WorkerFactory;
import io.temporal.workflow.Workflow;
import io.temporal.workflow.WorkflowInterface;
import io.temporal.workflow.WorkflowMethod;
+import java.io.IOException;
import java.time.Duration;
/**
@@ -109,10 +92,19 @@ public String composeGreeting(String greeting, String name) {
}
public static void main(String[] args) {
- // gRPC stubs wrapper that talks to the local docker instance of temporal service.
- WorkflowServiceStubs service = WorkflowServiceStubs.newLocalServiceStubs();
+ // Load configuration from environment and files
+ ClientConfigProfile profile;
+ try {
+ profile = ClientConfigProfile.load();
+ } catch (IOException e) {
+ throw new RuntimeException("Failed to load client configuration", e);
+ }
+
+ // gRPC stubs wrapper that talks to the temporal service.
+ WorkflowServiceStubs service =
+ WorkflowServiceStubs.newServiceStubs(profile.toWorkflowServiceStubsOptions());
// client that can be used to start and signal workflows
- WorkflowClient client = WorkflowClient.newInstance(service);
+ WorkflowClient client = WorkflowClient.newInstance(service, profile.toWorkflowClientOptions());
// worker factory that can be used to create workers for specific task queues
WorkerFactory factory = WorkerFactory.newInstance(client);
diff --git a/core/src/main/java/io/temporal/samples/hello/HelloParallelActivity.java b/core/src/main/java/io/temporal/samples/hello/HelloParallelActivity.java
index 6925cef1c..21b716070 100644
--- a/core/src/main/java/io/temporal/samples/hello/HelloParallelActivity.java
+++ b/core/src/main/java/io/temporal/samples/hello/HelloParallelActivity.java
@@ -1,32 +1,15 @@
-/*
- * Copyright (c) 2020 Temporal Technologies, Inc. All Rights Reserved
- *
- * Copyright 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
- * Modifications copyright (C) 2017 Uber Technologies, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"). You may not
- * use this file except in compliance with the License. A copy of the License is
- * located at
- *
- * http://aws.amazon.com/apache2.0
- *
- * or in the "license" file accompanying this file. This file is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
package io.temporal.samples.hello;
import io.temporal.activity.ActivityInterface;
import io.temporal.activity.ActivityOptions;
import io.temporal.client.WorkflowClient;
import io.temporal.client.WorkflowOptions;
+import io.temporal.envconfig.ClientConfigProfile;
import io.temporal.serviceclient.WorkflowServiceStubs;
import io.temporal.worker.Worker;
import io.temporal.worker.WorkerFactory;
import io.temporal.workflow.*;
+import java.io.IOException;
import java.time.Duration;
import java.util.ArrayList;
import java.util.Arrays;
@@ -135,13 +118,18 @@ public List getGreetings(List names) {
*/
public static void main(String[] args) {
- // Define the workflow service.
- WorkflowServiceStubs service = WorkflowServiceStubs.newLocalServiceStubs();
+ // Load configuration from environment and files
+ ClientConfigProfile profile;
+ try {
+ profile = ClientConfigProfile.load();
+ } catch (IOException e) {
+ throw new RuntimeException("Failed to load client configuration", e);
+ }
- /*
- * Get a Workflow service client which can be used to start, Signal, and Query Workflow Executions.
- */
- WorkflowClient client = WorkflowClient.newInstance(service);
+ // Define the workflow service.
+ WorkflowServiceStubs service =
+ WorkflowServiceStubs.newServiceStubs(profile.toWorkflowServiceStubsOptions());
+ WorkflowClient client = WorkflowClient.newInstance(service, profile.toWorkflowClientOptions());
/*
* Define the workflow factory. It is used to create workflow workers for a specific task queue.
diff --git a/core/src/main/java/io/temporal/samples/hello/HelloPeriodic.java b/core/src/main/java/io/temporal/samples/hello/HelloPeriodic.java
index f94e6b66b..f26370f21 100644
--- a/core/src/main/java/io/temporal/samples/hello/HelloPeriodic.java
+++ b/core/src/main/java/io/temporal/samples/hello/HelloPeriodic.java
@@ -1,22 +1,3 @@
-/*
- * Copyright (c) 2020 Temporal Technologies, Inc. All Rights Reserved
- *
- * Copyright 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
- * Modifications copyright (C) 2017 Uber Technologies, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"). You may not
- * use this file except in compliance with the License. A copy of the License is
- * located at
- *
- * http://aws.amazon.com/apache2.0
- *
- * or in the "license" file accompanying this file. This file is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
package io.temporal.samples.hello;
import io.temporal.activity.Activity;
@@ -26,6 +7,7 @@
import io.temporal.client.WorkflowExecutionAlreadyStarted;
import io.temporal.client.WorkflowOptions;
import io.temporal.client.WorkflowStub;
+import io.temporal.envconfig.ClientConfigProfile;
import io.temporal.serviceclient.WorkflowServiceStubs;
import io.temporal.worker.Worker;
import io.temporal.worker.WorkerFactory;
@@ -33,6 +15,7 @@
import io.temporal.workflow.Workflow;
import io.temporal.workflow.WorkflowInterface;
import io.temporal.workflow.WorkflowMethod;
+import java.io.IOException;
import java.time.Duration;
import java.util.Random;
@@ -202,13 +185,18 @@ public void greet(String greeting) {
"CatchAndPrintStackTrace") // in this simple example advanced error logging is not required
public static void main(String[] args) throws InterruptedException {
- // Define the workflow service.
- WorkflowServiceStubs service = WorkflowServiceStubs.newLocalServiceStubs();
+ // Load configuration from environment and files
+ ClientConfigProfile profile;
+ try {
+ profile = ClientConfigProfile.load();
+ } catch (IOException e) {
+ throw new RuntimeException("Failed to load client configuration", e);
+ }
- /*
- * Get a Workflow service client which can be used to start, Signal, and Query Workflow Executions.
- */
- WorkflowClient client = WorkflowClient.newInstance(service);
+ // Define the workflow service.
+ WorkflowServiceStubs service =
+ WorkflowServiceStubs.newServiceStubs(profile.toWorkflowServiceStubsOptions());
+ WorkflowClient client = WorkflowClient.newInstance(service, profile.toWorkflowClientOptions());
/*
* Define the workflow factory. It is used to create workflow workers for a specific task queue.
diff --git a/core/src/main/java/io/temporal/samples/hello/HelloPolymorphicActivity.java b/core/src/main/java/io/temporal/samples/hello/HelloPolymorphicActivity.java
index 8a4ad611d..71a2c3ffd 100644
--- a/core/src/main/java/io/temporal/samples/hello/HelloPolymorphicActivity.java
+++ b/core/src/main/java/io/temporal/samples/hello/HelloPolymorphicActivity.java
@@ -1,34 +1,17 @@
-/*
- * Copyright (c) 2020 Temporal Technologies, Inc. All Rights Reserved
- *
- * Copyright 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
- * Modifications copyright (C) 2017 Uber Technologies, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"). You may not
- * use this file except in compliance with the License. A copy of the License is
- * located at
- *
- * http://aws.amazon.com/apache2.0
- *
- * or in the "license" file accompanying this file. This file is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
package io.temporal.samples.hello;
import io.temporal.activity.ActivityInterface;
import io.temporal.activity.ActivityOptions;
import io.temporal.client.WorkflowClient;
import io.temporal.client.WorkflowOptions;
+import io.temporal.envconfig.ClientConfigProfile;
import io.temporal.serviceclient.WorkflowServiceStubs;
import io.temporal.worker.Worker;
import io.temporal.worker.WorkerFactory;
import io.temporal.workflow.Workflow;
import io.temporal.workflow.WorkflowInterface;
import io.temporal.workflow.WorkflowMethod;
+import java.io.IOException;
import java.time.Duration;
/**
@@ -169,13 +152,18 @@ public String composeGreeting(String name) {
*/
public static void main(String[] args) {
- // Define the workflow service.
- WorkflowServiceStubs service = WorkflowServiceStubs.newLocalServiceStubs();
+ // Load configuration from environment and files
+ ClientConfigProfile profile;
+ try {
+ profile = ClientConfigProfile.load();
+ } catch (IOException e) {
+ throw new RuntimeException("Failed to load client configuration", e);
+ }
- /*
- * Get a Workflow service client which can be used to start, Signal, and Query Workflow Executions.
- */
- WorkflowClient client = WorkflowClient.newInstance(service);
+ // Define the workflow service.
+ WorkflowServiceStubs service =
+ WorkflowServiceStubs.newServiceStubs(profile.toWorkflowServiceStubsOptions());
+ WorkflowClient client = WorkflowClient.newInstance(service, profile.toWorkflowClientOptions());
/*
* Define the workflow factory. It is used to create workflow workers for a specific task queue.
diff --git a/core/src/main/java/io/temporal/samples/hello/HelloQuery.java b/core/src/main/java/io/temporal/samples/hello/HelloQuery.java
index 5ee640e14..e89f83f07 100644
--- a/core/src/main/java/io/temporal/samples/hello/HelloQuery.java
+++ b/core/src/main/java/io/temporal/samples/hello/HelloQuery.java
@@ -1,26 +1,8 @@
-/*
- * Copyright (c) 2020 Temporal Technologies, Inc. All Rights Reserved
- *
- * Copyright 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
- * Modifications copyright (C) 2017 Uber Technologies, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"). You may not
- * use this file except in compliance with the License. A copy of the License is
- * located at
- *
- * http://aws.amazon.com/apache2.0
- *
- * or in the "license" file accompanying this file. This file is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
package io.temporal.samples.hello;
import io.temporal.client.WorkflowClient;
import io.temporal.client.WorkflowOptions;
+import io.temporal.envconfig.ClientConfigProfile;
import io.temporal.serviceclient.WorkflowServiceStubs;
import io.temporal.worker.Worker;
import io.temporal.worker.WorkerFactory;
@@ -28,6 +10,7 @@
import io.temporal.workflow.Workflow;
import io.temporal.workflow.WorkflowInterface;
import io.temporal.workflow.WorkflowMethod;
+import java.io.IOException;
import java.time.Duration;
/** Sample Temporal Workflow Definition that demonstrates how to Query a Workflow. */
@@ -97,13 +80,18 @@ public String queryGreeting() {
*/
public static void main(String[] args) throws InterruptedException {
- // Define the workflow service.
- WorkflowServiceStubs service = WorkflowServiceStubs.newLocalServiceStubs();
+ // Load configuration from environment and files
+ ClientConfigProfile profile;
+ try {
+ profile = ClientConfigProfile.load();
+ } catch (IOException e) {
+ throw new RuntimeException("Failed to load client configuration", e);
+ }
- /*
- * Get a Workflow service client which can be used to start, Signal, and Query Workflow Executions.
- */
- WorkflowClient client = WorkflowClient.newInstance(service);
+ // Define the workflow service.
+ WorkflowServiceStubs service =
+ WorkflowServiceStubs.newServiceStubs(profile.toWorkflowServiceStubsOptions());
+ WorkflowClient client = WorkflowClient.newInstance(service, profile.toWorkflowClientOptions());
/*
* Define the workflow factory. It is used to create workflow workers for a specific task queue.
diff --git a/core/src/main/java/io/temporal/samples/hello/HelloSaga.java b/core/src/main/java/io/temporal/samples/hello/HelloSaga.java
index d0180e35d..4fb3bc6a1 100644
--- a/core/src/main/java/io/temporal/samples/hello/HelloSaga.java
+++ b/core/src/main/java/io/temporal/samples/hello/HelloSaga.java
@@ -1,22 +1,3 @@
-/*
- * Copyright (c) 2020 Temporal Technologies, Inc. All Rights Reserved
- *
- * Copyright 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
- * Modifications copyright (C) 2017 Uber Technologies, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"). You may not
- * use this file except in compliance with the License. A copy of the License is
- * located at
- *
- * http://aws.amazon.com/apache2.0
- *
- * or in the "license" file accompanying this file. This file is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
package io.temporal.samples.hello;
import io.temporal.activity.ActivityInterface;
@@ -24,6 +5,7 @@
import io.temporal.activity.ActivityOptions;
import io.temporal.client.WorkflowClient;
import io.temporal.client.WorkflowOptions;
+import io.temporal.envconfig.ClientConfigProfile;
import io.temporal.serviceclient.WorkflowServiceStubs;
import io.temporal.worker.Worker;
import io.temporal.worker.WorkerFactory;
@@ -33,6 +15,7 @@
import io.temporal.workflow.Workflow;
import io.temporal.workflow.WorkflowInterface;
import io.temporal.workflow.WorkflowMethod;
+import java.io.IOException;
import java.time.Duration;
/**
@@ -277,13 +260,18 @@ public void execute() {
*/
public static void main(String[] args) {
- // Define the workflow service.
- WorkflowServiceStubs service = WorkflowServiceStubs.newLocalServiceStubs();
+ // Load configuration from environment and files
+ ClientConfigProfile profile;
+ try {
+ profile = ClientConfigProfile.load();
+ } catch (IOException e) {
+ throw new RuntimeException("Failed to load client configuration", e);
+ }
- /*
- * Get a Workflow service client which can be used to start, Signal, and Query Workflow Executions.
- */
- WorkflowClient client = WorkflowClient.newInstance(service);
+ // Define the workflow service.
+ WorkflowServiceStubs service =
+ WorkflowServiceStubs.newServiceStubs(profile.toWorkflowServiceStubsOptions());
+ WorkflowClient client = WorkflowClient.newInstance(service, profile.toWorkflowClientOptions());
/*
* Define the workflow factory. It is used to create workflow workers for a specific task queue.
diff --git a/core/src/main/java/io/temporal/samples/hello/HelloSchedules.java b/core/src/main/java/io/temporal/samples/hello/HelloSchedules.java
index 22a86f61f..698f4f83b 100644
--- a/core/src/main/java/io/temporal/samples/hello/HelloSchedules.java
+++ b/core/src/main/java/io/temporal/samples/hello/HelloSchedules.java
@@ -1,22 +1,3 @@
-/*
- * Copyright (c) 2020 Temporal Technologies, Inc. All Rights Reserved
- *
- * Copyright 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
- * Modifications copyright (C) 2017 Uber Technologies, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"). You may not
- * use this file except in compliance with the License. A copy of the License is
- * located at
- *
- * http://aws.amazon.com/apache2.0
- *
- * or in the "license" file accompanying this file. This file is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
package io.temporal.samples.hello;
import io.temporal.activity.Activity;
@@ -28,12 +9,14 @@
import io.temporal.client.WorkflowOptions;
import io.temporal.client.schedules.*;
import io.temporal.common.converter.GlobalDataConverter;
+import io.temporal.envconfig.ClientConfigProfile;
import io.temporal.serviceclient.WorkflowServiceStubs;
import io.temporal.worker.Worker;
import io.temporal.worker.WorkerFactory;
import io.temporal.workflow.Workflow;
import io.temporal.workflow.WorkflowInterface;
import io.temporal.workflow.WorkflowMethod;
+import java.io.IOException;
import java.time.Duration;
import java.time.Instant;
import java.util.Collections;
@@ -149,13 +132,18 @@ public void greet(String greeting) {
*/
public static void main(String[] args) throws InterruptedException {
- // Get a Workflow service stub.
- WorkflowServiceStubs service = WorkflowServiceStubs.newLocalServiceStubs();
+ // Load configuration from environment and files
+ ClientConfigProfile profile;
+ try {
+ profile = ClientConfigProfile.load();
+ } catch (IOException e) {
+ throw new RuntimeException("Failed to load client configuration", e);
+ }
- /*
- * Get a Workflow service client which can be used to start, Signal, and Query Workflow Executions.
- */
- WorkflowClient client = WorkflowClient.newInstance(service);
+ // Get a Workflow service stub.
+ WorkflowServiceStubs service =
+ WorkflowServiceStubs.newServiceStubs(profile.toWorkflowServiceStubsOptions());
+ WorkflowClient client = WorkflowClient.newInstance(service, profile.toWorkflowClientOptions());
/*
* Define the workflow factory. It is used to create workflow workers for a specific task queue.
diff --git a/core/src/main/java/io/temporal/samples/hello/HelloSearchAttributes.java b/core/src/main/java/io/temporal/samples/hello/HelloSearchAttributes.java
index e9d28cc01..7115ebaa5 100644
--- a/core/src/main/java/io/temporal/samples/hello/HelloSearchAttributes.java
+++ b/core/src/main/java/io/temporal/samples/hello/HelloSearchAttributes.java
@@ -1,22 +1,3 @@
-/*
- * Copyright (c) 2020 Temporal Technologies, Inc. All Rights Reserved
- *
- * Copyright 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
- * Modifications copyright (C) 2017 Uber Technologies, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"). You may not
- * use this file except in compliance with the License. A copy of the License is
- * located at
- *
- * http://aws.amazon.com/apache2.0
- *
- * or in the "license" file accompanying this file. This file is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
package io.temporal.samples.hello;
import io.temporal.activity.ActivityInterface;
@@ -31,12 +12,14 @@
import io.temporal.client.WorkflowOptions;
import io.temporal.common.converter.DataConverter;
import io.temporal.common.converter.GlobalDataConverter;
+import io.temporal.envconfig.ClientConfigProfile;
import io.temporal.serviceclient.WorkflowServiceStubs;
import io.temporal.worker.Worker;
import io.temporal.worker.WorkerFactory;
import io.temporal.workflow.Workflow;
import io.temporal.workflow.WorkflowInterface;
import io.temporal.workflow.WorkflowMethod;
+import java.io.IOException;
import java.time.Duration;
import java.time.ZoneId;
import java.time.ZonedDateTime;
@@ -132,13 +115,18 @@ public String composeGreeting(String greeting, String name) {
*/
public static void main(String[] args) {
- // Define the workflow service.
- WorkflowServiceStubs service = WorkflowServiceStubs.newLocalServiceStubs();
+ // Load configuration from environment and files
+ ClientConfigProfile profile;
+ try {
+ profile = ClientConfigProfile.load();
+ } catch (IOException e) {
+ throw new RuntimeException("Failed to load client configuration", e);
+ }
- /*
- * Get a Workflow service client which can be used to start, Signal, and Query Workflow Executions.
- */
- WorkflowClient client = WorkflowClient.newInstance(service);
+ // Define the workflow service.
+ WorkflowServiceStubs service =
+ WorkflowServiceStubs.newServiceStubs(profile.toWorkflowServiceStubsOptions());
+ WorkflowClient client = WorkflowClient.newInstance(service, profile.toWorkflowClientOptions());
/*
* Define the workflow factory. It is used to create workflow workers for a specific task queue.
diff --git a/core/src/main/java/io/temporal/samples/hello/HelloSideEffect.java b/core/src/main/java/io/temporal/samples/hello/HelloSideEffect.java
index faa36f005..f894dc343 100644
--- a/core/src/main/java/io/temporal/samples/hello/HelloSideEffect.java
+++ b/core/src/main/java/io/temporal/samples/hello/HelloSideEffect.java
@@ -1,28 +1,10 @@
-/*
- * Copyright (c) 2020 Temporal Technologies, Inc. All Rights Reserved
- *
- * Copyright 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
- * Modifications copyright (C) 2017 Uber Technologies, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"). You may not
- * use this file except in compliance with the License. A copy of the License is
- * located at
- *
- * http://aws.amazon.com/apache2.0
- *
- * or in the "license" file accompanying this file. This file is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
package io.temporal.samples.hello;
import io.temporal.activity.ActivityInterface;
import io.temporal.activity.ActivityOptions;
import io.temporal.client.WorkflowClient;
import io.temporal.client.WorkflowOptions;
+import io.temporal.envconfig.ClientConfigProfile;
import io.temporal.serviceclient.WorkflowServiceStubs;
import io.temporal.worker.Worker;
import io.temporal.worker.WorkerFactory;
@@ -30,6 +12,7 @@
import io.temporal.workflow.Workflow;
import io.temporal.workflow.WorkflowInterface;
import io.temporal.workflow.WorkflowMethod;
+import java.io.IOException;
import java.security.SecureRandom;
import java.time.Duration;
import java.util.Random;
@@ -178,14 +161,18 @@ public String sayGoodBye(String greeting) {
*/
public static void main(String[] args) {
- // Define the workflow service.
- WorkflowServiceStubs service = WorkflowServiceStubs.newLocalServiceStubs();
+ // Load configuration from environment and files
+ ClientConfigProfile profile;
+ try {
+ profile = ClientConfigProfile.load();
+ } catch (IOException e) {
+ throw new RuntimeException("Failed to load client configuration", e);
+ }
- /*
- * Get a Workflow service client which can be used to start, Signal, and Query Workflow
- * Executions.
- */
- WorkflowClient client = WorkflowClient.newInstance(service);
+ // Define the workflow service.
+ WorkflowServiceStubs service =
+ WorkflowServiceStubs.newServiceStubs(profile.toWorkflowServiceStubsOptions());
+ WorkflowClient client = WorkflowClient.newInstance(service, profile.toWorkflowClientOptions());
/*
* Define the workflow factory. It is used to create workflow workers for a specific task queue.
diff --git a/core/src/main/java/io/temporal/samples/hello/HelloSignal.java b/core/src/main/java/io/temporal/samples/hello/HelloSignal.java
index a302816dd..e2e50fc85 100644
--- a/core/src/main/java/io/temporal/samples/hello/HelloSignal.java
+++ b/core/src/main/java/io/temporal/samples/hello/HelloSignal.java
@@ -1,26 +1,8 @@
-/*
- * Copyright (c) 2020 Temporal Technologies, Inc. All Rights Reserved
- *
- * Copyright 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
- * Modifications copyright (C) 2017 Uber Technologies, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"). You may not
- * use this file except in compliance with the License. A copy of the License is
- * located at
- *
- * http://aws.amazon.com/apache2.0
- *
- * or in the "license" file accompanying this file. This file is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
package io.temporal.samples.hello;
import io.temporal.client.WorkflowClient;
import io.temporal.client.WorkflowOptions;
+import io.temporal.envconfig.ClientConfigProfile;
import io.temporal.serviceclient.WorkflowServiceStubs;
import io.temporal.worker.Worker;
import io.temporal.worker.WorkerFactory;
@@ -28,6 +10,7 @@
import io.temporal.workflow.Workflow;
import io.temporal.workflow.WorkflowInterface;
import io.temporal.workflow.WorkflowMethod;
+import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
@@ -113,13 +96,18 @@ public void exit() {
*/
public static void main(String[] args) throws Exception {
- // Get a Workflow service stub.
- WorkflowServiceStubs service = WorkflowServiceStubs.newLocalServiceStubs();
+ // Load configuration from environment and files
+ ClientConfigProfile profile;
+ try {
+ profile = ClientConfigProfile.load();
+ } catch (IOException e) {
+ throw new RuntimeException("Failed to load client configuration", e);
+ }
- /*
- * Get a Workflow service client which can be used to start, Signal, and Query Workflow Executions.
- */
- WorkflowClient client = WorkflowClient.newInstance(service);
+ // Get a Workflow service stub.
+ WorkflowServiceStubs service =
+ WorkflowServiceStubs.newServiceStubs(profile.toWorkflowServiceStubsOptions());
+ WorkflowClient client = WorkflowClient.newInstance(service, profile.toWorkflowClientOptions());
/*
* Define the workflow factory. It is used to create workflow workers for a specific task queue.
diff --git a/core/src/main/java/io/temporal/samples/hello/HelloSignalWithStartAndWorkflowInit.java b/core/src/main/java/io/temporal/samples/hello/HelloSignalWithStartAndWorkflowInit.java
new file mode 100644
index 000000000..f579388ae
--- /dev/null
+++ b/core/src/main/java/io/temporal/samples/hello/HelloSignalWithStartAndWorkflowInit.java
@@ -0,0 +1,219 @@
+package io.temporal.samples.hello;
+
+import io.temporal.activity.ActivityInterface;
+import io.temporal.activity.ActivityOptions;
+import io.temporal.client.WorkflowClient;
+import io.temporal.client.WorkflowFailedException;
+import io.temporal.client.WorkflowOptions;
+import io.temporal.client.WorkflowStub;
+import io.temporal.envconfig.ClientConfigProfile;
+import io.temporal.serviceclient.WorkflowServiceStubs;
+import io.temporal.worker.Worker;
+import io.temporal.worker.WorkerFactory;
+import io.temporal.worker.WorkflowImplementationOptions;
+import io.temporal.workflow.*;
+import java.io.IOException;
+import java.time.Duration;
+import java.util.ArrayList;
+import java.util.List;
+import org.apache.commons.lang.StringUtils;
+
+/**
+ * Sample Temporal workflow that demonstrates how to use WorkflowInit with clients starting
+ * execution using SignalWithStart
+ */
+public class HelloSignalWithStartAndWorkflowInit {
+ static final String TASK_QUEUE = "HelloWithInitTaskQueue";
+
+ public interface MyWorkflow {
+ @WorkflowMethod
+ String greet(Person person);
+
+ @SignalMethod
+ void addGreeting(Person person);
+ }
+
+ @WorkflowInterface
+ public interface MyWorkflowWithInit extends MyWorkflow {}
+
+ @WorkflowInterface
+ public interface MyWorkflowNoInit extends MyWorkflow {}
+
+ public static class WithInitMyWorkflowImpl implements MyWorkflowWithInit {
+ // We dont initialize peopleToGreet on purpose
+ private List peopleToGreet;
+ private MyGreetingActivities activities =
+ Workflow.newActivityStub(
+ MyGreetingActivities.class,
+ ActivityOptions.newBuilder().setStartToCloseTimeout(Duration.ofSeconds(2)).build());
+
+ @WorkflowInit
+ public WithInitMyWorkflowImpl(Person person) {
+ peopleToGreet = new ArrayList<>();
+ }
+
+ @Override
+ public String greet(Person person) {
+ peopleToGreet.add(person);
+ List greetings = new ArrayList<>();
+
+ while (!peopleToGreet.isEmpty()) {
+ // run activity...
+ greetings.add(activities.greet(peopleToGreet.get(0)));
+ peopleToGreet.remove(0);
+ }
+ return StringUtils.join(greetings, ",");
+ }
+
+ @Override
+ public void addGreeting(Person person) {
+ peopleToGreet.add(person);
+ }
+ }
+
+ public static class WithoutInitMyWorkflowImpl implements MyWorkflowNoInit {
+ // We dont initialize peopleToGreet on purpose
+ private List peopleToGreet;
+ private MyGreetingActivities activities =
+ Workflow.newActivityStub(
+ MyGreetingActivities.class,
+ ActivityOptions.newBuilder().setStartToCloseTimeout(Duration.ofSeconds(2)).build());
+
+ @Override
+ public String greet(Person person) {
+ peopleToGreet.add(person);
+ List greetings = new ArrayList<>();
+
+ while (!peopleToGreet.isEmpty()) {
+ // run activity...
+ greetings.add(activities.greet(peopleToGreet.get(0)));
+ peopleToGreet.remove(0);
+ }
+ return StringUtils.join(greetings, ",");
+ }
+
+ @Override
+ public void addGreeting(Person person) {
+ peopleToGreet.add(person);
+ }
+ }
+
+ @ActivityInterface
+ public interface MyGreetingActivities {
+ public String greet(Person person);
+ }
+
+ public static class MyGreetingActivitiesImpl implements MyGreetingActivities {
+ @Override
+ public String greet(Person person) {
+ return "Hello " + person.firstName + " " + person.lastName;
+ }
+ }
+
+ public static class Person {
+ String firstName;
+ String lastName;
+ int age;
+
+ public Person() {}
+
+ public Person(String firstName, String lastName, int age) {
+ this.firstName = firstName;
+ this.lastName = lastName;
+ this.age = age;
+ }
+
+ public String getFirstName() {
+ return firstName;
+ }
+
+ public void setFirstName(String firstName) {
+ this.firstName = firstName;
+ }
+
+ public String getLastName() {
+ return lastName;
+ }
+
+ public void setLastName(String lastName) {
+ this.lastName = lastName;
+ }
+
+ public int getAge() {
+ return age;
+ }
+
+ public void setAge(int age) {
+ this.age = age;
+ }
+ }
+
+ public static void main(String[] args) {
+ // Load configuration from environment and files
+ ClientConfigProfile profile;
+ try {
+ profile = ClientConfigProfile.load();
+ } catch (IOException e) {
+ throw new RuntimeException("Failed to load client configuration", e);
+ }
+
+ WorkflowServiceStubs service =
+ WorkflowServiceStubs.newServiceStubs(profile.toWorkflowServiceStubsOptions());
+ WorkflowClient client = WorkflowClient.newInstance(service, profile.toWorkflowClientOptions());
+ WorkerFactory factory = WorkerFactory.newInstance(client);
+ Worker worker = factory.newWorker(TASK_QUEUE);
+
+ worker.registerWorkflowImplementationTypes(WithInitMyWorkflowImpl.class);
+ // We explicitly want to fail this workflow on NPE as thats what we expect without WorkflowInit
+ // As we didnt initialize peopleToGreet on purpose
+ worker.registerWorkflowImplementationTypes(
+ WorkflowImplementationOptions.newBuilder()
+ .setFailWorkflowExceptionTypes(NullPointerException.class)
+ .build(),
+ WithoutInitMyWorkflowImpl.class);
+ worker.registerActivitiesImplementations(new MyGreetingActivitiesImpl());
+
+ factory.start();
+
+ MyWorkflowWithInit withInitStub =
+ client.newWorkflowStub(
+ MyWorkflowWithInit.class,
+ WorkflowOptions.newBuilder()
+ .setWorkflowId("with-init")
+ .setTaskQueue(TASK_QUEUE)
+ .build());
+ // Start with init workflow which is expected to succeed
+ // As WorkflowInit will initialize peopleToGreet before signal handler is invoked
+ WorkflowStub.fromTyped(withInitStub)
+ .signalWithStart(
+ "addGreeting",
+ new Object[] {new Person("Michael", "Jordan", 55)},
+ new Object[] {new Person("John", "Stockton", 57)});
+
+ String result = WorkflowStub.fromTyped(withInitStub).getResult(String.class);
+ System.out.println("Result: " + result);
+
+ // Start without init, this execution is expected to fail as we set
+ // NullPointerException as a workflow failure type
+ // NPE is caused because we did not initialize peopleToGreet array
+ MyWorkflowNoInit noInitStub =
+ client.newWorkflowStub(
+ MyWorkflowNoInit.class,
+ WorkflowOptions.newBuilder()
+ .setWorkflowId("without-init")
+ .setTaskQueue(TASK_QUEUE)
+ .build());
+ WorkflowStub.fromTyped(noInitStub)
+ .signalWithStart(
+ "addGreeting",
+ new Object[] {new Person("Michael", "Jordan", 55)},
+ new Object[] {new Person("John", "Stockton", 57)});
+ try {
+ WorkflowStub.fromTyped(noInitStub).getResult(String.class);
+ } catch (WorkflowFailedException e) {
+ System.out.println("Expected workflow failure: " + e.getMessage());
+ }
+
+ System.exit(0);
+ }
+}
diff --git a/core/src/main/java/io/temporal/samples/hello/HelloSignalWithTimer.java b/core/src/main/java/io/temporal/samples/hello/HelloSignalWithTimer.java
index 804034ffa..ea2d29d2a 100644
--- a/core/src/main/java/io/temporal/samples/hello/HelloSignalWithTimer.java
+++ b/core/src/main/java/io/temporal/samples/hello/HelloSignalWithTimer.java
@@ -1,22 +1,3 @@
-/*
- * Copyright (c) 2020 Temporal Technologies, Inc. All Rights Reserved
- *
- * Copyright 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
- * Modifications copyright (C) 2017 Uber Technologies, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"). You may not
- * use this file except in compliance with the License. A copy of the License is
- * located at
- *
- * http://aws.amazon.com/apache2.0
- *
- * or in the "license" file accompanying this file. This file is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
package io.temporal.samples.hello;
import io.temporal.activity.ActivityInterface;
@@ -24,11 +5,13 @@
import io.temporal.client.WorkflowClient;
import io.temporal.client.WorkflowOptions;
import io.temporal.client.WorkflowStub;
+import io.temporal.envconfig.ClientConfigProfile;
import io.temporal.failure.CanceledFailure;
import io.temporal.serviceclient.WorkflowServiceStubs;
import io.temporal.worker.Worker;
import io.temporal.worker.WorkerFactory;
import io.temporal.workflow.*;
+import java.io.IOException;
import java.time.Duration;
import org.slf4j.Logger;
@@ -135,8 +118,17 @@ public void processValue(String value) {
}
public static void main(String[] args) {
- WorkflowServiceStubs service = WorkflowServiceStubs.newLocalServiceStubs();
- WorkflowClient client = WorkflowClient.newInstance(service);
+ // Load configuration from environment and files
+ ClientConfigProfile profile;
+ try {
+ profile = ClientConfigProfile.load();
+ } catch (IOException e) {
+ throw new RuntimeException("Failed to load client configuration", e);
+ }
+
+ WorkflowServiceStubs service =
+ WorkflowServiceStubs.newServiceStubs(profile.toWorkflowServiceStubsOptions());
+ WorkflowClient client = WorkflowClient.newInstance(service, profile.toWorkflowClientOptions());
WorkerFactory factory = WorkerFactory.newInstance(client);
Worker worker = factory.newWorker(TASK_QUEUE);
diff --git a/core/src/main/java/io/temporal/samples/hello/HelloTypedSearchAttributes.java b/core/src/main/java/io/temporal/samples/hello/HelloTypedSearchAttributes.java
index df196d762..8629dfd62 100644
--- a/core/src/main/java/io/temporal/samples/hello/HelloTypedSearchAttributes.java
+++ b/core/src/main/java/io/temporal/samples/hello/HelloTypedSearchAttributes.java
@@ -1,22 +1,3 @@
-/*
- * Copyright (c) 2020 Temporal Technologies, Inc. All Rights Reserved
- *
- * Copyright 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
- * Modifications copyright (C) 2017 Uber Technologies, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"). You may not
- * use this file except in compliance with the License. A copy of the License is
- * located at
- *
- * http://aws.amazon.com/apache2.0
- *
- * or in the "license" file accompanying this file. This file is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
package io.temporal.samples.hello;
import io.temporal.activity.ActivityInterface;
@@ -25,12 +6,14 @@
import io.temporal.client.WorkflowClient;
import io.temporal.client.WorkflowOptions;
import io.temporal.common.SearchAttributeKey;
+import io.temporal.envconfig.ClientConfigProfile;
import io.temporal.serviceclient.WorkflowServiceStubs;
import io.temporal.worker.Worker;
import io.temporal.worker.WorkerFactory;
import io.temporal.workflow.Workflow;
import io.temporal.workflow.WorkflowInterface;
import io.temporal.workflow.WorkflowMethod;
+import java.io.IOException;
import java.time.Duration;
import java.time.OffsetDateTime;
import java.time.ZoneOffset;
@@ -168,13 +151,18 @@ public String composeGreeting(String greeting, List salutations, String
*/
public static void main(String[] args) {
- // Define the workflow service.
- WorkflowServiceStubs service = WorkflowServiceStubs.newLocalServiceStubs();
+ // Load configuration from environment and files
+ ClientConfigProfile profile;
+ try {
+ profile = ClientConfigProfile.load();
+ } catch (IOException e) {
+ throw new RuntimeException("Failed to load client configuration", e);
+ }
- /*
- * Get a Workflow service client which can be used to start, Signal, and Query Workflow Executions.
- */
- WorkflowClient client = WorkflowClient.newInstance(service);
+ // Define the workflow service.
+ WorkflowServiceStubs service =
+ WorkflowServiceStubs.newServiceStubs(profile.toWorkflowServiceStubsOptions());
+ WorkflowClient client = WorkflowClient.newInstance(service, profile.toWorkflowClientOptions());
/*
* Define the workflow factory. It is used to create workflow workers for a specific task queue.
diff --git a/core/src/main/java/io/temporal/samples/hello/HelloUpdate.java b/core/src/main/java/io/temporal/samples/hello/HelloUpdate.java
index 79f20336b..6df8a8694 100644
--- a/core/src/main/java/io/temporal/samples/hello/HelloUpdate.java
+++ b/core/src/main/java/io/temporal/samples/hello/HelloUpdate.java
@@ -1,22 +1,3 @@
-/*
- * Copyright (c) 2020 Temporal Technologies, Inc. All Rights Reserved
- *
- * Copyright 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
- * Modifications copyright (C) 2017 Uber Technologies, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"). You may not
- * use this file except in compliance with the License. A copy of the License is
- * located at
- *
- * http://aws.amazon.com/apache2.0
- *
- * or in the "license" file accompanying this file. This file is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
package io.temporal.samples.hello;
import com.google.common.base.Throwables;
@@ -25,6 +6,7 @@
import io.temporal.client.WorkflowOptions;
import io.temporal.client.WorkflowStub;
import io.temporal.client.WorkflowUpdateException;
+import io.temporal.envconfig.ClientConfigProfile;
import io.temporal.failure.ApplicationFailure;
import io.temporal.serviceclient.WorkflowServiceStubs;
import io.temporal.worker.Worker;
@@ -35,6 +17,7 @@
import io.temporal.workflow.Workflow;
import io.temporal.workflow.WorkflowInterface;
import io.temporal.workflow.WorkflowMethod;
+import java.io.IOException;
import java.time.Duration;
import java.util.ArrayList;
import java.util.List;
@@ -176,13 +159,18 @@ public void exit() {
*/
public static void main(String[] args) throws Exception {
- // Get a Workflow service stub.
- WorkflowServiceStubs service = WorkflowServiceStubs.newLocalServiceStubs();
+ // Load configuration from environment and files
+ ClientConfigProfile profile;
+ try {
+ profile = ClientConfigProfile.load();
+ } catch (IOException e) {
+ throw new RuntimeException("Failed to load client configuration", e);
+ }
- /*
- * Get a Workflow service client which can be used to start, Signal, and Query Workflow Executions.
- */
- WorkflowClient client = WorkflowClient.newInstance(service);
+ // Get a Workflow service stub.
+ WorkflowServiceStubs service =
+ WorkflowServiceStubs.newServiceStubs(profile.toWorkflowServiceStubsOptions());
+ WorkflowClient client = WorkflowClient.newInstance(service, profile.toWorkflowClientOptions());
/*
* Define the workflow factory. It is used to create workflow workers for a specific task queue.
diff --git a/core/src/main/java/io/temporal/samples/hello/HelloWorkflowTimer.java b/core/src/main/java/io/temporal/samples/hello/HelloWorkflowTimer.java
index a03a8104b..ec6f8a5ba 100644
--- a/core/src/main/java/io/temporal/samples/hello/HelloWorkflowTimer.java
+++ b/core/src/main/java/io/temporal/samples/hello/HelloWorkflowTimer.java
@@ -1,22 +1,3 @@
-/*
- * Copyright (c) 2020 Temporal Technologies, Inc. All Rights Reserved
- *
- * Copyright 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
- * Modifications copyright (C) 2017 Uber Technologies, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"). You may not
- * use this file except in compliance with the License. A copy of the License is
- * located at
- *
- * http://aws.amazon.com/apache2.0
- *
- * or in the "license" file accompanying this file. This file is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
package io.temporal.samples.hello;
import io.temporal.activity.*;
@@ -24,6 +5,7 @@
import io.temporal.client.WorkflowClient;
import io.temporal.client.WorkflowOptions;
import io.temporal.client.WorkflowStub;
+import io.temporal.envconfig.ClientConfigProfile;
import io.temporal.failure.ActivityFailure;
import io.temporal.failure.CanceledFailure;
import io.temporal.failure.ChildWorkflowFailure;
@@ -31,6 +13,7 @@
import io.temporal.worker.Worker;
import io.temporal.worker.WorkerFactory;
import io.temporal.workflow.*;
+import java.io.IOException;
import java.time.Duration;
/** Sample shows how to use workflow timer instead of WorkflowOptions->Run/ExecutionTimeout */
@@ -209,10 +192,19 @@ public String executeChild(String input) {
}
public static void main(String[] args) {
+ // Load configuration from environment and files
+ ClientConfigProfile profile;
+ try {
+ profile = ClientConfigProfile.load();
+ } catch (IOException e) {
+ throw new RuntimeException("Failed to load client configuration", e);
+ }
+
// Create service stubs
- WorkflowServiceStubs service = WorkflowServiceStubs.newLocalServiceStubs();
- // Crete workflow client
- WorkflowClient client = WorkflowClient.newInstance(service);
+ WorkflowServiceStubs service =
+ WorkflowServiceStubs.newServiceStubs(profile.toWorkflowServiceStubsOptions());
+ // Create workflow client
+ WorkflowClient client = WorkflowClient.newInstance(service, profile.toWorkflowClientOptions());
// Create worker factory
WorkerFactory factory = WorkerFactory.newInstance(client);
diff --git a/core/src/main/java/io/temporal/samples/hello/README.md b/core/src/main/java/io/temporal/samples/hello/README.md
index 41dd18271..c8ebbdb42 100644
--- a/core/src/main/java/io/temporal/samples/hello/README.md
+++ b/core/src/main/java/io/temporal/samples/hello/README.md
@@ -34,4 +34,5 @@ To run each hello world sample, use one of the following commands:
./gradlew -q execute -PmainClass=io.temporal.samples.hello.HelloSideEffect
./gradlew -q execute -PmainClass=io.temporal.samples.hello.HelloUpdate
./gradlew -q execute -PmainClass=io.temporal.samples.hello.HelloSignalWithTimer
+./gradlew -q execute -PmainClass=io.temporal.samples.hello.HelloSignalWithStartAndWorkflowInit
```
diff --git a/core/src/main/java/io/temporal/samples/keymanagementencryption/awsencryptionsdk/EncryptedPayloads.java b/core/src/main/java/io/temporal/samples/keymanagementencryption/awsencryptionsdk/EncryptedPayloads.java
index 6052c9d7f..03392674c 100644
--- a/core/src/main/java/io/temporal/samples/keymanagementencryption/awsencryptionsdk/EncryptedPayloads.java
+++ b/core/src/main/java/io/temporal/samples/keymanagementencryption/awsencryptionsdk/EncryptedPayloads.java
@@ -1,22 +1,3 @@
-/*
- * Copyright (c) 2020 Temporal Technologies, Inc. All Rights Reserved
- *
- * Copyright 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
- * Modifications copyright (C) 2017 Uber Technologies, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"). You may not
- * use this file except in compliance with the License. A copy of the License is
- * located at
- *
- * http://aws.amazon.com/apache2.0
- *
- * or in the "license" file accompanying this file. This file is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
package io.temporal.samples.keymanagementencryption.awsencryptionsdk;
import io.temporal.client.WorkflowClient;
@@ -24,10 +5,12 @@
import io.temporal.client.WorkflowOptions;
import io.temporal.common.converter.CodecDataConverter;
import io.temporal.common.converter.DefaultDataConverter;
+import io.temporal.envconfig.ClientConfigProfile;
import io.temporal.samples.hello.HelloActivity;
import io.temporal.serviceclient.WorkflowServiceStubs;
import io.temporal.worker.Worker;
import io.temporal.worker.WorkerFactory;
+import java.io.IOException;
import java.util.Collections;
import software.amazon.cryptography.materialproviders.IKeyring;
import software.amazon.cryptography.materialproviders.MaterialProviders;
@@ -55,7 +38,16 @@ public static void main(String[] args) {
CreateAwsKmsMultiKeyringInput.builder().generator(generatorKey).build();
final IKeyring kmsKeyring = materialProviders.CreateAwsKmsMultiKeyring(keyringInput);
// gRPC stubs wrapper that talks to the local docker instance of temporal service.
- WorkflowServiceStubs service = WorkflowServiceStubs.newLocalServiceStubs();
+ // Load configuration from environment and files
+ ClientConfigProfile profile;
+ try {
+ profile = ClientConfigProfile.load();
+ } catch (IOException e) {
+ throw new RuntimeException("Failed to load client configuration", e);
+ }
+
+ WorkflowServiceStubs service =
+ WorkflowServiceStubs.newServiceStubs(profile.toWorkflowServiceStubsOptions());
// client that can be used to start and signal workflows
WorkflowClient client =
WorkflowClient.newInstance(
diff --git a/core/src/main/java/io/temporal/samples/keymanagementencryption/awsencryptionsdk/KeyringCodec.java b/core/src/main/java/io/temporal/samples/keymanagementencryption/awsencryptionsdk/KeyringCodec.java
index e8d669408..a7c9988bd 100644
--- a/core/src/main/java/io/temporal/samples/keymanagementencryption/awsencryptionsdk/KeyringCodec.java
+++ b/core/src/main/java/io/temporal/samples/keymanagementencryption/awsencryptionsdk/KeyringCodec.java
@@ -1,22 +1,3 @@
-/*
- * Copyright (c) 2020 Temporal Technologies, Inc. All Rights Reserved
- *
- * Copyright 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
- * Modifications copyright (C) 2017 Uber Technologies, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"). You may not
- * use this file except in compliance with the License. A copy of the License is
- * located at
- *
- * http://aws.amazon.com/apache2.0
- *
- * or in the "license" file accompanying this file. This file is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
package io.temporal.samples.keymanagementencryption.awsencryptionsdk;
import com.amazonaws.encryptionsdk.AwsCrypto;
diff --git a/core/src/main/java/io/temporal/samples/listworkflows/Customer.java b/core/src/main/java/io/temporal/samples/listworkflows/Customer.java
index 6ec0780fb..6777bcb55 100644
--- a/core/src/main/java/io/temporal/samples/listworkflows/Customer.java
+++ b/core/src/main/java/io/temporal/samples/listworkflows/Customer.java
@@ -1,22 +1,3 @@
-/*
- * Copyright (c) 2020 Temporal Technologies, Inc. All Rights Reserved
- *
- * Copyright 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
- * Modifications copyright (C) 2017 Uber Technologies, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"). You may not
- * use this file except in compliance with the License. A copy of the License is
- * located at
- *
- * http://aws.amazon.com/apache2.0
- *
- * or in the "license" file accompanying this file. This file is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
package io.temporal.samples.listworkflows;
public class Customer {
diff --git a/core/src/main/java/io/temporal/samples/listworkflows/CustomerActivities.java b/core/src/main/java/io/temporal/samples/listworkflows/CustomerActivities.java
index 609b4a86f..a49c8f479 100644
--- a/core/src/main/java/io/temporal/samples/listworkflows/CustomerActivities.java
+++ b/core/src/main/java/io/temporal/samples/listworkflows/CustomerActivities.java
@@ -1,22 +1,3 @@
-/*
- * Copyright (c) 2020 Temporal Technologies, Inc. All Rights Reserved
- *
- * Copyright 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
- * Modifications copyright (C) 2017 Uber Technologies, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"). You may not
- * use this file except in compliance with the License. A copy of the License is
- * located at
- *
- * http://aws.amazon.com/apache2.0
- *
- * or in the "license" file accompanying this file. This file is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
package io.temporal.samples.listworkflows;
import io.temporal.activity.ActivityInterface;
diff --git a/core/src/main/java/io/temporal/samples/listworkflows/CustomerActivitiesImpl.java b/core/src/main/java/io/temporal/samples/listworkflows/CustomerActivitiesImpl.java
index f7151c4b1..c4de12e50 100644
--- a/core/src/main/java/io/temporal/samples/listworkflows/CustomerActivitiesImpl.java
+++ b/core/src/main/java/io/temporal/samples/listworkflows/CustomerActivitiesImpl.java
@@ -1,22 +1,3 @@
-/*
- * Copyright (c) 2020 Temporal Technologies, Inc. All Rights Reserved
- *
- * Copyright 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
- * Modifications copyright (C) 2017 Uber Technologies, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"). You may not
- * use this file except in compliance with the License. A copy of the License is
- * located at
- *
- * http://aws.amazon.com/apache2.0
- *
- * or in the "license" file accompanying this file. This file is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
package io.temporal.samples.listworkflows;
import java.util.concurrent.TimeUnit;
diff --git a/core/src/main/java/io/temporal/samples/listworkflows/CustomerWorkflow.java b/core/src/main/java/io/temporal/samples/listworkflows/CustomerWorkflow.java
index 1c4a4fe23..62d1a29fc 100644
--- a/core/src/main/java/io/temporal/samples/listworkflows/CustomerWorkflow.java
+++ b/core/src/main/java/io/temporal/samples/listworkflows/CustomerWorkflow.java
@@ -1,22 +1,3 @@
-/*
- * Copyright (c) 2020 Temporal Technologies, Inc. All Rights Reserved
- *
- * Copyright 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
- * Modifications copyright (C) 2017 Uber Technologies, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"). You may not
- * use this file except in compliance with the License. A copy of the License is
- * located at
- *
- * http://aws.amazon.com/apache2.0
- *
- * or in the "license" file accompanying this file. This file is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
package io.temporal.samples.listworkflows;
import io.temporal.workflow.SignalMethod;
diff --git a/core/src/main/java/io/temporal/samples/listworkflows/CustomerWorkflowImpl.java b/core/src/main/java/io/temporal/samples/listworkflows/CustomerWorkflowImpl.java
index 7b43ff650..d3871d0e0 100644
--- a/core/src/main/java/io/temporal/samples/listworkflows/CustomerWorkflowImpl.java
+++ b/core/src/main/java/io/temporal/samples/listworkflows/CustomerWorkflowImpl.java
@@ -1,22 +1,3 @@
-/*
- * Copyright (c) 2020 Temporal Technologies, Inc. All Rights Reserved
- *
- * Copyright 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
- * Modifications copyright (C) 2017 Uber Technologies, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"). You may not
- * use this file except in compliance with the License. A copy of the License is
- * located at
- *
- * http://aws.amazon.com/apache2.0
- *
- * or in the "license" file accompanying this file. This file is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
package io.temporal.samples.listworkflows;
import io.temporal.activity.ActivityOptions;
diff --git a/core/src/main/java/io/temporal/samples/listworkflows/Starter.java b/core/src/main/java/io/temporal/samples/listworkflows/Starter.java
index d03039a7a..ad7f62369 100644
--- a/core/src/main/java/io/temporal/samples/listworkflows/Starter.java
+++ b/core/src/main/java/io/temporal/samples/listworkflows/Starter.java
@@ -1,22 +1,3 @@
-/*
- * Copyright (c) 2020 Temporal Technologies, Inc. All Rights Reserved
- *
- * Copyright 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
- * Modifications copyright (C) 2017 Uber Technologies, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"). You may not
- * use this file except in compliance with the License. A copy of the License is
- * located at
- *
- * http://aws.amazon.com/apache2.0
- *
- * or in the "license" file accompanying this file. This file is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
package io.temporal.samples.listworkflows;
import io.temporal.api.enums.v1.WorkflowExecutionStatus;
@@ -25,9 +6,11 @@
import io.temporal.api.workflowservice.v1.ListWorkflowExecutionsResponse;
import io.temporal.client.WorkflowClient;
import io.temporal.client.WorkflowOptions;
+import io.temporal.envconfig.ClientConfigProfile;
import io.temporal.serviceclient.WorkflowServiceStubs;
import io.temporal.worker.Worker;
import io.temporal.worker.WorkerFactory;
+import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
@@ -36,11 +19,23 @@
public class Starter {
public static final String TASK_QUEUE = "customerTaskQueue";
- private static final WorkflowServiceStubs service = WorkflowServiceStubs.newLocalServiceStubs();
- private static final WorkflowClient client = WorkflowClient.newInstance(service);
- private static final WorkerFactory factory = WorkerFactory.newInstance(client);
+ private static WorkflowServiceStubs service;
+ private static WorkflowClient client;
+ private static WorkerFactory factory;
public static void main(String[] args) {
+ // Load configuration from environment and files
+ ClientConfigProfile profile;
+ try {
+ profile = ClientConfigProfile.load();
+ } catch (IOException e) {
+ throw new RuntimeException("Failed to load client configuration", e);
+ }
+
+ service = WorkflowServiceStubs.newServiceStubs(profile.toWorkflowServiceStubsOptions());
+ client = WorkflowClient.newInstance(service, profile.toWorkflowClientOptions());
+ factory = WorkerFactory.newInstance(client);
+
// create some fake customers
List customers = new ArrayList<>();
customers.add(new Customer("c1", "John", "john@john.com", "new"));
diff --git a/core/src/main/java/io/temporal/samples/metrics/MetricsStarter.java b/core/src/main/java/io/temporal/samples/metrics/MetricsStarter.java
index 489463d31..ffe222899 100644
--- a/core/src/main/java/io/temporal/samples/metrics/MetricsStarter.java
+++ b/core/src/main/java/io/temporal/samples/metrics/MetricsStarter.java
@@ -1,22 +1,3 @@
-/*
- * Copyright (c) 2020 Temporal Technologies, Inc. All Rights Reserved
- *
- * Copyright 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
- * Modifications copyright (C) 2017 Uber Technologies, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"). You may not
- * use this file except in compliance with the License. A copy of the License is
- * located at
- *
- * http://aws.amazon.com/apache2.0
- *
- * or in the "license" file accompanying this file. This file is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
package io.temporal.samples.metrics;
import com.sun.net.httpserver.HttpServer;
@@ -28,9 +9,11 @@
import io.temporal.client.WorkflowClient;
import io.temporal.client.WorkflowOptions;
import io.temporal.common.reporter.MicrometerClientStatsReporter;
+import io.temporal.envconfig.ClientConfigProfile;
import io.temporal.samples.metrics.workflow.MetricsWorkflow;
import io.temporal.serviceclient.WorkflowServiceStubs;
import io.temporal.serviceclient.WorkflowServiceStubsOptions;
+import java.io.IOException;
public class MetricsStarter {
public static void main(String[] args) {
@@ -54,12 +37,22 @@ public static void main(String[] args) {
// scrape endpoint.
Runtime.getRuntime().addShutdownHook(new Thread(() -> scrapeEndpoint.stop(1)));
- // Add metrics scope to workflow service stub options
+ // Load configuration from environment and files
+ ClientConfigProfile profile;
+ try {
+ profile = ClientConfigProfile.load();
+ } catch (IOException e) {
+ throw new RuntimeException("Failed to load client configuration", e);
+ }
+
+ // Add metrics scope to workflow service stub options, preserving env config
WorkflowServiceStubsOptions stubOptions =
- WorkflowServiceStubsOptions.newBuilder().setMetricsScope(scope).build();
+ WorkflowServiceStubsOptions.newBuilder(profile.toWorkflowServiceStubsOptions())
+ .setMetricsScope(scope)
+ .build();
WorkflowServiceStubs service = WorkflowServiceStubs.newServiceStubs(stubOptions);
- WorkflowClient client = WorkflowClient.newInstance(service);
+ WorkflowClient client = WorkflowClient.newInstance(service, profile.toWorkflowClientOptions());
WorkflowOptions workflowOptions =
WorkflowOptions.newBuilder()
diff --git a/core/src/main/java/io/temporal/samples/metrics/MetricsUtils.java b/core/src/main/java/io/temporal/samples/metrics/MetricsUtils.java
index 03c20d481..621fab684 100644
--- a/core/src/main/java/io/temporal/samples/metrics/MetricsUtils.java
+++ b/core/src/main/java/io/temporal/samples/metrics/MetricsUtils.java
@@ -1,22 +1,3 @@
-/*
- * Copyright (c) 2020 Temporal Technologies, Inc. All Rights Reserved
- *
- * Copyright 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
- * Modifications copyright (C) 2017 Uber Technologies, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"). You may not
- * use this file except in compliance with the License. A copy of the License is
- * located at
- *
- * http://aws.amazon.com/apache2.0
- *
- * or in the "license" file accompanying this file. This file is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
package io.temporal.samples.metrics;
import static java.nio.charset.StandardCharsets.UTF_8;
diff --git a/core/src/main/java/io/temporal/samples/metrics/MetricsWorker.java b/core/src/main/java/io/temporal/samples/metrics/MetricsWorker.java
index eced332dd..9f95107cf 100644
--- a/core/src/main/java/io/temporal/samples/metrics/MetricsWorker.java
+++ b/core/src/main/java/io/temporal/samples/metrics/MetricsWorker.java
@@ -1,22 +1,3 @@
-/*
- * Copyright (c) 2020 Temporal Technologies, Inc. All Rights Reserved
- *
- * Copyright 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
- * Modifications copyright (C) 2017 Uber Technologies, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"). You may not
- * use this file except in compliance with the License. A copy of the License is
- * located at
- *
- * http://aws.amazon.com/apache2.0
- *
- * or in the "license" file accompanying this file. This file is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
package io.temporal.samples.metrics;
import com.sun.net.httpserver.HttpServer;
@@ -27,12 +8,14 @@
import io.micrometer.prometheus.PrometheusMeterRegistry;
import io.temporal.client.WorkflowClient;
import io.temporal.common.reporter.MicrometerClientStatsReporter;
+import io.temporal.envconfig.ClientConfigProfile;
import io.temporal.samples.metrics.activities.MetricsActivitiesImpl;
import io.temporal.samples.metrics.workflow.MetricsWorkflowImpl;
import io.temporal.serviceclient.WorkflowServiceStubs;
import io.temporal.serviceclient.WorkflowServiceStubsOptions;
import io.temporal.worker.Worker;
import io.temporal.worker.WorkerFactory;
+import java.io.IOException;
public class MetricsWorker {
@@ -60,12 +43,22 @@ public static void main(String[] args) {
// Stopping the worker will stop the http server that exposes the
// scrape endpoint.
Runtime.getRuntime().addShutdownHook(new Thread(() -> scrapeEndpoint.stop(1)));
- // Add metrics scope to workflow service stub options
+ // Load configuration from environment and files
+ ClientConfigProfile profile;
+ try {
+ profile = ClientConfigProfile.load();
+ } catch (IOException e) {
+ throw new RuntimeException("Failed to load client configuration", e);
+ }
+
+ // Add metrics scope to workflow service stub options, preserving env config
WorkflowServiceStubsOptions stubOptions =
- WorkflowServiceStubsOptions.newBuilder().setMetricsScope(scope).build();
+ WorkflowServiceStubsOptions.newBuilder(profile.toWorkflowServiceStubsOptions())
+ .setMetricsScope(scope)
+ .build();
WorkflowServiceStubs service = WorkflowServiceStubs.newServiceStubs(stubOptions);
- WorkflowClient client = WorkflowClient.newInstance(service);
+ WorkflowClient client = WorkflowClient.newInstance(service, profile.toWorkflowClientOptions());
WorkerFactory factory = WorkerFactory.newInstance(client);
Worker worker = factory.newWorker(DEFAULT_TASK_QUEUE_NAME);
diff --git a/core/src/main/java/io/temporal/samples/metrics/activities/MetricsActivities.java b/core/src/main/java/io/temporal/samples/metrics/activities/MetricsActivities.java
index 7a1f77521..113a4d05d 100644
--- a/core/src/main/java/io/temporal/samples/metrics/activities/MetricsActivities.java
+++ b/core/src/main/java/io/temporal/samples/metrics/activities/MetricsActivities.java
@@ -1,22 +1,3 @@
-/*
- * Copyright (c) 2020 Temporal Technologies, Inc. All Rights Reserved
- *
- * Copyright 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
- * Modifications copyright (C) 2017 Uber Technologies, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"). You may not
- * use this file except in compliance with the License. A copy of the License is
- * located at
- *
- * http://aws.amazon.com/apache2.0
- *
- * or in the "license" file accompanying this file. This file is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
package io.temporal.samples.metrics.activities;
import io.temporal.activity.ActivityInterface;
diff --git a/core/src/main/java/io/temporal/samples/metrics/activities/MetricsActivitiesImpl.java b/core/src/main/java/io/temporal/samples/metrics/activities/MetricsActivitiesImpl.java
index 1844a44e8..fd9edded4 100644
--- a/core/src/main/java/io/temporal/samples/metrics/activities/MetricsActivitiesImpl.java
+++ b/core/src/main/java/io/temporal/samples/metrics/activities/MetricsActivitiesImpl.java
@@ -1,22 +1,3 @@
-/*
- * Copyright (c) 2020 Temporal Technologies, Inc. All Rights Reserved
- *
- * Copyright 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
- * Modifications copyright (C) 2017 Uber Technologies, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"). You may not
- * use this file except in compliance with the License. A copy of the License is
- * located at
- *
- * http://aws.amazon.com/apache2.0
- *
- * or in the "license" file accompanying this file. This file is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
package io.temporal.samples.metrics.activities;
import io.temporal.activity.Activity;
diff --git a/core/src/main/java/io/temporal/samples/metrics/workflow/MetricsWorkflow.java b/core/src/main/java/io/temporal/samples/metrics/workflow/MetricsWorkflow.java
index bc97521b5..da1e473f2 100644
--- a/core/src/main/java/io/temporal/samples/metrics/workflow/MetricsWorkflow.java
+++ b/core/src/main/java/io/temporal/samples/metrics/workflow/MetricsWorkflow.java
@@ -1,22 +1,3 @@
-/*
- * Copyright (c) 2020 Temporal Technologies, Inc. All Rights Reserved
- *
- * Copyright 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
- * Modifications copyright (C) 2017 Uber Technologies, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"). You may not
- * use this file except in compliance with the License. A copy of the License is
- * located at
- *
- * http://aws.amazon.com/apache2.0
- *
- * or in the "license" file accompanying this file. This file is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
package io.temporal.samples.metrics.workflow;
import io.temporal.workflow.WorkflowInterface;
diff --git a/core/src/main/java/io/temporal/samples/metrics/workflow/MetricsWorkflowImpl.java b/core/src/main/java/io/temporal/samples/metrics/workflow/MetricsWorkflowImpl.java
index 560d013d6..7bd7b2472 100644
--- a/core/src/main/java/io/temporal/samples/metrics/workflow/MetricsWorkflowImpl.java
+++ b/core/src/main/java/io/temporal/samples/metrics/workflow/MetricsWorkflowImpl.java
@@ -1,22 +1,3 @@
-/*
- * Copyright (c) 2020 Temporal Technologies, Inc. All Rights Reserved
- *
- * Copyright 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
- * Modifications copyright (C) 2017 Uber Technologies, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"). You may not
- * use this file except in compliance with the License. A copy of the License is
- * located at
- *
- * http://aws.amazon.com/apache2.0
- *
- * or in the "license" file accompanying this file. This file is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
package io.temporal.samples.metrics.workflow;
import com.uber.m3.tally.Scope;
diff --git a/core/src/main/java/io/temporal/samples/moneybatch/Account.java b/core/src/main/java/io/temporal/samples/moneybatch/Account.java
index 98565e906..fd4bd1145 100644
--- a/core/src/main/java/io/temporal/samples/moneybatch/Account.java
+++ b/core/src/main/java/io/temporal/samples/moneybatch/Account.java
@@ -1,22 +1,3 @@
-/*
- * Copyright (c) 2020 Temporal Technologies, Inc. All Rights Reserved
- *
- * Copyright 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
- * Modifications copyright (C) 2017 Uber Technologies, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"). You may not
- * use this file except in compliance with the License. A copy of the License is
- * located at
- *
- * http://aws.amazon.com/apache2.0
- *
- * or in the "license" file accompanying this file. This file is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
package io.temporal.samples.moneybatch;
import io.temporal.activity.ActivityInterface;
diff --git a/core/src/main/java/io/temporal/samples/moneybatch/AccountActivityWorker.java b/core/src/main/java/io/temporal/samples/moneybatch/AccountActivityWorker.java
index f0aa2eb9f..d67014f80 100644
--- a/core/src/main/java/io/temporal/samples/moneybatch/AccountActivityWorker.java
+++ b/core/src/main/java/io/temporal/samples/moneybatch/AccountActivityWorker.java
@@ -1,28 +1,11 @@
-/*
- * Copyright (c) 2020 Temporal Technologies, Inc. All Rights Reserved
- *
- * Copyright 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
- * Modifications copyright (C) 2017 Uber Technologies, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"). You may not
- * use this file except in compliance with the License. A copy of the License is
- * located at
- *
- * http://aws.amazon.com/apache2.0
- *
- * or in the "license" file accompanying this file. This file is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
package io.temporal.samples.moneybatch;
import io.temporal.client.WorkflowClient;
+import io.temporal.envconfig.ClientConfigProfile;
import io.temporal.serviceclient.WorkflowServiceStubs;
import io.temporal.worker.Worker;
import io.temporal.worker.WorkerFactory;
+import java.io.IOException;
public class AccountActivityWorker {
@@ -30,8 +13,17 @@ public class AccountActivityWorker {
@SuppressWarnings("CatchAndPrintStackTrace")
public static void main(String[] args) {
- WorkflowServiceStubs service = WorkflowServiceStubs.newLocalServiceStubs();
- WorkflowClient client = WorkflowClient.newInstance(service);
+ // Load configuration from environment and files
+ ClientConfigProfile profile;
+ try {
+ profile = ClientConfigProfile.load();
+ } catch (IOException e) {
+ throw new RuntimeException("Failed to load client configuration", e);
+ }
+
+ WorkflowServiceStubs service =
+ WorkflowServiceStubs.newServiceStubs(profile.toWorkflowServiceStubsOptions());
+ WorkflowClient client = WorkflowClient.newInstance(service, profile.toWorkflowClientOptions());
WorkerFactory factory = WorkerFactory.newInstance(client);
Worker worker = factory.newWorker(TASK_QUEUE);
diff --git a/core/src/main/java/io/temporal/samples/moneybatch/AccountImpl.java b/core/src/main/java/io/temporal/samples/moneybatch/AccountImpl.java
index 1e03f516d..694fb1d33 100644
--- a/core/src/main/java/io/temporal/samples/moneybatch/AccountImpl.java
+++ b/core/src/main/java/io/temporal/samples/moneybatch/AccountImpl.java
@@ -1,22 +1,3 @@
-/*
- * Copyright (c) 2020 Temporal Technologies, Inc. All Rights Reserved
- *
- * Copyright 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
- * Modifications copyright (C) 2017 Uber Technologies, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"). You may not
- * use this file except in compliance with the License. A copy of the License is
- * located at
- *
- * http://aws.amazon.com/apache2.0
- *
- * or in the "license" file accompanying this file. This file is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
package io.temporal.samples.moneybatch;
public class AccountImpl implements Account {
diff --git a/core/src/main/java/io/temporal/samples/moneybatch/AccountTransferWorker.java b/core/src/main/java/io/temporal/samples/moneybatch/AccountTransferWorker.java
index c69ed6ee0..99529467d 100644
--- a/core/src/main/java/io/temporal/samples/moneybatch/AccountTransferWorker.java
+++ b/core/src/main/java/io/temporal/samples/moneybatch/AccountTransferWorker.java
@@ -1,35 +1,27 @@
-/*
- * Copyright (c) 2020 Temporal Technologies, Inc. All Rights Reserved
- *
- * Copyright 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
- * Modifications copyright (C) 2017 Uber Technologies, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"). You may not
- * use this file except in compliance with the License. A copy of the License is
- * located at
- *
- * http://aws.amazon.com/apache2.0
- *
- * or in the "license" file accompanying this file. This file is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
package io.temporal.samples.moneybatch;
import io.temporal.client.WorkflowClient;
+import io.temporal.envconfig.ClientConfigProfile;
import io.temporal.serviceclient.WorkflowServiceStubs;
import io.temporal.worker.Worker;
import io.temporal.worker.WorkerFactory;
+import java.io.IOException;
public class AccountTransferWorker {
@SuppressWarnings("CatchAndPrintStackTrace")
public static void main(String[] args) {
- WorkflowServiceStubs service = WorkflowServiceStubs.newLocalServiceStubs();
- WorkflowClient client = WorkflowClient.newInstance(service);
+ // Load configuration from environment and files
+ ClientConfigProfile profile;
+ try {
+ profile = ClientConfigProfile.load();
+ } catch (IOException e) {
+ throw new RuntimeException("Failed to load client configuration", e);
+ }
+
+ WorkflowServiceStubs service =
+ WorkflowServiceStubs.newServiceStubs(profile.toWorkflowServiceStubsOptions());
+ WorkflowClient client = WorkflowClient.newInstance(service, profile.toWorkflowClientOptions());
WorkerFactory factory = WorkerFactory.newInstance(client);
Worker worker = factory.newWorker(AccountActivityWorker.TASK_QUEUE);
diff --git a/core/src/main/java/io/temporal/samples/moneybatch/AccountTransferWorkflow.java b/core/src/main/java/io/temporal/samples/moneybatch/AccountTransferWorkflow.java
index a3278cb7c..c3ebc35ab 100644
--- a/core/src/main/java/io/temporal/samples/moneybatch/AccountTransferWorkflow.java
+++ b/core/src/main/java/io/temporal/samples/moneybatch/AccountTransferWorkflow.java
@@ -1,22 +1,3 @@
-/*
- * Copyright (c) 2020 Temporal Technologies, Inc. All Rights Reserved
- *
- * Copyright 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
- * Modifications copyright (C) 2017 Uber Technologies, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"). You may not
- * use this file except in compliance with the License. A copy of the License is
- * located at
- *
- * http://aws.amazon.com/apache2.0
- *
- * or in the "license" file accompanying this file. This file is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
package io.temporal.samples.moneybatch;
import io.temporal.workflow.QueryMethod;
diff --git a/core/src/main/java/io/temporal/samples/moneybatch/AccountTransferWorkflowImpl.java b/core/src/main/java/io/temporal/samples/moneybatch/AccountTransferWorkflowImpl.java
index 2d979bd21..fe1ab1241 100644
--- a/core/src/main/java/io/temporal/samples/moneybatch/AccountTransferWorkflowImpl.java
+++ b/core/src/main/java/io/temporal/samples/moneybatch/AccountTransferWorkflowImpl.java
@@ -1,22 +1,3 @@
-/*
- * Copyright (c) 2020 Temporal Technologies, Inc. All Rights Reserved
- *
- * Copyright 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
- * Modifications copyright (C) 2017 Uber Technologies, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"). You may not
- * use this file except in compliance with the License. A copy of the License is
- * located at
- *
- * http://aws.amazon.com/apache2.0
- *
- * or in the "license" file accompanying this file. This file is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
package io.temporal.samples.moneybatch;
import io.temporal.activity.ActivityOptions;
diff --git a/core/src/main/java/io/temporal/samples/moneybatch/TransferRequester.java b/core/src/main/java/io/temporal/samples/moneybatch/TransferRequester.java
index 7db5bd037..31b2f507f 100644
--- a/core/src/main/java/io/temporal/samples/moneybatch/TransferRequester.java
+++ b/core/src/main/java/io/temporal/samples/moneybatch/TransferRequester.java
@@ -1,28 +1,11 @@
-/*
- * Copyright (c) 2020 Temporal Technologies, Inc. All Rights Reserved
- *
- * Copyright 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
- * Modifications copyright (C) 2017 Uber Technologies, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"). You may not
- * use this file except in compliance with the License. A copy of the License is
- * located at
- *
- * http://aws.amazon.com/apache2.0
- *
- * or in the "license" file accompanying this file. This file is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
package io.temporal.samples.moneybatch;
import io.temporal.client.BatchRequest;
import io.temporal.client.WorkflowClient;
import io.temporal.client.WorkflowOptions;
+import io.temporal.envconfig.ClientConfigProfile;
import io.temporal.serviceclient.WorkflowServiceStubs;
+import java.io.IOException;
import java.util.Random;
import java.util.UUID;
@@ -35,8 +18,18 @@ public class TransferRequester {
public static void main(String[] args) {
String reference = UUID.randomUUID().toString();
int amountCents = (new Random().nextInt(5) + 1) * 25;
- WorkflowServiceStubs service = WorkflowServiceStubs.newLocalServiceStubs();
- WorkflowClient workflowClient = WorkflowClient.newInstance(service);
+ // Load configuration from environment and files
+ ClientConfigProfile profile;
+ try {
+ profile = ClientConfigProfile.load();
+ } catch (IOException e) {
+ throw new RuntimeException("Failed to load client configuration", e);
+ }
+
+ WorkflowServiceStubs service =
+ WorkflowServiceStubs.newServiceStubs(profile.toWorkflowServiceStubsOptions());
+ WorkflowClient workflowClient =
+ WorkflowClient.newInstance(service, profile.toWorkflowClientOptions());
String from = "account1";
String to = "account2";
diff --git a/core/src/main/java/io/temporal/samples/moneytransfer/Account.java b/core/src/main/java/io/temporal/samples/moneytransfer/Account.java
index 507ceb53b..413d1bfe3 100644
--- a/core/src/main/java/io/temporal/samples/moneytransfer/Account.java
+++ b/core/src/main/java/io/temporal/samples/moneytransfer/Account.java
@@ -1,22 +1,3 @@
-/*
- * Copyright (c) 2020 Temporal Technologies, Inc. All Rights Reserved
- *
- * Copyright 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
- * Modifications copyright (C) 2017 Uber Technologies, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"). You may not
- * use this file except in compliance with the License. A copy of the License is
- * located at
- *
- * http://aws.amazon.com/apache2.0
- *
- * or in the "license" file accompanying this file. This file is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
package io.temporal.samples.moneytransfer;
import io.temporal.activity.ActivityInterface;
diff --git a/core/src/main/java/io/temporal/samples/moneytransfer/AccountActivityWorker.java b/core/src/main/java/io/temporal/samples/moneytransfer/AccountActivityWorker.java
index dcd5cd43e..a3113fe5d 100644
--- a/core/src/main/java/io/temporal/samples/moneytransfer/AccountActivityWorker.java
+++ b/core/src/main/java/io/temporal/samples/moneytransfer/AccountActivityWorker.java
@@ -1,28 +1,11 @@
-/*
- * Copyright (c) 2020 Temporal Technologies, Inc. All Rights Reserved
- *
- * Copyright 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
- * Modifications copyright (C) 2017 Uber Technologies, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"). You may not
- * use this file except in compliance with the License. A copy of the License is
- * located at
- *
- * http://aws.amazon.com/apache2.0
- *
- * or in the "license" file accompanying this file. This file is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
package io.temporal.samples.moneytransfer;
import io.temporal.client.WorkflowClient;
+import io.temporal.envconfig.ClientConfigProfile;
import io.temporal.serviceclient.WorkflowServiceStubs;
import io.temporal.worker.Worker;
import io.temporal.worker.WorkerFactory;
+import java.io.IOException;
public class AccountActivityWorker {
@@ -30,10 +13,19 @@ public class AccountActivityWorker {
@SuppressWarnings("CatchAndPrintStackTrace")
public static void main(String[] args) {
- // gRPC stubs wrapper that talks to the local docker instance of temporal service.
- WorkflowServiceStubs service = WorkflowServiceStubs.newLocalServiceStubs();
+ // Load configuration from environment and files
+ ClientConfigProfile profile;
+ try {
+ profile = ClientConfigProfile.load();
+ } catch (IOException e) {
+ throw new RuntimeException("Failed to load client configuration", e);
+ }
+
+ // gRPC stubs wrapper that talks to the temporal service.
+ WorkflowServiceStubs service =
+ WorkflowServiceStubs.newServiceStubs(profile.toWorkflowServiceStubsOptions());
// client that can be used to start and signal workflows
- WorkflowClient client = WorkflowClient.newInstance(service);
+ WorkflowClient client = WorkflowClient.newInstance(service, profile.toWorkflowClientOptions());
// worker factory that can be used to create workers for specific task queues
WorkerFactory factory = WorkerFactory.newInstance(client);
diff --git a/core/src/main/java/io/temporal/samples/moneytransfer/AccountImpl.java b/core/src/main/java/io/temporal/samples/moneytransfer/AccountImpl.java
index 761c06b3a..8374ab90f 100644
--- a/core/src/main/java/io/temporal/samples/moneytransfer/AccountImpl.java
+++ b/core/src/main/java/io/temporal/samples/moneytransfer/AccountImpl.java
@@ -1,22 +1,3 @@
-/*
- * Copyright (c) 2020 Temporal Technologies, Inc. All Rights Reserved
- *
- * Copyright 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
- * Modifications copyright (C) 2017 Uber Technologies, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"). You may not
- * use this file except in compliance with the License. A copy of the License is
- * located at
- *
- * http://aws.amazon.com/apache2.0
- *
- * or in the "license" file accompanying this file. This file is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
package io.temporal.samples.moneytransfer;
public class AccountImpl implements Account {
diff --git a/core/src/main/java/io/temporal/samples/moneytransfer/AccountTransferWorker.java b/core/src/main/java/io/temporal/samples/moneytransfer/AccountTransferWorker.java
index b7aaf0fad..97ab56ff9 100644
--- a/core/src/main/java/io/temporal/samples/moneytransfer/AccountTransferWorker.java
+++ b/core/src/main/java/io/temporal/samples/moneytransfer/AccountTransferWorker.java
@@ -1,40 +1,32 @@
-/*
- * Copyright (c) 2020 Temporal Technologies, Inc. All Rights Reserved
- *
- * Copyright 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
- * Modifications copyright (C) 2017 Uber Technologies, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"). You may not
- * use this file except in compliance with the License. A copy of the License is
- * located at
- *
- * http://aws.amazon.com/apache2.0
- *
- * or in the "license" file accompanying this file. This file is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
package io.temporal.samples.moneytransfer;
import static io.temporal.samples.moneytransfer.AccountActivityWorker.TASK_QUEUE;
import io.temporal.client.WorkflowClient;
+import io.temporal.envconfig.ClientConfigProfile;
import io.temporal.serviceclient.WorkflowServiceStubs;
import io.temporal.worker.Worker;
import io.temporal.worker.WorkerFactory;
+import java.io.IOException;
public class AccountTransferWorker {
@SuppressWarnings("CatchAndPrintStackTrace")
public static void main(String[] args) {
// Get worker to poll the common task queue.
- // gRPC stubs wrapper that talks to the local docker instance of temporal service.
- WorkflowServiceStubs service = WorkflowServiceStubs.newLocalServiceStubs();
+ // Load configuration from environment and files
+ ClientConfigProfile profile;
+ try {
+ profile = ClientConfigProfile.load();
+ } catch (IOException e) {
+ throw new RuntimeException("Failed to load client configuration", e);
+ }
+
+ // gRPC stubs wrapper that talks to the temporal service.
+ WorkflowServiceStubs service =
+ WorkflowServiceStubs.newServiceStubs(profile.toWorkflowServiceStubsOptions());
// client that can be used to start and signal workflows
- WorkflowClient client = WorkflowClient.newInstance(service);
+ WorkflowClient client = WorkflowClient.newInstance(service, profile.toWorkflowClientOptions());
// worker factory that can be used to create workers for specific task queues
WorkerFactory factory = WorkerFactory.newInstance(client);
diff --git a/core/src/main/java/io/temporal/samples/moneytransfer/AccountTransferWorkflow.java b/core/src/main/java/io/temporal/samples/moneytransfer/AccountTransferWorkflow.java
index 554ea54ac..e5a5cfe26 100644
--- a/core/src/main/java/io/temporal/samples/moneytransfer/AccountTransferWorkflow.java
+++ b/core/src/main/java/io/temporal/samples/moneytransfer/AccountTransferWorkflow.java
@@ -1,22 +1,3 @@
-/*
- * Copyright (c) 2020 Temporal Technologies, Inc. All Rights Reserved
- *
- * Copyright 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
- * Modifications copyright (C) 2017 Uber Technologies, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"). You may not
- * use this file except in compliance with the License. A copy of the License is
- * located at
- *
- * http://aws.amazon.com/apache2.0
- *
- * or in the "license" file accompanying this file. This file is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
package io.temporal.samples.moneytransfer;
import io.temporal.workflow.WorkflowInterface;
diff --git a/core/src/main/java/io/temporal/samples/moneytransfer/AccountTransferWorkflowImpl.java b/core/src/main/java/io/temporal/samples/moneytransfer/AccountTransferWorkflowImpl.java
index bf7a042fe..a5de72543 100644
--- a/core/src/main/java/io/temporal/samples/moneytransfer/AccountTransferWorkflowImpl.java
+++ b/core/src/main/java/io/temporal/samples/moneytransfer/AccountTransferWorkflowImpl.java
@@ -1,22 +1,3 @@
-/*
- * Copyright (c) 2020 Temporal Technologies, Inc. All Rights Reserved
- *
- * Copyright 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
- * Modifications copyright (C) 2017 Uber Technologies, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"). You may not
- * use this file except in compliance with the License. A copy of the License is
- * located at
- *
- * http://aws.amazon.com/apache2.0
- *
- * or in the "license" file accompanying this file. This file is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
package io.temporal.samples.moneytransfer;
import io.temporal.activity.ActivityOptions;
diff --git a/core/src/main/java/io/temporal/samples/moneytransfer/TransferRequester.java b/core/src/main/java/io/temporal/samples/moneytransfer/TransferRequester.java
index 1faa9cd3b..6fda6598e 100644
--- a/core/src/main/java/io/temporal/samples/moneytransfer/TransferRequester.java
+++ b/core/src/main/java/io/temporal/samples/moneytransfer/TransferRequester.java
@@ -1,29 +1,12 @@
-/*
- * Copyright (c) 2020 Temporal Technologies, Inc. All Rights Reserved
- *
- * Copyright 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
- * Modifications copyright (C) 2017 Uber Technologies, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"). You may not
- * use this file except in compliance with the License. A copy of the License is
- * located at
- *
- * http://aws.amazon.com/apache2.0
- *
- * or in the "license" file accompanying this file. This file is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
package io.temporal.samples.moneytransfer;
import static io.temporal.samples.moneytransfer.AccountActivityWorker.TASK_QUEUE;
import io.temporal.client.WorkflowClient;
import io.temporal.client.WorkflowOptions;
+import io.temporal.envconfig.ClientConfigProfile;
import io.temporal.serviceclient.WorkflowServiceStubs;
+import java.io.IOException;
import java.util.Random;
import java.util.UUID;
@@ -40,9 +23,19 @@ public static void main(String[] args) {
reference = args[0];
amountCents = Integer.parseInt(args[1]);
}
- WorkflowServiceStubs service = WorkflowServiceStubs.newLocalServiceStubs();
+ // Load configuration from environment and files
+ ClientConfigProfile profile;
+ try {
+ profile = ClientConfigProfile.load();
+ } catch (IOException e) {
+ throw new RuntimeException("Failed to load client configuration", e);
+ }
+
+ WorkflowServiceStubs service =
+ WorkflowServiceStubs.newServiceStubs(profile.toWorkflowServiceStubsOptions());
// client that can be used to start and signal workflows
- WorkflowClient workflowClient = WorkflowClient.newInstance(service);
+ WorkflowClient workflowClient =
+ WorkflowClient.newInstance(service, profile.toWorkflowClientOptions());
// now we can start running instances of the saga - its state will be persisted
WorkflowOptions options = WorkflowOptions.newBuilder().setTaskQueue(TASK_QUEUE).build();
diff --git a/core/src/main/java/io/temporal/samples/nexus/README.MD b/core/src/main/java/io/temporal/samples/nexus/README.MD
index 526d3d486..dc627f27e 100644
--- a/core/src/main/java/io/temporal/samples/nexus/README.MD
+++ b/core/src/main/java/io/temporal/samples/nexus/README.MD
@@ -24,7 +24,7 @@ This sample shows how to use Temporal for authoring a Nexus service and call it
site](https://learn.temporal.io/getting_started/go/dev_environment/#set-up-a-local-temporal-service-for-development-with-temporal-cli)
to install Temporal CLI.
-> NOTE: Required version is at least v1.1.0.
+> NOTE: The recommended version is at least v1.3.0.
### Spin up environment
@@ -33,7 +33,7 @@ This sample shows how to use Temporal for authoring a Nexus service and call it
> HTTP port is required for Nexus communications
```
-temporal server start-dev --http-port 7243 --dynamic-config-value system.enableNexus=true
+temporal server start-dev
```
### Initialize environment
diff --git a/core/src/main/java/io/temporal/samples/nexus/caller/CallerStarter.java b/core/src/main/java/io/temporal/samples/nexus/caller/CallerStarter.java
index 23dd0f5ec..f207d64cf 100644
--- a/core/src/main/java/io/temporal/samples/nexus/caller/CallerStarter.java
+++ b/core/src/main/java/io/temporal/samples/nexus/caller/CallerStarter.java
@@ -1,29 +1,10 @@
-/*
- * Copyright (c) 2020 Temporal Technologies, Inc. All Rights Reserved
- *
- * Copyright 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
- * Modifications copyright (C) 2017 Uber Technologies, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"). You may not
- * use this file except in compliance with the License. A copy of the License is
- * located at
- *
- * http://aws.amazon.com/apache2.0
- *
- * or in the "license" file accompanying this file. This file is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
package io.temporal.samples.nexus.caller;
+import io.temporal.api.common.v1.WorkflowExecution;
import io.temporal.client.WorkflowClient;
import io.temporal.client.WorkflowOptions;
-import io.temporal.client.WorkflowStub;
import io.temporal.samples.nexus.options.ClientOptions;
-import io.temporal.samples.nexus.service.NexusService;
+import io.temporal.samples.nexus.service.SampleNexusService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -37,17 +18,20 @@ public static void main(String[] args) {
WorkflowOptions.newBuilder().setTaskQueue(CallerWorker.DEFAULT_TASK_QUEUE_NAME).build();
EchoCallerWorkflow echoWorkflow =
client.newWorkflowStub(EchoCallerWorkflow.class, workflowOptions);
- logger.info("Workflow result: {}", echoWorkflow.echo("Nexus Echo 👋"));
+ WorkflowExecution execution = WorkflowClient.start(echoWorkflow::echo, "Nexus Echo 👋");
logger.info(
- "Started workflow workflowId: {} runId: {}",
- WorkflowStub.fromTyped(echoWorkflow).getExecution().getWorkflowId(),
- WorkflowStub.fromTyped(echoWorkflow).getExecution().getRunId());
+ "Started EchoCallerWorkflow workflowId: {} runId: {}",
+ execution.getWorkflowId(),
+ execution.getRunId());
+ logger.info("Workflow result: {}", echoWorkflow.echo("Nexus Echo 👋"));
HelloCallerWorkflow helloWorkflow =
client.newWorkflowStub(HelloCallerWorkflow.class, workflowOptions);
- logger.info("Workflow result: {}", helloWorkflow.hello("Nexus", NexusService.Language.ES));
+ execution = WorkflowClient.start(helloWorkflow::hello, "Nexus", SampleNexusService.Language.EN);
+ logger.info(
+ "Started HelloCallerWorkflow workflowId: {} runId: {}",
+ execution.getWorkflowId(),
+ execution.getRunId());
logger.info(
- "Started workflow workflowId: {} runId: {}",
- WorkflowStub.fromTyped(helloWorkflow).getExecution().getWorkflowId(),
- WorkflowStub.fromTyped(helloWorkflow).getExecution().getRunId());
+ "Workflow result: {}", helloWorkflow.hello("Nexus", SampleNexusService.Language.ES));
}
}
diff --git a/core/src/main/java/io/temporal/samples/nexus/caller/CallerWorker.java b/core/src/main/java/io/temporal/samples/nexus/caller/CallerWorker.java
index e7be0ae4a..5480917ba 100644
--- a/core/src/main/java/io/temporal/samples/nexus/caller/CallerWorker.java
+++ b/core/src/main/java/io/temporal/samples/nexus/caller/CallerWorker.java
@@ -1,22 +1,3 @@
-/*
- * Copyright (c) 2020 Temporal Technologies, Inc. All Rights Reserved
- *
- * Copyright 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
- * Modifications copyright (C) 2017 Uber Technologies, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"). You may not
- * use this file except in compliance with the License. A copy of the License is
- * located at
- *
- * http://aws.amazon.com/apache2.0
- *
- * or in the "license" file accompanying this file. This file is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
package io.temporal.samples.nexus.caller;
import io.temporal.client.WorkflowClient;
@@ -40,7 +21,7 @@ public static void main(String[] args) {
WorkflowImplementationOptions.newBuilder()
.setNexusServiceOptions(
Collections.singletonMap(
- "NexusService",
+ "SampleNexusService",
NexusServiceOptions.newBuilder().setEndpoint("my-nexus-endpoint-name").build()))
.build(),
EchoCallerWorkflowImpl.class,
diff --git a/core/src/main/java/io/temporal/samples/nexus/caller/EchoCallerWorkflow.java b/core/src/main/java/io/temporal/samples/nexus/caller/EchoCallerWorkflow.java
index 5f830855e..b4c7fac84 100644
--- a/core/src/main/java/io/temporal/samples/nexus/caller/EchoCallerWorkflow.java
+++ b/core/src/main/java/io/temporal/samples/nexus/caller/EchoCallerWorkflow.java
@@ -1,22 +1,3 @@
-/*
- * Copyright (c) 2020 Temporal Technologies, Inc. All Rights Reserved
- *
- * Copyright 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
- * Modifications copyright (C) 2017 Uber Technologies, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"). You may not
- * use this file except in compliance with the License. A copy of the License is
- * located at
- *
- * http://aws.amazon.com/apache2.0
- *
- * or in the "license" file accompanying this file. This file is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
package io.temporal.samples.nexus.caller;
import io.temporal.workflow.WorkflowInterface;
diff --git a/core/src/main/java/io/temporal/samples/nexus/caller/EchoCallerWorkflowImpl.java b/core/src/main/java/io/temporal/samples/nexus/caller/EchoCallerWorkflowImpl.java
index 7c5d5f787..f76edbfe4 100644
--- a/core/src/main/java/io/temporal/samples/nexus/caller/EchoCallerWorkflowImpl.java
+++ b/core/src/main/java/io/temporal/samples/nexus/caller/EchoCallerWorkflowImpl.java
@@ -1,34 +1,15 @@
-/*
- * Copyright (c) 2020 Temporal Technologies, Inc. All Rights Reserved
- *
- * Copyright 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
- * Modifications copyright (C) 2017 Uber Technologies, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"). You may not
- * use this file except in compliance with the License. A copy of the License is
- * located at
- *
- * http://aws.amazon.com/apache2.0
- *
- * or in the "license" file accompanying this file. This file is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
package io.temporal.samples.nexus.caller;
-import io.temporal.samples.nexus.service.NexusService;
+import io.temporal.samples.nexus.service.SampleNexusService;
import io.temporal.workflow.NexusOperationOptions;
import io.temporal.workflow.NexusServiceOptions;
import io.temporal.workflow.Workflow;
import java.time.Duration;
public class EchoCallerWorkflowImpl implements EchoCallerWorkflow {
- NexusService nexusService =
+ SampleNexusService sampleNexusService =
Workflow.newNexusServiceStub(
- NexusService.class,
+ SampleNexusService.class,
NexusServiceOptions.newBuilder()
.setOperationOptions(
NexusOperationOptions.newBuilder()
@@ -38,6 +19,6 @@ public class EchoCallerWorkflowImpl implements EchoCallerWorkflow {
@Override
public String echo(String message) {
- return nexusService.echo(new NexusService.EchoInput(message)).getMessage();
+ return sampleNexusService.echo(new SampleNexusService.EchoInput(message)).getMessage();
}
}
diff --git a/core/src/main/java/io/temporal/samples/nexus/caller/HelloCallerWorkflow.java b/core/src/main/java/io/temporal/samples/nexus/caller/HelloCallerWorkflow.java
index 6e943c17e..1f78e9c02 100644
--- a/core/src/main/java/io/temporal/samples/nexus/caller/HelloCallerWorkflow.java
+++ b/core/src/main/java/io/temporal/samples/nexus/caller/HelloCallerWorkflow.java
@@ -1,30 +1,11 @@
-/*
- * Copyright (c) 2020 Temporal Technologies, Inc. All Rights Reserved
- *
- * Copyright 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
- * Modifications copyright (C) 2017 Uber Technologies, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"). You may not
- * use this file except in compliance with the License. A copy of the License is
- * located at
- *
- * http://aws.amazon.com/apache2.0
- *
- * or in the "license" file accompanying this file. This file is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
package io.temporal.samples.nexus.caller;
-import io.temporal.samples.nexus.service.NexusService;
+import io.temporal.samples.nexus.service.SampleNexusService;
import io.temporal.workflow.WorkflowInterface;
import io.temporal.workflow.WorkflowMethod;
@WorkflowInterface
public interface HelloCallerWorkflow {
@WorkflowMethod
- String hello(String message, NexusService.Language language);
+ String hello(String message, SampleNexusService.Language language);
}
diff --git a/core/src/main/java/io/temporal/samples/nexus/caller/HelloCallerWorkflowImpl.java b/core/src/main/java/io/temporal/samples/nexus/caller/HelloCallerWorkflowImpl.java
index dcc8d1a04..6a6fe8dce 100644
--- a/core/src/main/java/io/temporal/samples/nexus/caller/HelloCallerWorkflowImpl.java
+++ b/core/src/main/java/io/temporal/samples/nexus/caller/HelloCallerWorkflowImpl.java
@@ -1,25 +1,6 @@
-/*
- * Copyright (c) 2020 Temporal Technologies, Inc. All Rights Reserved
- *
- * Copyright 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
- * Modifications copyright (C) 2017 Uber Technologies, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"). You may not
- * use this file except in compliance with the License. A copy of the License is
- * located at
- *
- * http://aws.amazon.com/apache2.0
- *
- * or in the "license" file accompanying this file. This file is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
package io.temporal.samples.nexus.caller;
-import io.temporal.samples.nexus.service.NexusService;
+import io.temporal.samples.nexus.service.SampleNexusService;
import io.temporal.workflow.NexusOperationHandle;
import io.temporal.workflow.NexusOperationOptions;
import io.temporal.workflow.NexusServiceOptions;
@@ -27,9 +8,9 @@
import java.time.Duration;
public class HelloCallerWorkflowImpl implements HelloCallerWorkflow {
- NexusService nexusService =
+ SampleNexusService sampleNexusService =
Workflow.newNexusServiceStub(
- NexusService.class,
+ SampleNexusService.class,
NexusServiceOptions.newBuilder()
.setOperationOptions(
NexusOperationOptions.newBuilder()
@@ -38,12 +19,12 @@ public class HelloCallerWorkflowImpl implements HelloCallerWorkflow {
.build());
@Override
- public String hello(String message, NexusService.Language language) {
- NexusOperationHandle handle =
+ public String hello(String message, SampleNexusService.Language language) {
+ NexusOperationHandle handle =
Workflow.startNexusOperation(
- nexusService::hello, new NexusService.HelloInput(message, language));
+ sampleNexusService::hello, new SampleNexusService.HelloInput(message, language));
// Optionally wait for the operation to be started. NexusOperationExecution will contain the
- // operation ID in case this operation is asynchronous.
+ // operation token in case this operation is asynchronous.
handle.getExecution().get();
return handle.getResult().get().getMessage();
}
diff --git a/core/src/main/java/io/temporal/samples/nexus/handler/EchoClient.java b/core/src/main/java/io/temporal/samples/nexus/handler/EchoClient.java
new file mode 100644
index 000000000..74b6f6c69
--- /dev/null
+++ b/core/src/main/java/io/temporal/samples/nexus/handler/EchoClient.java
@@ -0,0 +1,7 @@
+package io.temporal.samples.nexus.handler;
+
+import io.temporal.samples.nexus.service.SampleNexusService;
+
+public interface EchoClient {
+ SampleNexusService.EchoOutput echo(SampleNexusService.EchoInput input);
+}
diff --git a/core/src/main/java/io/temporal/samples/nexus/handler/EchoClientImpl.java b/core/src/main/java/io/temporal/samples/nexus/handler/EchoClientImpl.java
new file mode 100644
index 000000000..1c9a2e524
--- /dev/null
+++ b/core/src/main/java/io/temporal/samples/nexus/handler/EchoClientImpl.java
@@ -0,0 +1,12 @@
+package io.temporal.samples.nexus.handler;
+
+import io.temporal.samples.nexus.service.SampleNexusService;
+
+// Note that this is a class, not a Temporal worker. This is to demonstrate that Nexus services can
+// simply call a class instead of a worker for fast operations that don't need retry handling.
+public class EchoClientImpl implements EchoClient {
+ @Override
+ public SampleNexusService.EchoOutput echo(SampleNexusService.EchoInput input) {
+ return new SampleNexusService.EchoOutput(input.getMessage());
+ }
+}
diff --git a/core/src/main/java/io/temporal/samples/nexus/handler/HandlerWorker.java b/core/src/main/java/io/temporal/samples/nexus/handler/HandlerWorker.java
index 71a78f91b..656b18c65 100644
--- a/core/src/main/java/io/temporal/samples/nexus/handler/HandlerWorker.java
+++ b/core/src/main/java/io/temporal/samples/nexus/handler/HandlerWorker.java
@@ -1,22 +1,3 @@
-/*
- * Copyright (c) 2020 Temporal Technologies, Inc. All Rights Reserved
- *
- * Copyright 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
- * Modifications copyright (C) 2017 Uber Technologies, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"). You may not
- * use this file except in compliance with the License. A copy of the License is
- * located at
- *
- * http://aws.amazon.com/apache2.0
- *
- * or in the "license" file accompanying this file. This file is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
package io.temporal.samples.nexus.handler;
import io.temporal.client.WorkflowClient;
@@ -34,7 +15,7 @@ public static void main(String[] args) {
Worker worker = factory.newWorker(DEFAULT_TASK_QUEUE_NAME);
worker.registerWorkflowImplementationTypes(HelloHandlerWorkflowImpl.class);
- worker.registerNexusServiceImplementation(new NexusServiceImpl());
+ worker.registerNexusServiceImplementation(new SampleNexusServiceImpl());
factory.start();
}
diff --git a/core/src/main/java/io/temporal/samples/nexus/handler/HelloHandlerWorkflow.java b/core/src/main/java/io/temporal/samples/nexus/handler/HelloHandlerWorkflow.java
index caa34d985..2c85d0792 100644
--- a/core/src/main/java/io/temporal/samples/nexus/handler/HelloHandlerWorkflow.java
+++ b/core/src/main/java/io/temporal/samples/nexus/handler/HelloHandlerWorkflow.java
@@ -1,30 +1,11 @@
-/*
- * Copyright (c) 2020 Temporal Technologies, Inc. All Rights Reserved
- *
- * Copyright 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
- * Modifications copyright (C) 2017 Uber Technologies, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"). You may not
- * use this file except in compliance with the License. A copy of the License is
- * located at
- *
- * http://aws.amazon.com/apache2.0
- *
- * or in the "license" file accompanying this file. This file is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
package io.temporal.samples.nexus.handler;
-import io.temporal.samples.nexus.service.NexusService;
+import io.temporal.samples.nexus.service.SampleNexusService;
import io.temporal.workflow.WorkflowInterface;
import io.temporal.workflow.WorkflowMethod;
@WorkflowInterface
public interface HelloHandlerWorkflow {
@WorkflowMethod
- NexusService.HelloOutput hello(NexusService.HelloInput input);
+ SampleNexusService.HelloOutput hello(SampleNexusService.HelloInput input);
}
diff --git a/core/src/main/java/io/temporal/samples/nexus/handler/HelloHandlerWorkflowImpl.java b/core/src/main/java/io/temporal/samples/nexus/handler/HelloHandlerWorkflowImpl.java
index ea5203eb7..b896ab523 100644
--- a/core/src/main/java/io/temporal/samples/nexus/handler/HelloHandlerWorkflowImpl.java
+++ b/core/src/main/java/io/temporal/samples/nexus/handler/HelloHandlerWorkflowImpl.java
@@ -1,41 +1,22 @@
-/*
- * Copyright (c) 2020 Temporal Technologies, Inc. All Rights Reserved
- *
- * Copyright 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
- * Modifications copyright (C) 2017 Uber Technologies, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"). You may not
- * use this file except in compliance with the License. A copy of the License is
- * located at
- *
- * http://aws.amazon.com/apache2.0
- *
- * or in the "license" file accompanying this file. This file is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
package io.temporal.samples.nexus.handler;
import io.temporal.failure.ApplicationFailure;
-import io.temporal.samples.nexus.service.NexusService;
+import io.temporal.samples.nexus.service.SampleNexusService;
public class HelloHandlerWorkflowImpl implements HelloHandlerWorkflow {
@Override
- public NexusService.HelloOutput hello(NexusService.HelloInput input) {
+ public SampleNexusService.HelloOutput hello(SampleNexusService.HelloInput input) {
switch (input.getLanguage()) {
case EN:
- return new NexusService.HelloOutput("Hello " + input.getName() + " 👋");
+ return new SampleNexusService.HelloOutput("Hello " + input.getName() + " 👋");
case FR:
- return new NexusService.HelloOutput("Bonjour " + input.getName() + " 👋");
+ return new SampleNexusService.HelloOutput("Bonjour " + input.getName() + " 👋");
case DE:
- return new NexusService.HelloOutput("Hallo " + input.getName() + " 👋");
+ return new SampleNexusService.HelloOutput("Hallo " + input.getName() + " 👋");
case ES:
- return new NexusService.HelloOutput("¡Hola! " + input.getName() + " 👋");
+ return new SampleNexusService.HelloOutput("¡Hola! " + input.getName() + " 👋");
case TR:
- return new NexusService.HelloOutput("Merhaba " + input.getName() + " 👋");
+ return new SampleNexusService.HelloOutput("Merhaba " + input.getName() + " 👋");
}
throw ApplicationFailure.newFailure(
"Unsupported language: " + input.getLanguage(), "UNSUPPORTED_LANGUAGE");
diff --git a/core/src/main/java/io/temporal/samples/nexus/handler/NexusServiceImpl.java b/core/src/main/java/io/temporal/samples/nexus/handler/NexusServiceImpl.java
deleted file mode 100644
index 4d6cb3cad..000000000
--- a/core/src/main/java/io/temporal/samples/nexus/handler/NexusServiceImpl.java
+++ /dev/null
@@ -1,65 +0,0 @@
-/*
- * Copyright (c) 2020 Temporal Technologies, Inc. All Rights Reserved
- *
- * Copyright 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
- * Modifications copyright (C) 2017 Uber Technologies, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"). You may not
- * use this file except in compliance with the License. A copy of the License is
- * located at
- *
- * http://aws.amazon.com/apache2.0
- *
- * or in the "license" file accompanying this file. This file is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
-package io.temporal.samples.nexus.handler;
-
-import io.nexusrpc.handler.OperationHandler;
-import io.nexusrpc.handler.OperationImpl;
-import io.nexusrpc.handler.ServiceImpl;
-import io.temporal.client.WorkflowOptions;
-import io.temporal.nexus.WorkflowClientOperationHandlers;
-import io.temporal.samples.nexus.service.NexusService;
-
-// To create a service implementation, annotate the class with @ServiceImpl and provide the
-// interface that the service implements. The service implementation class should have methods that
-// return OperationHandler that correspond to the operations defined in the service interface.
-@ServiceImpl(service = NexusService.class)
-public class NexusServiceImpl {
- @OperationImpl
- public OperationHandler echo() {
- // WorkflowClientOperationHandlers.sync is a meant for exposing simple RPC handlers.
- return WorkflowClientOperationHandlers.sync(
- // The method is provided with an SDK client that can be used for arbitrary calls such as
- // signaling, querying,
- // and listing workflows but implementations are free to make arbitrary calls to other
- // services or databases, or
- // perform simple computations such as this one.
- (ctx, details, client, input) -> new NexusService.EchoOutput(input.getMessage()));
- }
-
- @OperationImpl
- public OperationHandler hello() {
- // Use the WorkflowClientOperationHandlers.fromWorkflowMethod constructor, which is the easiest
- // way to expose a workflow as an operation.
- return WorkflowClientOperationHandlers.fromWorkflowMethod(
- (ctx, details, client, input) ->
- client.newWorkflowStub(
- HelloHandlerWorkflow.class,
- // Workflow IDs should typically be business meaningful IDs and are used to
- // dedupe workflow starts.
- // For this example, we're using the request ID allocated by Temporal when the
- // caller workflow schedules
- // the operation, this ID is guaranteed to be stable across retries of this
- // operation.
- //
- // Task queue defaults to the task queue this operation is handled on.
- WorkflowOptions.newBuilder().setWorkflowId(details.getRequestId()).build())
- ::hello);
- }
-}
diff --git a/core/src/main/java/io/temporal/samples/nexus/handler/SampleNexusServiceImpl.java b/core/src/main/java/io/temporal/samples/nexus/handler/SampleNexusServiceImpl.java
new file mode 100644
index 000000000..42952b72b
--- /dev/null
+++ b/core/src/main/java/io/temporal/samples/nexus/handler/SampleNexusServiceImpl.java
@@ -0,0 +1,67 @@
+package io.temporal.samples.nexus.handler;
+
+import io.nexusrpc.handler.OperationHandler;
+import io.nexusrpc.handler.OperationImpl;
+import io.nexusrpc.handler.ServiceImpl;
+import io.temporal.client.WorkflowOptions;
+import io.temporal.nexus.Nexus;
+import io.temporal.nexus.WorkflowRunOperation;
+import io.temporal.samples.nexus.service.SampleNexusService;
+
+// To create a service implementation, annotate the class with @ServiceImpl and provide the
+// interface that the service implements. The service implementation class should have methods that
+// return OperationHandler that correspond to the operations defined in the service interface.
+@ServiceImpl(service = SampleNexusService.class)
+public class SampleNexusServiceImpl {
+ private final EchoClient echoClient;
+
+ // The injected EchoClient makes this class unit-testable.
+ // The no-arg constructor provides a default; the second allows tests to inject a mock.
+ // If you are not using the sync call or do not need to mock a handler, then you will not
+ // need this constructor pairing.
+ public SampleNexusServiceImpl() {
+ this(new EchoClientImpl());
+ }
+
+ public SampleNexusServiceImpl(EchoClient echoClient) {
+ this.echoClient = echoClient;
+ }
+
+ // The Echo Nexus Service exemplifies making a synchronous call using OperationHandler.sync.
+ // In this case, it is calling the EchoClient class - not a workflow - and simply returning the
+ // result.
+ @OperationImpl
+ public OperationHandler echo() {
+ return OperationHandler.sync(
+ // The method is for making arbitrary short calls to other services or databases, or
+ // perform simple computations such as this one. Users can also access a workflow client by
+ // calling
+ // Nexus.getOperationContext().getWorkflowClient(ctx) to make arbitrary calls such as
+ // signaling, querying, or listing workflows.
+ (ctx, details, input) -> echoClient.echo(input));
+ }
+
+ @OperationImpl
+ public OperationHandler hello() {
+ // Use the WorkflowRunOperation.fromWorkflowMethod constructor, which is the easiest
+ // way to expose a workflow as an operation. To expose a workflow with a different input
+ // parameters then the operation or from an untyped stub, use the
+ // WorkflowRunOperation.fromWorkflowHandler constructor and the appropriate constructor method
+ // on WorkflowHandle.
+ return WorkflowRunOperation.fromWorkflowMethod(
+ (ctx, details, input) ->
+ Nexus.getOperationContext()
+ .getWorkflowClient()
+ .newWorkflowStub(
+ HelloHandlerWorkflow.class,
+ // Workflow IDs should typically be business meaningful IDs and are used to
+ // dedupe workflow starts. For this example, we're using the request ID
+ // allocated by Temporal when the caller workflow schedules
+ // the operation, this ID is guaranteed to be stable across retries of this
+ // operation.
+ //
+ // Task queue defaults to the task queue this operation is handled on.
+ WorkflowOptions.newBuilder().setWorkflowId(details.getRequestId()).build())
+ ::hello);
+ }
+}
diff --git a/core/src/main/java/io/temporal/samples/nexus/options/ClientOptions.java b/core/src/main/java/io/temporal/samples/nexus/options/ClientOptions.java
index 7ba699309..5d382eaab 100644
--- a/core/src/main/java/io/temporal/samples/nexus/options/ClientOptions.java
+++ b/core/src/main/java/io/temporal/samples/nexus/options/ClientOptions.java
@@ -1,29 +1,8 @@
-/*
- * Copyright (c) 2020 Temporal Technologies, Inc. All Rights Reserved
- *
- * Copyright 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
- * Modifications copyright (C) 2017 Uber Technologies, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"). You may not
- * use this file except in compliance with the License. A copy of the License is
- * located at
- *
- * http://aws.amazon.com/apache2.0
- *
- * or in the "license" file accompanying this file. This file is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
package io.temporal.samples.nexus.options;
-import io.grpc.Metadata;
import io.grpc.netty.shaded.io.grpc.netty.GrpcSslContexts;
import io.grpc.netty.shaded.io.netty.handler.ssl.SslContextBuilder;
import io.grpc.netty.shaded.io.netty.handler.ssl.util.InsecureTrustManagerFactory;
-import io.grpc.stub.MetadataUtils;
import io.temporal.client.WorkflowClient;
import io.temporal.client.WorkflowClientOptions;
import io.temporal.serviceclient.WorkflowServiceStubs;
@@ -34,7 +13,13 @@
import org.apache.commons.cli.*;
public class ClientOptions {
+
public static WorkflowClient getWorkflowClient(String[] args) {
+ return getWorkflowClient(args, WorkflowClientOptions.newBuilder());
+ }
+
+ public static WorkflowClient getWorkflowClient(
+ String[] args, WorkflowClientOptions.Builder clientOptions) {
Options options = new Options();
Option targetHostOption = new Option("target-host", true, "Host:port for the Temporal service");
targetHostOption.setRequired(false);
@@ -137,19 +122,10 @@ public static WorkflowClient getWorkflowClient(String[] args) {
if (!apiKey.isEmpty()) {
serviceStubOptionsBuilder.setEnableHttps(true);
serviceStubOptionsBuilder.addApiKey(() -> apiKey);
- Metadata.Key TEMPORAL_NAMESPACE_HEADER_KEY =
- Metadata.Key.of("temporal-namespace", Metadata.ASCII_STRING_MARSHALLER);
- Metadata metadata = new Metadata();
- metadata.put(TEMPORAL_NAMESPACE_HEADER_KEY, namespace);
- serviceStubOptionsBuilder.setChannelInitializer(
- (channel) -> {
- channel.intercept(MetadataUtils.newAttachHeadersInterceptor(metadata));
- });
}
WorkflowServiceStubs service =
WorkflowServiceStubs.newServiceStubs(serviceStubOptionsBuilder.build());
- return WorkflowClient.newInstance(
- service, WorkflowClientOptions.newBuilder().setNamespace(namespace).build());
+ return WorkflowClient.newInstance(service, clientOptions.setNamespace(namespace).build());
}
}
diff --git a/core/src/main/java/io/temporal/samples/nexus/service/NexusService.java b/core/src/main/java/io/temporal/samples/nexus/service/SampleNexusService.java
similarity index 70%
rename from core/src/main/java/io/temporal/samples/nexus/service/NexusService.java
rename to core/src/main/java/io/temporal/samples/nexus/service/SampleNexusService.java
index e12dcbe92..180f9ec28 100644
--- a/core/src/main/java/io/temporal/samples/nexus/service/NexusService.java
+++ b/core/src/main/java/io/temporal/samples/nexus/service/SampleNexusService.java
@@ -1,22 +1,3 @@
-/*
- * Copyright (c) 2020 Temporal Technologies, Inc. All Rights Reserved
- *
- * Copyright 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
- * Modifications copyright (C) 2017 Uber Technologies, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"). You may not
- * use this file except in compliance with the License. A copy of the License is
- * located at
- *
- * http://aws.amazon.com/apache2.0
- *
- * or in the "license" file accompanying this file. This file is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
package io.temporal.samples.nexus.service;
import com.fasterxml.jackson.annotation.JsonCreator;
@@ -25,7 +6,7 @@
import io.nexusrpc.Service;
@Service
-public interface NexusService {
+public interface SampleNexusService {
enum Language {
EN,
FR,
diff --git a/core/src/main/java/io/temporal/samples/nexus/service/description.md b/core/src/main/java/io/temporal/samples/nexus/service/description.md
index 98dc27083..b1cafb3a2 100644
--- a/core/src/main/java/io/temporal/samples/nexus/service/description.md
+++ b/core/src/main/java/io/temporal/samples/nexus/service/description.md
@@ -1,8 +1,6 @@
-Service Name:
-NexusService
-Operation Names:
-echo
-hello
+## Service: [SampleNexusService](https://github.com/temporalio/samples-java/blob/main/core/src/main/java/io/temporal/samples/nexus/service/SampleNexusService.java)
+ - operation: `echo`
+ - operation: `hello`
+
+See https://github.com/temporalio/samples-java/blob/main/core/src/main/java/io/temporal/samples/nexus/service/SampleNexusService.java for Input / Output types.
-Input / Output arguments are in the following repository:
-https://github.com/temporalio/samples-java/core/src/main/java/io/temporal/samples/nexus/service/NexusService.java
diff --git a/core/src/main/java/io/temporal/samples/nexuscancellation/README.MD b/core/src/main/java/io/temporal/samples/nexuscancellation/README.MD
new file mode 100644
index 000000000..bd69da875
--- /dev/null
+++ b/core/src/main/java/io/temporal/samples/nexuscancellation/README.MD
@@ -0,0 +1,47 @@
+# Nexus Cancellation
+
+This sample shows how to cancel a Nexus operation from a caller workflow and specify a cancellation type. In this sample we will show using the `WAIT_REQUESTED` cancellation type, which allows the caller to return after the handler workflow has received the requested to be cancelled, but does not wait for the handler workflow to finish processing the cancellation request.
+
+To run this sample, set up your environment following the instructions in the main [Nexus Sample](../nexus/README.md).
+
+Next, in separate terminal windows:
+
+### Nexus handler worker
+
+```
+./gradlew -q execute -PmainClass=io.temporal.samples.nexuscancellation.handler.HandlerWorker \
+ --args="-target-host localhost:7233 -namespace my-target-namespace"
+```
+
+### Nexus caller worker
+
+```
+./gradlew -q execute -PmainClass=io.temporal.samples.nexuscancellation.caller.CallerWorker \
+ --args="-target-host localhost:7233 -namespace my-caller-namespace"
+```
+
+### Start caller workflow
+
+```
+./gradlew -q execute -PmainClass=io.temporal.samples.nexuscancellation.caller.CallerStarter \
+ --args="-target-host localhost:7233 -namespace my-caller-namespace"
+```
+
+### Output
+
+which should result in on the caller side:
+```
+14:33:52.810 i.t.s.n.caller.CallerStarter - Started workflow workflowId: 87e97bf0-ca8a-4ae6-a9dc-ae97e5c0ac41 runId: 01976b36-a524-71a1-b848-8eb385fec2c3
+14:33:54.250 i.t.s.n.caller.CallerStarter - Workflow result: Hallo Nexus 👋
+```
+
+on the handler side:
+
+```
+14:33:54.177 INFO i.t.s.n.h.HelloHandlerWorkflowImpl - HelloHandlerWorkflow was cancelled successfully.
+14:33:56.167 INFO i.t.s.n.h.HelloHandlerWorkflowImpl - HelloHandlerWorkflow was cancelled successfully.
+14:33:57.172 INFO i.t.s.n.h.HelloHandlerWorkflowImpl - HelloHandlerWorkflow was cancelled successfully.
+14:33:57.176 INFO i.t.s.n.h.HelloHandlerWorkflowImpl - HelloHandlerWorkflow was cancelled successfully.
+```
+
+Notice the timing, the caller workflow returned before the handler workflow was cancelled. This is because of the use of `WAIT_REQUESTED` as the cancellation type in the Nexus operation. This means the caller didn't have to wait for the handler workflow to finish, but still guarantees the handler workflow will receive the cancellation request.
\ No newline at end of file
diff --git a/core/src/main/java/io/temporal/samples/nexuscancellation/caller/CallerStarter.java b/core/src/main/java/io/temporal/samples/nexuscancellation/caller/CallerStarter.java
new file mode 100644
index 000000000..c0cd95dde
--- /dev/null
+++ b/core/src/main/java/io/temporal/samples/nexuscancellation/caller/CallerStarter.java
@@ -0,0 +1,27 @@
+package io.temporal.samples.nexuscancellation.caller;
+
+import io.temporal.api.common.v1.WorkflowExecution;
+import io.temporal.client.WorkflowClient;
+import io.temporal.client.WorkflowOptions;
+import io.temporal.samples.nexus.options.ClientOptions;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class CallerStarter {
+ private static final Logger logger = LoggerFactory.getLogger(CallerStarter.class);
+
+ public static void main(String[] args) {
+ WorkflowClient client = ClientOptions.getWorkflowClient(args);
+
+ WorkflowOptions workflowOptions =
+ WorkflowOptions.newBuilder().setTaskQueue(CallerWorker.DEFAULT_TASK_QUEUE_NAME).build();
+ HelloCallerWorkflow helloWorkflow =
+ client.newWorkflowStub(HelloCallerWorkflow.class, workflowOptions);
+ WorkflowExecution execution = WorkflowClient.start(helloWorkflow::hello, "Nexus");
+ logger.info(
+ "Started workflow workflowId: {} runId: {}",
+ execution.getWorkflowId(),
+ execution.getRunId());
+ logger.info("Workflow result: {}", helloWorkflow.hello("Nexus"));
+ }
+}
diff --git a/core/src/main/java/io/temporal/samples/nexuscancellation/caller/CallerWorker.java b/core/src/main/java/io/temporal/samples/nexuscancellation/caller/CallerWorker.java
new file mode 100644
index 000000000..811cecde8
--- /dev/null
+++ b/core/src/main/java/io/temporal/samples/nexuscancellation/caller/CallerWorker.java
@@ -0,0 +1,32 @@
+package io.temporal.samples.nexuscancellation.caller;
+
+import io.temporal.client.WorkflowClient;
+import io.temporal.samples.nexus.options.ClientOptions;
+import io.temporal.samples.nexus.service.SampleNexusService;
+import io.temporal.worker.Worker;
+import io.temporal.worker.WorkerFactory;
+import io.temporal.worker.WorkflowImplementationOptions;
+import io.temporal.workflow.NexusServiceOptions;
+import java.util.Collections;
+
+public class CallerWorker {
+ public static final String DEFAULT_TASK_QUEUE_NAME = "my-caller-workflow-task-queue";
+
+ public static void main(String[] args) {
+ WorkflowClient client = ClientOptions.getWorkflowClient(args);
+
+ WorkerFactory factory = WorkerFactory.newInstance(client);
+
+ Worker worker = factory.newWorker(DEFAULT_TASK_QUEUE_NAME);
+ worker.registerWorkflowImplementationTypes(
+ WorkflowImplementationOptions.newBuilder()
+ .setNexusServiceOptions(
+ Collections.singletonMap(
+ SampleNexusService.class.getSimpleName(),
+ NexusServiceOptions.newBuilder().setEndpoint("my-nexus-endpoint-name").build()))
+ .build(),
+ HelloCallerWorkflowImpl.class);
+
+ factory.start();
+ }
+}
diff --git a/core/src/main/java/io/temporal/samples/nexuscancellation/caller/HelloCallerWorkflow.java b/core/src/main/java/io/temporal/samples/nexuscancellation/caller/HelloCallerWorkflow.java
new file mode 100644
index 000000000..a585d713c
--- /dev/null
+++ b/core/src/main/java/io/temporal/samples/nexuscancellation/caller/HelloCallerWorkflow.java
@@ -0,0 +1,10 @@
+package io.temporal.samples.nexuscancellation.caller;
+
+import io.temporal.workflow.WorkflowInterface;
+import io.temporal.workflow.WorkflowMethod;
+
+@WorkflowInterface
+public interface HelloCallerWorkflow {
+ @WorkflowMethod
+ String hello(String message);
+}
diff --git a/core/src/main/java/io/temporal/samples/nexuscancellation/caller/HelloCallerWorkflowImpl.java b/core/src/main/java/io/temporal/samples/nexuscancellation/caller/HelloCallerWorkflowImpl.java
new file mode 100644
index 000000000..6072906b4
--- /dev/null
+++ b/core/src/main/java/io/temporal/samples/nexuscancellation/caller/HelloCallerWorkflowImpl.java
@@ -0,0 +1,85 @@
+package io.temporal.samples.nexuscancellation.caller;
+
+import static io.temporal.samples.nexus.service.SampleNexusService.Language.*;
+
+import io.temporal.failure.CanceledFailure;
+import io.temporal.failure.NexusOperationFailure;
+import io.temporal.samples.nexus.service.SampleNexusService;
+import io.temporal.workflow.*;
+import java.time.Duration;
+import java.util.ArrayList;
+import java.util.List;
+import org.slf4j.Logger;
+
+public class HelloCallerWorkflowImpl implements HelloCallerWorkflow {
+ public static final Logger log = Workflow.getLogger(HelloCallerWorkflowImpl.class);
+ private static final SampleNexusService.Language[] languages =
+ new SampleNexusService.Language[] {EN, FR, DE, ES, TR};
+ SampleNexusService sampleNexusService =
+ Workflow.newNexusServiceStub(
+ SampleNexusService.class,
+ NexusServiceOptions.newBuilder()
+ .setOperationOptions(
+ NexusOperationOptions.newBuilder()
+ .setScheduleToCloseTimeout(Duration.ofSeconds(10))
+ // Set the cancellation type to WAIT_REQUESTED. This means that the caller
+ // will wait for the cancellation request to be received by the handler before
+ // proceeding with the cancellation.
+ //
+ // By default, the caller would wait until the operation is completed.
+ .setCancellationType(NexusOperationCancellationType.WAIT_REQUESTED)
+ .build())
+ .build());
+
+ @Override
+ public String hello(String message) {
+ List> results = new ArrayList<>(languages.length);
+
+ /*
+ * Create our CancellationScope. Within this scope we call the nexus operation asynchronously
+ * hello method asynchronously for each of our defined languages.
+ */
+ CancellationScope scope =
+ Workflow.newCancellationScope(
+ () -> {
+ for (SampleNexusService.Language language : languages) {
+ results.add(
+ Async.function(
+ sampleNexusService::hello,
+ new SampleNexusService.HelloInput(message, language)));
+ }
+ });
+
+ /*
+ * Execute all nexus operations within the CancellationScope. Note that this execution is
+ * non-blocking as the code inside our cancellation scope is also non-blocking.
+ */
+ scope.run();
+
+ // We use "anyOf" here to wait for one of the nexus operation invocations to return
+ SampleNexusService.HelloOutput result = Promise.anyOf(results).get();
+
+ // Trigger cancellation of all uncompleted nexus operations invocations within the cancellation
+ // scope
+ scope.cancel();
+ // Wait for all nexus operations to receive a cancellation request before
+ // proceeding.
+ //
+ // Note: Once the workflow completes any pending cancellation requests are dropped by the
+ // server. In general, it is a good practice to wait for all cancellation requests to be
+ // processed before completing the workflow.
+ for (Promise promise : results) {
+ try {
+ promise.get();
+ } catch (NexusOperationFailure e) {
+ // If the operation was cancelled, we can ignore the failure
+ if (e.getCause() instanceof CanceledFailure) {
+ log.info("Operation was cancelled");
+ continue;
+ }
+ throw e;
+ }
+ }
+ return result.getMessage();
+ }
+}
diff --git a/core/src/main/java/io/temporal/samples/nexuscancellation/handler/HandlerWorker.java b/core/src/main/java/io/temporal/samples/nexuscancellation/handler/HandlerWorker.java
new file mode 100644
index 000000000..f7d0f6940
--- /dev/null
+++ b/core/src/main/java/io/temporal/samples/nexuscancellation/handler/HandlerWorker.java
@@ -0,0 +1,23 @@
+package io.temporal.samples.nexuscancellation.handler;
+
+import io.temporal.client.WorkflowClient;
+import io.temporal.samples.nexus.handler.SampleNexusServiceImpl;
+import io.temporal.samples.nexus.options.ClientOptions;
+import io.temporal.worker.Worker;
+import io.temporal.worker.WorkerFactory;
+
+public class HandlerWorker {
+ public static final String DEFAULT_TASK_QUEUE_NAME = "my-handler-task-queue";
+
+ public static void main(String[] args) {
+ WorkflowClient client = ClientOptions.getWorkflowClient(args);
+
+ WorkerFactory factory = WorkerFactory.newInstance(client);
+
+ Worker worker = factory.newWorker(DEFAULT_TASK_QUEUE_NAME);
+ worker.registerWorkflowImplementationTypes(HelloHandlerWorkflowImpl.class);
+ worker.registerNexusServiceImplementation(new SampleNexusServiceImpl());
+
+ factory.start();
+ }
+}
diff --git a/core/src/main/java/io/temporal/samples/nexuscancellation/handler/HelloHandlerWorkflowImpl.java b/core/src/main/java/io/temporal/samples/nexuscancellation/handler/HelloHandlerWorkflowImpl.java
new file mode 100644
index 000000000..de8b93557
--- /dev/null
+++ b/core/src/main/java/io/temporal/samples/nexuscancellation/handler/HelloHandlerWorkflowImpl.java
@@ -0,0 +1,42 @@
+package io.temporal.samples.nexuscancellation.handler;
+
+import io.temporal.failure.ApplicationFailure;
+import io.temporal.failure.CanceledFailure;
+import io.temporal.samples.nexus.handler.HelloHandlerWorkflow;
+import io.temporal.samples.nexus.service.SampleNexusService;
+import io.temporal.workflow.Workflow;
+import java.time.Duration;
+import org.slf4j.Logger;
+
+public class HelloHandlerWorkflowImpl implements HelloHandlerWorkflow {
+ public static final Logger log = Workflow.getLogger(HelloHandlerWorkflowImpl.class);
+
+ @Override
+ public SampleNexusService.HelloOutput hello(SampleNexusService.HelloInput input) {
+ // Sleep for a random duration to simulate some work
+ try {
+ Workflow.sleep(Duration.ofSeconds(Workflow.newRandom().nextInt(5)));
+ switch (input.getLanguage()) {
+ case EN:
+ return new SampleNexusService.HelloOutput("Hello " + input.getName() + " 👋");
+ case FR:
+ return new SampleNexusService.HelloOutput("Bonjour " + input.getName() + " 👋");
+ case DE:
+ return new SampleNexusService.HelloOutput("Hallo " + input.getName() + " 👋");
+ case ES:
+ return new SampleNexusService.HelloOutput("¡Hola! " + input.getName() + " 👋");
+ case TR:
+ return new SampleNexusService.HelloOutput("Merhaba " + input.getName() + " 👋");
+ }
+ throw ApplicationFailure.newFailure(
+ "Unsupported language: " + input.getLanguage(), "UNSUPPORTED_LANGUAGE");
+ } catch (CanceledFailure e) {
+ // Simulate some work after cancellation is requested
+ Workflow.newDetachedCancellationScope(
+ () -> Workflow.sleep(Duration.ofSeconds(Workflow.newRandom().nextInt(5))))
+ .run();
+ log.info("HelloHandlerWorkflow was cancelled successfully.");
+ throw e;
+ }
+ }
+}
diff --git a/core/src/main/java/io/temporal/samples/nexuscontextpropagation/README.MD b/core/src/main/java/io/temporal/samples/nexuscontextpropagation/README.MD
new file mode 100644
index 000000000..54e2bc4f9
--- /dev/null
+++ b/core/src/main/java/io/temporal/samples/nexuscontextpropagation/README.MD
@@ -0,0 +1,45 @@
+# Nexus Context Propagation
+
+This sample shows how to propagate MDC (Mapped Diagnostic Context) context values from Workflows to Nexus operations.
+Nexus does not support `ContextPropagator` since the header format is not compatible. Users should look at `NexusMDCContextInterceptor` for propagating MDC context values.
+
+To run this sample, set up your environment following the instructions in the main [Nexus Sample](../nexus/README.md).
+
+Next, in separate terminal windows:
+
+### Nexus handler worker
+
+```
+./gradlew -q execute -PmainClass=io.temporal.samples.nexuscontextpropagation.handler.HandlerWorker \
+ --args="-target-host localhost:7233 -namespace my-target-namespace"
+```
+
+### Nexus caller worker
+
+```
+./gradlew -q execute -PmainClass=io.temporal.samples.nexuscontextpropagation.caller.CallerWorker \
+ --args="-target-host localhost:7233 -namespace my-caller-namespace"
+```
+
+### Start caller workflow
+
+```
+./gradlew -q execute -PmainClass=io.temporal.samples.nexuscontextpropagation.caller.CallerStarter \
+ --args="-target-host localhost:7233 -namespace my-caller-namespace"
+```
+
+### Output
+
+which should result in this on the caller side:
+```
+INFO i.t.s.n.caller.CallerStarter - Started EchoCallerWorkflow workflowId: 7ac97cb9-b457-4052-af94-d82478c35c5e runId: 01954eb9-6963-7b52-9a1d-b74e64643846
+INFO i.t.s.n.caller.CallerStarter - Workflow result: Nexus Echo 👋
+INFO i.t.s.n.caller.CallerStarter - Started HelloCallerWorkflow workflowId: 9e0bc89c-5709-4742-b7c0-868464c2fccf runId: 01954eb9-6ae3-7d6d-b355-71545688309d
+INFO i.t.s.n.caller.CallerStarter - Workflow result: Hello Nexus 👋
+```
+
+And this on the handler side:
+```
+INFO i.t.s.n.handler.SampleNexusServiceImpl - Echo called from a workflow with ID : 7ac97cb9-b457-4052-af94-d82478c35c5e
+INFO i.t.s.n.h.HelloHandlerWorkflowImpl - HelloHandlerWorkflow called from a workflow with ID : 9e0bc89c-5709-4742-b7c0-868464c2fccf
+```
diff --git a/core/src/main/java/io/temporal/samples/nexuscontextpropagation/caller/CallerStarter.java b/core/src/main/java/io/temporal/samples/nexuscontextpropagation/caller/CallerStarter.java
new file mode 100644
index 000000000..cfcc739de
--- /dev/null
+++ b/core/src/main/java/io/temporal/samples/nexuscontextpropagation/caller/CallerStarter.java
@@ -0,0 +1,46 @@
+package io.temporal.samples.nexuscontextpropagation.caller;
+
+import io.temporal.api.common.v1.WorkflowExecution;
+import io.temporal.client.WorkflowClient;
+import io.temporal.client.WorkflowClientOptions;
+import io.temporal.client.WorkflowOptions;
+import io.temporal.samples.nexus.caller.EchoCallerWorkflow;
+import io.temporal.samples.nexus.caller.HelloCallerWorkflow;
+import io.temporal.samples.nexus.options.ClientOptions;
+import io.temporal.samples.nexus.service.SampleNexusService;
+import io.temporal.samples.nexuscontextpropagation.propagation.MDCContextPropagator;
+import java.util.Collections;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class CallerStarter {
+ private static final Logger logger = LoggerFactory.getLogger(CallerStarter.class);
+
+ public static void main(String[] args) {
+ WorkflowClient client =
+ ClientOptions.getWorkflowClient(
+ args,
+ WorkflowClientOptions.newBuilder()
+ .setContextPropagators(Collections.singletonList(new MDCContextPropagator())));
+
+ WorkflowOptions workflowOptions =
+ WorkflowOptions.newBuilder().setTaskQueue(CallerWorker.DEFAULT_TASK_QUEUE_NAME).build();
+ EchoCallerWorkflow echoWorkflow =
+ client.newWorkflowStub(EchoCallerWorkflow.class, workflowOptions);
+ WorkflowExecution execution = WorkflowClient.start(echoWorkflow::echo, "Nexus Echo 👋");
+ logger.info(
+ "Started EchoCallerWorkflow workflowId: {} runId: {}",
+ execution.getWorkflowId(),
+ execution.getRunId());
+ logger.info("Workflow result: {}", echoWorkflow.echo("Nexus Echo 👋"));
+ HelloCallerWorkflow helloWorkflow =
+ client.newWorkflowStub(HelloCallerWorkflow.class, workflowOptions);
+ execution = WorkflowClient.start(helloWorkflow::hello, "Nexus", SampleNexusService.Language.EN);
+ logger.info(
+ "Started HelloCallerWorkflow workflowId: {} runId: {}",
+ execution.getWorkflowId(),
+ execution.getRunId());
+ logger.info(
+ "Workflow result: {}", helloWorkflow.hello("Nexus", SampleNexusService.Language.ES));
+ }
+}
diff --git a/core/src/main/java/io/temporal/samples/nexuscontextpropagation/caller/CallerWorker.java b/core/src/main/java/io/temporal/samples/nexuscontextpropagation/caller/CallerWorker.java
new file mode 100644
index 000000000..db3f1cfb9
--- /dev/null
+++ b/core/src/main/java/io/temporal/samples/nexuscontextpropagation/caller/CallerWorker.java
@@ -0,0 +1,39 @@
+package io.temporal.samples.nexuscontextpropagation.caller;
+
+import io.temporal.client.WorkflowClient;
+import io.temporal.samples.nexus.options.ClientOptions;
+import io.temporal.samples.nexuscontextpropagation.propagation.NexusMDCContextInterceptor;
+import io.temporal.worker.Worker;
+import io.temporal.worker.WorkerFactory;
+import io.temporal.worker.WorkerFactoryOptions;
+import io.temporal.worker.WorkflowImplementationOptions;
+import io.temporal.workflow.NexusServiceOptions;
+import java.util.Collections;
+
+public class CallerWorker {
+ public static final String DEFAULT_TASK_QUEUE_NAME = "my-caller-workflow-task-queue";
+
+ public static void main(String[] args) {
+ WorkflowClient client = ClientOptions.getWorkflowClient(args);
+
+ WorkerFactory factory =
+ WorkerFactory.newInstance(
+ client,
+ WorkerFactoryOptions.newBuilder()
+ .setWorkerInterceptors(new NexusMDCContextInterceptor())
+ .build());
+
+ Worker worker = factory.newWorker(DEFAULT_TASK_QUEUE_NAME);
+ worker.registerWorkflowImplementationTypes(
+ WorkflowImplementationOptions.newBuilder()
+ .setNexusServiceOptions(
+ Collections.singletonMap(
+ "SampleNexusService",
+ NexusServiceOptions.newBuilder().setEndpoint("my-nexus-endpoint-name").build()))
+ .build(),
+ EchoCallerWorkflowImpl.class,
+ HelloCallerWorkflowImpl.class);
+
+ factory.start();
+ }
+}
diff --git a/core/src/main/java/io/temporal/samples/nexuscontextpropagation/caller/EchoCallerWorkflowImpl.java b/core/src/main/java/io/temporal/samples/nexuscontextpropagation/caller/EchoCallerWorkflowImpl.java
new file mode 100644
index 000000000..3de27350d
--- /dev/null
+++ b/core/src/main/java/io/temporal/samples/nexuscontextpropagation/caller/EchoCallerWorkflowImpl.java
@@ -0,0 +1,27 @@
+package io.temporal.samples.nexuscontextpropagation.caller;
+
+import io.temporal.samples.nexus.caller.EchoCallerWorkflow;
+import io.temporal.samples.nexus.service.SampleNexusService;
+import io.temporal.workflow.NexusOperationOptions;
+import io.temporal.workflow.NexusServiceOptions;
+import io.temporal.workflow.Workflow;
+import java.time.Duration;
+import org.slf4j.MDC;
+
+public class EchoCallerWorkflowImpl implements EchoCallerWorkflow {
+ SampleNexusService sampleNexusService =
+ Workflow.newNexusServiceStub(
+ SampleNexusService.class,
+ NexusServiceOptions.newBuilder()
+ .setOperationOptions(
+ NexusOperationOptions.newBuilder()
+ .setScheduleToCloseTimeout(Duration.ofSeconds(10))
+ .build())
+ .build());
+
+ @Override
+ public String echo(String message) {
+ MDC.put("x-nexus-caller-workflow-id", Workflow.getInfo().getWorkflowId());
+ return sampleNexusService.echo(new SampleNexusService.EchoInput(message)).getMessage();
+ }
+}
diff --git a/core/src/main/java/io/temporal/samples/nexuscontextpropagation/caller/HelloCallerWorkflowImpl.java b/core/src/main/java/io/temporal/samples/nexuscontextpropagation/caller/HelloCallerWorkflowImpl.java
new file mode 100644
index 000000000..b817179a4
--- /dev/null
+++ b/core/src/main/java/io/temporal/samples/nexuscontextpropagation/caller/HelloCallerWorkflowImpl.java
@@ -0,0 +1,34 @@
+package io.temporal.samples.nexuscontextpropagation.caller;
+
+import io.temporal.samples.nexus.caller.HelloCallerWorkflow;
+import io.temporal.samples.nexus.service.SampleNexusService;
+import io.temporal.workflow.NexusOperationHandle;
+import io.temporal.workflow.NexusOperationOptions;
+import io.temporal.workflow.NexusServiceOptions;
+import io.temporal.workflow.Workflow;
+import java.time.Duration;
+import org.slf4j.MDC;
+
+public class HelloCallerWorkflowImpl implements HelloCallerWorkflow {
+ SampleNexusService sampleNexusService =
+ Workflow.newNexusServiceStub(
+ SampleNexusService.class,
+ NexusServiceOptions.newBuilder()
+ .setOperationOptions(
+ NexusOperationOptions.newBuilder()
+ .setScheduleToCloseTimeout(Duration.ofSeconds(10))
+ .build())
+ .build());
+
+ @Override
+ public String hello(String message, SampleNexusService.Language language) {
+ MDC.put("x-nexus-caller-workflow-id", Workflow.getInfo().getWorkflowId());
+ NexusOperationHandle handle =
+ Workflow.startNexusOperation(
+ sampleNexusService::hello, new SampleNexusService.HelloInput(message, language));
+ // Optionally wait for the operation to be started. NexusOperationExecution will contain the
+ // operation token in case this operation is asynchronous.
+ handle.getExecution().get();
+ return handle.getResult().get().getMessage();
+ }
+}
diff --git a/core/src/main/java/io/temporal/samples/nexuscontextpropagation/handler/HandlerWorker.java b/core/src/main/java/io/temporal/samples/nexuscontextpropagation/handler/HandlerWorker.java
new file mode 100644
index 000000000..31b665a8a
--- /dev/null
+++ b/core/src/main/java/io/temporal/samples/nexuscontextpropagation/handler/HandlerWorker.java
@@ -0,0 +1,36 @@
+package io.temporal.samples.nexuscontextpropagation.handler;
+
+import io.temporal.client.WorkflowClient;
+import io.temporal.client.WorkflowClientOptions;
+import io.temporal.samples.nexus.options.ClientOptions;
+import io.temporal.samples.nexuscontextpropagation.propagation.MDCContextPropagator;
+import io.temporal.samples.nexuscontextpropagation.propagation.NexusMDCContextInterceptor;
+import io.temporal.worker.Worker;
+import io.temporal.worker.WorkerFactory;
+import io.temporal.worker.WorkerFactoryOptions;
+import java.util.Collections;
+
+public class HandlerWorker {
+ public static final String DEFAULT_TASK_QUEUE_NAME = "my-handler-task-queue";
+
+ public static void main(String[] args) {
+ WorkflowClient client =
+ ClientOptions.getWorkflowClient(
+ args,
+ WorkflowClientOptions.newBuilder()
+ .setContextPropagators(Collections.singletonList(new MDCContextPropagator())));
+
+ WorkerFactory factory =
+ WorkerFactory.newInstance(
+ client,
+ WorkerFactoryOptions.newBuilder()
+ .setWorkerInterceptors(new NexusMDCContextInterceptor())
+ .build());
+
+ Worker worker = factory.newWorker(DEFAULT_TASK_QUEUE_NAME);
+ worker.registerWorkflowImplementationTypes(HelloHandlerWorkflowImpl.class);
+ worker.registerNexusServiceImplementation(new SampleNexusServiceImpl());
+
+ factory.start();
+ }
+}
diff --git a/core/src/main/java/io/temporal/samples/nexuscontextpropagation/handler/HelloHandlerWorkflowImpl.java b/core/src/main/java/io/temporal/samples/nexuscontextpropagation/handler/HelloHandlerWorkflowImpl.java
new file mode 100644
index 000000000..324ad34c1
--- /dev/null
+++ b/core/src/main/java/io/temporal/samples/nexuscontextpropagation/handler/HelloHandlerWorkflowImpl.java
@@ -0,0 +1,35 @@
+package io.temporal.samples.nexuscontextpropagation.handler;
+
+import io.temporal.failure.ApplicationFailure;
+import io.temporal.samples.nexus.handler.HelloHandlerWorkflow;
+import io.temporal.samples.nexus.service.SampleNexusService;
+import io.temporal.workflow.Workflow;
+import org.slf4j.Logger;
+import org.slf4j.MDC;
+
+public class HelloHandlerWorkflowImpl implements HelloHandlerWorkflow {
+ public static final Logger log = Workflow.getLogger(HelloHandlerWorkflowImpl.class);
+
+ @Override
+ public SampleNexusService.HelloOutput hello(SampleNexusService.HelloInput input) {
+ if (MDC.get("x-nexus-caller-workflow-id") != null) {
+ log.info(
+ "HelloHandlerWorkflow called from a workflow with ID : {}",
+ MDC.get("x-nexus-caller-workflow-id"));
+ }
+ switch (input.getLanguage()) {
+ case EN:
+ return new SampleNexusService.HelloOutput("Hello " + input.getName() + " 👋");
+ case FR:
+ return new SampleNexusService.HelloOutput("Bonjour " + input.getName() + " 👋");
+ case DE:
+ return new SampleNexusService.HelloOutput("Hallo " + input.getName() + " 👋");
+ case ES:
+ return new SampleNexusService.HelloOutput("¡Hola! " + input.getName() + " 👋");
+ case TR:
+ return new SampleNexusService.HelloOutput("Merhaba " + input.getName() + " 👋");
+ }
+ throw ApplicationFailure.newFailure(
+ "Unsupported language: " + input.getLanguage(), "UNSUPPORTED_LANGUAGE");
+ }
+}
diff --git a/core/src/main/java/io/temporal/samples/nexuscontextpropagation/handler/SampleNexusServiceImpl.java b/core/src/main/java/io/temporal/samples/nexuscontextpropagation/handler/SampleNexusServiceImpl.java
new file mode 100644
index 000000000..fc69e756b
--- /dev/null
+++ b/core/src/main/java/io/temporal/samples/nexuscontextpropagation/handler/SampleNexusServiceImpl.java
@@ -0,0 +1,65 @@
+package io.temporal.samples.nexuscontextpropagation.handler;
+
+import io.nexusrpc.handler.OperationHandler;
+import io.nexusrpc.handler.OperationImpl;
+import io.nexusrpc.handler.ServiceImpl;
+import io.temporal.client.WorkflowOptions;
+import io.temporal.nexus.Nexus;
+import io.temporal.nexus.WorkflowRunOperation;
+import io.temporal.samples.nexus.handler.HelloHandlerWorkflow;
+import io.temporal.samples.nexus.service.SampleNexusService;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.slf4j.MDC;
+
+// To create a service implementation, annotate the class with @ServiceImpl and provide the
+// interface that the service implements. The service implementation class should have methods that
+// return OperationHandler that correspond to the operations defined in the service interface.
+@ServiceImpl(service = SampleNexusService.class)
+public class SampleNexusServiceImpl {
+ private static final Logger logger = LoggerFactory.getLogger(SampleNexusServiceImpl.class);
+
+ @OperationImpl
+ public OperationHandler echo() {
+ // OperationHandler.sync is a meant for exposing simple RPC handlers.
+ return OperationHandler.sync(
+ // The method is for making arbitrary short calls to other services or databases, or
+ // perform simple computations such as this one. Users can also access a workflow client by
+ // calling
+ // Nexus.getOperationContext().getWorkflowClient(ctx) to make arbitrary calls such as
+ // signaling, querying, or listing workflows.
+ (ctx, details, input) -> {
+ if (MDC.get("x-nexus-caller-workflow-id") != null) {
+ logger.info(
+ "Echo called from a workflow with ID : {}", MDC.get("x-nexus-caller-workflow-id"));
+ }
+ return new SampleNexusService.EchoOutput(input.getMessage());
+ });
+ }
+
+ @OperationImpl
+ public OperationHandler hello() {
+ // Use the WorkflowRunOperation.fromWorkflowMethod constructor, which is the easiest
+ // way to expose a workflow as an operation. To expose a workflow with a different input
+ // parameters then the operation or from an untyped stub, use the
+ // WorkflowRunOperation.fromWorkflowHandler constructor and the appropriate constructor method
+ // on WorkflowHandle.
+ return WorkflowRunOperation.fromWorkflowMethod(
+ (ctx, details, input) ->
+ Nexus.getOperationContext()
+ .getWorkflowClient()
+ .newWorkflowStub(
+ HelloHandlerWorkflow.class,
+ // Workflow IDs should typically be business meaningful IDs and are used to
+ // dedupe workflow starts.
+ // For this example, we're using the request ID allocated by Temporal when
+ // the
+ // caller workflow schedules
+ // the operation, this ID is guaranteed to be stable across retries of this
+ // operation.
+ //
+ // Task queue defaults to the task queue this operation is handled on.
+ WorkflowOptions.newBuilder().setWorkflowId(details.getRequestId()).build())
+ ::hello);
+ }
+}
diff --git a/core/src/main/java/io/temporal/samples/nexuscontextpropagation/propagation/MDCContextPropagator.java b/core/src/main/java/io/temporal/samples/nexuscontextpropagation/propagation/MDCContextPropagator.java
new file mode 100644
index 000000000..fe1cd54af
--- /dev/null
+++ b/core/src/main/java/io/temporal/samples/nexuscontextpropagation/propagation/MDCContextPropagator.java
@@ -0,0 +1,61 @@
+package io.temporal.samples.nexuscontextpropagation.propagation;
+
+import io.temporal.api.common.v1.Payload;
+import io.temporal.common.context.ContextPropagator;
+import io.temporal.common.converter.DataConverter;
+import java.util.HashMap;
+import java.util.Map;
+import org.slf4j.MDC;
+
+public class MDCContextPropagator implements ContextPropagator {
+
+ @Override
+ public String getName() {
+ return this.getClass().getName();
+ }
+
+ @Override
+ public Object getCurrentContext() {
+ Map context = new HashMap<>();
+ if (MDC.getCopyOfContextMap() == null) {
+ return context;
+ }
+ for (Map.Entry entry : MDC.getCopyOfContextMap().entrySet()) {
+ if (entry.getKey().startsWith("x-nexus-")) {
+ context.put(entry.getKey(), entry.getValue());
+ }
+ }
+ return context;
+ }
+
+ @Override
+ public void setCurrentContext(Object context) {
+ Map contextMap = (Map) context;
+ for (Map.Entry entry : contextMap.entrySet()) {
+ MDC.put(entry.getKey(), entry.getValue());
+ }
+ }
+
+ @Override
+ public Map serializeContext(Object context) {
+ Map contextMap = (Map) context;
+ Map serializedContext = new HashMap<>();
+ for (Map.Entry entry : contextMap.entrySet()) {
+ serializedContext.put(
+ entry.getKey(), DataConverter.getDefaultInstance().toPayload(entry.getValue()).get());
+ }
+ return serializedContext;
+ }
+
+ @Override
+ public Object deserializeContext(Map context) {
+ Map contextMap = new HashMap<>();
+ for (Map.Entry entry : context.entrySet()) {
+ contextMap.put(
+ entry.getKey(),
+ DataConverter.getDefaultInstance()
+ .fromPayload(entry.getValue(), String.class, String.class));
+ }
+ return contextMap;
+ }
+}
diff --git a/core/src/main/java/io/temporal/samples/nexuscontextpropagation/propagation/NexusMDCContextInterceptor.java b/core/src/main/java/io/temporal/samples/nexuscontextpropagation/propagation/NexusMDCContextInterceptor.java
new file mode 100644
index 000000000..e252af2cc
--- /dev/null
+++ b/core/src/main/java/io/temporal/samples/nexuscontextpropagation/propagation/NexusMDCContextInterceptor.java
@@ -0,0 +1,110 @@
+package io.temporal.samples.nexuscontextpropagation.propagation;
+
+import io.nexusrpc.OperationException;
+import io.nexusrpc.handler.OperationContext;
+import io.temporal.common.interceptors.NexusOperationInboundCallsInterceptor;
+import io.temporal.common.interceptors.WorkerInterceptorBase;
+import io.temporal.common.interceptors.WorkflowInboundCallsInterceptor;
+import io.temporal.common.interceptors.WorkflowOutboundCallsInterceptor;
+import java.util.Map;
+import org.slf4j.MDC;
+
+/**
+ * Propagates MDC context from the caller workflow to the Nexus service through the operation
+ * headers.
+ */
+public class NexusMDCContextInterceptor extends WorkerInterceptorBase {
+ private static final String NEXUS_HEADER_PREFIX = "x-nexus-";
+
+ @Override
+ public WorkflowInboundCallsInterceptor interceptWorkflow(WorkflowInboundCallsInterceptor next) {
+ return new WorkflowInboundCallsInterceptorNexusMDC(next);
+ }
+
+ public static class WorkflowInboundCallsInterceptorNexusMDC
+ extends io.temporal.common.interceptors.WorkflowInboundCallsInterceptorBase {
+ private final WorkflowInboundCallsInterceptor next;
+
+ public WorkflowInboundCallsInterceptorNexusMDC(WorkflowInboundCallsInterceptor next) {
+ super(next);
+ this.next = next;
+ }
+
+ @Override
+ public void init(WorkflowOutboundCallsInterceptor outboundCalls) {
+ next.init(new WorkflowOutboundCallsInterceptorNexusMDC(outboundCalls));
+ }
+ }
+
+ public static class WorkflowOutboundCallsInterceptorNexusMDC
+ extends io.temporal.common.interceptors.WorkflowOutboundCallsInterceptorBase {
+ private final WorkflowOutboundCallsInterceptor next;
+
+ public WorkflowOutboundCallsInterceptorNexusMDC(WorkflowOutboundCallsInterceptor next) {
+ super(next);
+ this.next = next;
+ }
+
+ @Override
+ public ExecuteNexusOperationOutput executeNexusOperation(
+ ExecuteNexusOperationInput input) {
+ Map contextMap = MDC.getCopyOfContextMap();
+ if (contextMap != null) {
+ Map headerMap = input.getHeaders();
+ contextMap.forEach(
+ (k, v) -> {
+ if (k.startsWith(NEXUS_HEADER_PREFIX)) {
+ headerMap.put(k, v);
+ }
+ });
+ }
+ return next.executeNexusOperation(input);
+ }
+ }
+
+ @Override
+ public NexusOperationInboundCallsInterceptor interceptNexusOperation(
+ OperationContext context, NexusOperationInboundCallsInterceptor next) {
+ return new NexusOperationInboundCallsInterceptorNexusMDC(next);
+ }
+
+ private static class NexusOperationInboundCallsInterceptorNexusMDC
+ extends io.temporal.common.interceptors.NexusOperationInboundCallsInterceptorBase {
+ private final NexusOperationInboundCallsInterceptor next;
+
+ public NexusOperationInboundCallsInterceptorNexusMDC(
+ NexusOperationInboundCallsInterceptor next) {
+ super(next);
+ this.next = next;
+ }
+
+ @Override
+ public StartOperationOutput startOperation(StartOperationInput input)
+ throws OperationException {
+ input
+ .getOperationContext()
+ .getHeaders()
+ .forEach(
+ (k, v) -> {
+ if (k.startsWith(NEXUS_HEADER_PREFIX)) {
+ MDC.put(k, v);
+ }
+ });
+ return next.startOperation(input);
+ }
+
+ @Override
+ public CancelOperationOutput cancelOperation(CancelOperationInput input) {
+ input
+ .getOperationContext()
+ .getHeaders()
+ .forEach(
+ (k, v) -> {
+ if (k.startsWith(NEXUS_HEADER_PREFIX)) {
+ MDC.put(k, v);
+ }
+ });
+ return next.cancelOperation(input);
+ }
+ }
+}
diff --git a/core/src/main/java/io/temporal/samples/nexusmultipleargs/README.MD b/core/src/main/java/io/temporal/samples/nexusmultipleargs/README.MD
new file mode 100644
index 000000000..754545091
--- /dev/null
+++ b/core/src/main/java/io/temporal/samples/nexusmultipleargs/README.MD
@@ -0,0 +1,36 @@
+# Nexus Multiple Arguments Sample
+
+This sample shows how to map a Nexus operation to a caller workflow that takes multiple input arguments using [WorkflowRunOperation.fromWorkflowHandle](https://javadoc.io/doc/io.temporal/temporal-sdk/latest/io/temporal/nexus/WorkflowRunOperation.html#fromWorkflowHandle(io.temporal.nexus.WorkflowHandleFactory)).
+
+To run this sample, set up your environment following the instructions in the main [Nexus Sample](../nexus/README.md).
+
+In separate terminal windows:
+
+### Nexus handler worker
+
+```
+./gradlew -q execute -PmainClass=io.temporal.samples.nexusmultipleargs.handler.HandlerWorker \
+ --args="-target-host localhost:7233 -namespace my-target-namespace"
+```
+
+### Nexus caller worker
+
+```
+./gradlew -q execute -PmainClass=io.temporal.samples.nexusmultipleargs.caller.CallerWorker \
+ --args="-target-host localhost:7233 -namespace my-caller-namespace"
+```
+
+### Start caller workflow
+
+```
+./gradlew -q execute -PmainClass=io.temporal.samples.nexusmultipleargs.caller.CallerStarter \
+ --args="-target-host localhost:7233 -namespace my-caller-namespace"
+```
+
+### Output
+
+which should result in:
+```
+[main] INFO i.t.s.nexus.caller.CallerStarter - Workflow result: Nexus Echo 👋
+[main] INFO i.t.s.nexus.caller.CallerStarter - Workflow result: ¡Hola! Nexus 👋
+```
diff --git a/core/src/main/java/io/temporal/samples/nexusmultipleargs/caller/CallerStarter.java b/core/src/main/java/io/temporal/samples/nexusmultipleargs/caller/CallerStarter.java
new file mode 100644
index 000000000..4d3e7cff5
--- /dev/null
+++ b/core/src/main/java/io/temporal/samples/nexusmultipleargs/caller/CallerStarter.java
@@ -0,0 +1,40 @@
+package io.temporal.samples.nexusmultipleargs.caller;
+
+import io.temporal.api.common.v1.WorkflowExecution;
+import io.temporal.client.WorkflowClient;
+import io.temporal.client.WorkflowOptions;
+import io.temporal.samples.nexus.caller.CallerWorker;
+import io.temporal.samples.nexus.caller.EchoCallerWorkflow;
+import io.temporal.samples.nexus.caller.HelloCallerWorkflow;
+import io.temporal.samples.nexus.options.ClientOptions;
+import io.temporal.samples.nexus.service.SampleNexusService;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class CallerStarter {
+ private static final Logger logger = LoggerFactory.getLogger(CallerStarter.class);
+
+ public static void main(String[] args) {
+ WorkflowClient client = ClientOptions.getWorkflowClient(args);
+
+ WorkflowOptions workflowOptions =
+ WorkflowOptions.newBuilder().setTaskQueue(CallerWorker.DEFAULT_TASK_QUEUE_NAME).build();
+ EchoCallerWorkflow echoWorkflow =
+ client.newWorkflowStub(EchoCallerWorkflow.class, workflowOptions);
+ WorkflowExecution execution = WorkflowClient.start(echoWorkflow::echo, "Nexus Echo 👋");
+ logger.info(
+ "Started EchoCallerWorkflow workflowId: {} runId: {}",
+ execution.getWorkflowId(),
+ execution.getRunId());
+ logger.info("Workflow result: {}", echoWorkflow.echo("Nexus Echo 👋"));
+ HelloCallerWorkflow helloWorkflow =
+ client.newWorkflowStub(HelloCallerWorkflow.class, workflowOptions);
+ execution = WorkflowClient.start(helloWorkflow::hello, "Nexus", SampleNexusService.Language.EN);
+ logger.info(
+ "Started HelloCallerWorkflow workflowId: {} runId: {}",
+ execution.getWorkflowId(),
+ execution.getRunId());
+ logger.info(
+ "Workflow result: {}", helloWorkflow.hello("Nexus", SampleNexusService.Language.ES));
+ }
+}
diff --git a/core/src/main/java/io/temporal/samples/nexusmultipleargs/caller/CallerWorker.java b/core/src/main/java/io/temporal/samples/nexusmultipleargs/caller/CallerWorker.java
new file mode 100644
index 000000000..64272e6a2
--- /dev/null
+++ b/core/src/main/java/io/temporal/samples/nexusmultipleargs/caller/CallerWorker.java
@@ -0,0 +1,32 @@
+package io.temporal.samples.nexusmultipleargs.caller;
+
+import io.temporal.client.WorkflowClient;
+import io.temporal.samples.nexus.options.ClientOptions;
+import io.temporal.worker.Worker;
+import io.temporal.worker.WorkerFactory;
+import io.temporal.worker.WorkflowImplementationOptions;
+import io.temporal.workflow.NexusServiceOptions;
+import java.util.Collections;
+
+public class CallerWorker {
+ public static final String DEFAULT_TASK_QUEUE_NAME = "my-caller-workflow-task-queue";
+
+ public static void main(String[] args) {
+ WorkflowClient client = ClientOptions.getWorkflowClient(args);
+
+ WorkerFactory factory = WorkerFactory.newInstance(client);
+
+ Worker worker = factory.newWorker(DEFAULT_TASK_QUEUE_NAME);
+ worker.registerWorkflowImplementationTypes(
+ WorkflowImplementationOptions.newBuilder()
+ .setNexusServiceOptions(
+ Collections.singletonMap(
+ "SampleNexusService",
+ NexusServiceOptions.newBuilder().setEndpoint("my-nexus-endpoint-name").build()))
+ .build(),
+ EchoCallerWorkflowImpl.class,
+ HelloCallerWorkflowImpl.class);
+
+ factory.start();
+ }
+}
diff --git a/core/src/main/java/io/temporal/samples/nexusmultipleargs/caller/EchoCallerWorkflow.java b/core/src/main/java/io/temporal/samples/nexusmultipleargs/caller/EchoCallerWorkflow.java
new file mode 100644
index 000000000..47f1adce2
--- /dev/null
+++ b/core/src/main/java/io/temporal/samples/nexusmultipleargs/caller/EchoCallerWorkflow.java
@@ -0,0 +1,10 @@
+package io.temporal.samples.nexusmultipleargs.caller;
+
+import io.temporal.workflow.WorkflowInterface;
+import io.temporal.workflow.WorkflowMethod;
+
+@WorkflowInterface
+public interface EchoCallerWorkflow {
+ @WorkflowMethod
+ String echo(String message);
+}
diff --git a/core/src/main/java/io/temporal/samples/nexusmultipleargs/caller/EchoCallerWorkflowImpl.java b/core/src/main/java/io/temporal/samples/nexusmultipleargs/caller/EchoCallerWorkflowImpl.java
new file mode 100644
index 000000000..20d875ddb
--- /dev/null
+++ b/core/src/main/java/io/temporal/samples/nexusmultipleargs/caller/EchoCallerWorkflowImpl.java
@@ -0,0 +1,25 @@
+package io.temporal.samples.nexusmultipleargs.caller;
+
+import io.temporal.samples.nexus.caller.EchoCallerWorkflow;
+import io.temporal.samples.nexus.service.SampleNexusService;
+import io.temporal.workflow.NexusOperationOptions;
+import io.temporal.workflow.NexusServiceOptions;
+import io.temporal.workflow.Workflow;
+import java.time.Duration;
+
+public class EchoCallerWorkflowImpl implements EchoCallerWorkflow {
+ SampleNexusService sampleNexusService =
+ Workflow.newNexusServiceStub(
+ SampleNexusService.class,
+ NexusServiceOptions.newBuilder()
+ .setOperationOptions(
+ NexusOperationOptions.newBuilder()
+ .setScheduleToCloseTimeout(Duration.ofSeconds(10))
+ .build())
+ .build());
+
+ @Override
+ public String echo(String message) {
+ return sampleNexusService.echo(new SampleNexusService.EchoInput(message)).getMessage();
+ }
+}
diff --git a/core/src/main/java/io/temporal/samples/nexusmultipleargs/caller/HelloCallerWorkflow.java b/core/src/main/java/io/temporal/samples/nexusmultipleargs/caller/HelloCallerWorkflow.java
new file mode 100644
index 000000000..03a8635ed
--- /dev/null
+++ b/core/src/main/java/io/temporal/samples/nexusmultipleargs/caller/HelloCallerWorkflow.java
@@ -0,0 +1,11 @@
+package io.temporal.samples.nexusmultipleargs.caller;
+
+import io.temporal.samples.nexus.service.SampleNexusService;
+import io.temporal.workflow.WorkflowInterface;
+import io.temporal.workflow.WorkflowMethod;
+
+@WorkflowInterface
+public interface HelloCallerWorkflow {
+ @WorkflowMethod
+ String hello(String message, SampleNexusService.Language language);
+}
diff --git a/core/src/main/java/io/temporal/samples/nexusmultipleargs/caller/HelloCallerWorkflowImpl.java b/core/src/main/java/io/temporal/samples/nexusmultipleargs/caller/HelloCallerWorkflowImpl.java
new file mode 100644
index 000000000..5d3c0824b
--- /dev/null
+++ b/core/src/main/java/io/temporal/samples/nexusmultipleargs/caller/HelloCallerWorkflowImpl.java
@@ -0,0 +1,32 @@
+package io.temporal.samples.nexusmultipleargs.caller;
+
+import io.temporal.samples.nexus.caller.HelloCallerWorkflow;
+import io.temporal.samples.nexus.service.SampleNexusService;
+import io.temporal.workflow.NexusOperationHandle;
+import io.temporal.workflow.NexusOperationOptions;
+import io.temporal.workflow.NexusServiceOptions;
+import io.temporal.workflow.Workflow;
+import java.time.Duration;
+
+public class HelloCallerWorkflowImpl implements HelloCallerWorkflow {
+ SampleNexusService sampleNexusService =
+ Workflow.newNexusServiceStub(
+ SampleNexusService.class,
+ NexusServiceOptions.newBuilder()
+ .setOperationOptions(
+ NexusOperationOptions.newBuilder()
+ .setScheduleToCloseTimeout(Duration.ofSeconds(10))
+ .build())
+ .build());
+
+ @Override
+ public String hello(String message, SampleNexusService.Language language) {
+ NexusOperationHandle handle =
+ Workflow.startNexusOperation(
+ sampleNexusService::hello, new SampleNexusService.HelloInput(message, language));
+ // Optionally wait for the operation to be started. NexusOperationExecution will contain the
+ // operation token in case this operation is asynchronous.
+ handle.getExecution().get();
+ return handle.getResult().get().getMessage();
+ }
+}
diff --git a/core/src/main/java/io/temporal/samples/nexusmultipleargs/handler/HandlerWorker.java b/core/src/main/java/io/temporal/samples/nexusmultipleargs/handler/HandlerWorker.java
new file mode 100644
index 000000000..c3fd95e9f
--- /dev/null
+++ b/core/src/main/java/io/temporal/samples/nexusmultipleargs/handler/HandlerWorker.java
@@ -0,0 +1,22 @@
+package io.temporal.samples.nexusmultipleargs.handler;
+
+import io.temporal.client.WorkflowClient;
+import io.temporal.samples.nexus.options.ClientOptions;
+import io.temporal.worker.Worker;
+import io.temporal.worker.WorkerFactory;
+
+public class HandlerWorker {
+ public static final String DEFAULT_TASK_QUEUE_NAME = "my-handler-task-queue";
+
+ public static void main(String[] args) {
+ WorkflowClient client = ClientOptions.getWorkflowClient(args);
+
+ WorkerFactory factory = WorkerFactory.newInstance(client);
+
+ Worker worker = factory.newWorker(DEFAULT_TASK_QUEUE_NAME);
+ worker.registerWorkflowImplementationTypes(HelloHandlerWorkflowImpl.class);
+ worker.registerNexusServiceImplementation(new SampleNexusServiceImpl());
+
+ factory.start();
+ }
+}
diff --git a/core/src/main/java/io/temporal/samples/nexusmultipleargs/handler/HelloHandlerWorkflow.java b/core/src/main/java/io/temporal/samples/nexusmultipleargs/handler/HelloHandlerWorkflow.java
new file mode 100644
index 000000000..d13906496
--- /dev/null
+++ b/core/src/main/java/io/temporal/samples/nexusmultipleargs/handler/HelloHandlerWorkflow.java
@@ -0,0 +1,11 @@
+package io.temporal.samples.nexusmultipleargs.handler;
+
+import io.temporal.samples.nexus.service.SampleNexusService;
+import io.temporal.workflow.WorkflowInterface;
+import io.temporal.workflow.WorkflowMethod;
+
+@WorkflowInterface
+public interface HelloHandlerWorkflow {
+ @WorkflowMethod
+ SampleNexusService.HelloOutput hello(String name, SampleNexusService.Language language);
+}
diff --git a/core/src/main/java/io/temporal/samples/nexusmultipleargs/handler/HelloHandlerWorkflowImpl.java b/core/src/main/java/io/temporal/samples/nexusmultipleargs/handler/HelloHandlerWorkflowImpl.java
new file mode 100644
index 000000000..9d9cc3733
--- /dev/null
+++ b/core/src/main/java/io/temporal/samples/nexusmultipleargs/handler/HelloHandlerWorkflowImpl.java
@@ -0,0 +1,24 @@
+package io.temporal.samples.nexusmultipleargs.handler;
+
+import io.temporal.failure.ApplicationFailure;
+import io.temporal.samples.nexus.service.SampleNexusService;
+
+public class HelloHandlerWorkflowImpl implements HelloHandlerWorkflow {
+ @Override
+ public SampleNexusService.HelloOutput hello(String name, SampleNexusService.Language language) {
+ switch (language) {
+ case EN:
+ return new SampleNexusService.HelloOutput("Hello " + name + " 👋");
+ case FR:
+ return new SampleNexusService.HelloOutput("Bonjour " + name + " 👋");
+ case DE:
+ return new SampleNexusService.HelloOutput("Hallo " + name + " 👋");
+ case ES:
+ return new SampleNexusService.HelloOutput("¡Hola! " + name + " 👋");
+ case TR:
+ return new SampleNexusService.HelloOutput("Merhaba " + name + " 👋");
+ }
+ throw ApplicationFailure.newFailure(
+ "Unsupported language: " + language, "UNSUPPORTED_LANGUAGE");
+ }
+}
diff --git a/core/src/main/java/io/temporal/samples/nexusmultipleargs/handler/SampleNexusServiceImpl.java b/core/src/main/java/io/temporal/samples/nexusmultipleargs/handler/SampleNexusServiceImpl.java
new file mode 100644
index 000000000..b5d819267
--- /dev/null
+++ b/core/src/main/java/io/temporal/samples/nexusmultipleargs/handler/SampleNexusServiceImpl.java
@@ -0,0 +1,60 @@
+package io.temporal.samples.nexusmultipleargs.handler;
+
+import io.nexusrpc.handler.OperationHandler;
+import io.nexusrpc.handler.OperationImpl;
+import io.nexusrpc.handler.ServiceImpl;
+import io.temporal.client.WorkflowOptions;
+import io.temporal.nexus.Nexus;
+import io.temporal.nexus.WorkflowHandle;
+import io.temporal.nexus.WorkflowRunOperation;
+import io.temporal.samples.nexus.service.SampleNexusService;
+
+// To create a service implementation, annotate the class with @ServiceImpl and provide the
+// interface that the service implements. The service implementation class should have methods that
+// return OperationHandler that correspond to the operations defined in the service interface.
+@ServiceImpl(service = SampleNexusService.class)
+public class SampleNexusServiceImpl {
+ @OperationImpl
+ public OperationHandler echo() {
+ // OperationHandler.sync is a meant for exposing simple RPC handlers.
+ return OperationHandler.sync(
+ // The method is for making arbitrary short calls to other services or databases, or
+ // perform simple computations such as this one. Users can also access a workflow client by
+ // calling
+ // Nexus.getOperationContext().getWorkflowClient(ctx) to make arbitrary calls such as
+ // signaling, querying, or listing workflows.
+ (ctx, details, input) -> new SampleNexusService.EchoOutput(input.getMessage()));
+ }
+
+ @OperationImpl
+ public OperationHandler hello() {
+ // If the operation input parameters are different from the workflow input parameters,
+ // use the WorkflowRunOperation.fromWorkflowHandler constructor and the appropriate constructor
+ // method on WorkflowHandle to map the Nexus input to the workflow parameters.
+ return WorkflowRunOperation.fromWorkflowHandle(
+ (ctx, details, input) ->
+ WorkflowHandle.fromWorkflowMethod(
+ Nexus.getOperationContext()
+ .getWorkflowClient()
+ .newWorkflowStub(
+ HelloHandlerWorkflow.class,
+ // Workflow IDs should typically be business meaningful IDs and are used
+ // to
+ // dedupe workflow starts.
+ // For this example, we're using the request ID allocated by Temporal
+ // when
+ // the
+ // caller workflow schedules
+ // the operation, this ID is guaranteed to be stable across retries of
+ // this
+ // operation.
+ //
+ // Task queue defaults to the task queue this operation is handled on.
+ WorkflowOptions.newBuilder()
+ .setWorkflowId(details.getRequestId())
+ .build())
+ ::hello,
+ input.getName(),
+ input.getLanguage()));
+ }
+}
diff --git a/core/src/main/java/io/temporal/samples/packetdelivery/Packet.java b/core/src/main/java/io/temporal/samples/packetdelivery/Packet.java
new file mode 100644
index 000000000..2d7ee91d4
--- /dev/null
+++ b/core/src/main/java/io/temporal/samples/packetdelivery/Packet.java
@@ -0,0 +1,21 @@
+package io.temporal.samples.packetdelivery;
+
+public class Packet {
+ private int id;
+ private String content;
+
+ public Packet() {}
+
+ public Packet(int id, String content) {
+ this.id = id;
+ this.content = content;
+ }
+
+ public int getId() {
+ return id;
+ }
+
+ public String getContent() {
+ return content;
+ }
+}
diff --git a/core/src/main/java/io/temporal/samples/packetdelivery/PacketDelivery.java b/core/src/main/java/io/temporal/samples/packetdelivery/PacketDelivery.java
new file mode 100644
index 000000000..334d21bcb
--- /dev/null
+++ b/core/src/main/java/io/temporal/samples/packetdelivery/PacketDelivery.java
@@ -0,0 +1,124 @@
+package io.temporal.samples.packetdelivery;
+
+import io.temporal.activity.ActivityOptions;
+import io.temporal.failure.ActivityFailure;
+import io.temporal.failure.CanceledFailure;
+import io.temporal.workflow.*;
+import java.time.Duration;
+import org.slf4j.Logger;
+
+public class PacketDelivery {
+ private Packet packet;
+ private boolean deliveryConfirmation = false;
+ private boolean needDeliveryConfirmation = false;
+ private CompletablePromise delivered = Workflow.newPromise();
+ private CancellationScope cancellationScope;
+
+ private Logger logger = Workflow.getLogger(this.getClass().getName());
+
+ private final PacketDeliveryActivities activities =
+ Workflow.newActivityStub(
+ PacketDeliveryActivities.class,
+ ActivityOptions.newBuilder()
+ .setStartToCloseTimeout(Duration.ofSeconds(5))
+ .setHeartbeatTimeout(Duration.ofSeconds(2))
+ .build());
+
+ private final PacketDeliveryActivities compensationActivities =
+ Workflow.newActivityStub(
+ PacketDeliveryActivities.class,
+ ActivityOptions.newBuilder().setStartToCloseTimeout(Duration.ofSeconds(3)).build());
+
+ public PacketDelivery(Packet packet) {
+ this.packet = packet;
+ processDeliveryAsync();
+ }
+
+ public Promise getDelivered() {
+ return delivered;
+ }
+
+ public void processDeliveryAsync() {
+ delivered.completeFrom(Async.procedure(this::processDelivery));
+ }
+
+ public void processDelivery() {
+ cancellationScope =
+ Workflow.newCancellationScope(
+ () -> {
+ String deliveryConfirmationResult = "";
+ while (!deliveryConfirmationResult.equals(PacketUtils.COMPLETION_SUCCESS)) {
+ // Step 1 perform delivery
+ logger.info(
+ "** Performing delivery for packet: "
+ + packet.getId()
+ + " - "
+ + packet.getContent());
+ activities.performDelivery(packet);
+ // Step 2 wait for delivery confirmation
+ logger.info(
+ "** Delivery for packet: "
+ + packet.getId()
+ + " - "
+ + packet.getContent()
+ + " awaiting delivery confirmation");
+ needDeliveryConfirmation = true;
+ Workflow.await(() -> deliveryConfirmation);
+ logger.info(
+ "** Delivery for packet: "
+ + packet.getId()
+ + " - "
+ + packet.getContent()
+ + " received confirmation");
+ // Step 3 complete delivery processing
+ logger.info(
+ "** Completing delivery for packet: "
+ + packet.getId()
+ + " - "
+ + packet.getContent());
+ deliveryConfirmationResult = activities.completeDelivery(packet);
+ // Reset deliveryConfirmation and needDeliveryConfirmation
+ deliveryConfirmation = false;
+ needDeliveryConfirmation = false;
+ }
+ });
+
+ try {
+ cancellationScope.run();
+ } catch (Exception e) {
+ if (e instanceof ActivityFailure) {
+ ActivityFailure activityFailure = (ActivityFailure) e;
+ if (activityFailure.getCause() instanceof CanceledFailure) {
+ // Run compensation activity and complete
+ compensationActivities.compensateDelivery(packet);
+ }
+ }
+ // Just for show for example that cancel could come in while we are waiting on approval signal
+ // too
+ else if (e instanceof CanceledFailure) {
+ needDeliveryConfirmation = false;
+ // Run compensation activity and complete
+ compensationActivities.compensateDelivery(packet);
+ }
+ return;
+ }
+ }
+
+ public void confirmDelivery() {
+ this.deliveryConfirmation = true;
+ }
+
+ public void cancelDelivery(String reason) {
+ if (cancellationScope != null) {
+ cancellationScope.cancel(reason);
+ }
+ }
+
+ public boolean isNeedDeliveryConfirmation() {
+ return needDeliveryConfirmation;
+ }
+
+ public Packet getPacket() {
+ return packet;
+ }
+}
diff --git a/core/src/main/java/io/temporal/samples/packetdelivery/PacketDeliveryActivities.java b/core/src/main/java/io/temporal/samples/packetdelivery/PacketDeliveryActivities.java
new file mode 100644
index 000000000..b2e67dbab
--- /dev/null
+++ b/core/src/main/java/io/temporal/samples/packetdelivery/PacketDeliveryActivities.java
@@ -0,0 +1,15 @@
+package io.temporal.samples.packetdelivery;
+
+import io.temporal.activity.ActivityInterface;
+import java.util.List;
+
+@ActivityInterface
+public interface PacketDeliveryActivities {
+ List generatePackets();
+
+ void performDelivery(Packet packet);
+
+ String completeDelivery(Packet packet);
+
+ String compensateDelivery(Packet packet);
+}
diff --git a/core/src/main/java/io/temporal/samples/packetdelivery/PacketDeliveryActivitiesImpl.java b/core/src/main/java/io/temporal/samples/packetdelivery/PacketDeliveryActivitiesImpl.java
new file mode 100644
index 000000000..655223501
--- /dev/null
+++ b/core/src/main/java/io/temporal/samples/packetdelivery/PacketDeliveryActivitiesImpl.java
@@ -0,0 +1,161 @@
+package io.temporal.samples.packetdelivery;
+
+import io.temporal.activity.Activity;
+import io.temporal.activity.ActivityExecutionContext;
+import io.temporal.client.ActivityCompletionException;
+import io.temporal.client.WorkflowClient;
+import java.util.*;
+
+public class PacketDeliveryActivitiesImpl implements PacketDeliveryActivities {
+ private List packets =
+ Arrays.asList(
+ new Packet(1, "books"),
+ new Packet(2, "jewelry"),
+ new Packet(3, "furniture"),
+ new Packet(4, "food"),
+ new Packet(5, "electronics"));
+ private WorkflowClient client;
+
+ public PacketDeliveryActivitiesImpl(WorkflowClient client) {
+ this.client = client;
+ }
+
+ @Override
+ public List generatePackets() {
+ return packets;
+ }
+
+ @Override
+ public void performDelivery(Packet packet) {
+ ActivityExecutionContext context = Activity.getExecutionContext();
+ System.out.println(
+ "** Activity - Performing delivery for packet: "
+ + packet.getId()
+ + " with content: "
+ + packet.getContent());
+ for (int i = 0; i < 4; i++) {
+ try {
+ // Perform the heartbeat. Used to notify the workflow that activity execution is alive
+ context.heartbeat(i);
+ } catch (ActivityCompletionException e) {
+ System.out.println(
+ "** Activity - Canceling delivery activity for packet: "
+ + packet.getId()
+ + " with content: "
+ + packet.getContent());
+ throw e;
+ }
+ }
+ }
+
+ @Override
+ public String completeDelivery(Packet packet) {
+ ActivityExecutionContext context = Activity.getExecutionContext();
+ System.out.println(
+ "** Activity - Completing delivery for package: "
+ + packet.getId()
+ + " with content: "
+ + packet.getContent());
+ for (int i = 0; i < 4; i++) {
+ try {
+ // Perform the heartbeat. Used to notify the workflow that activity execution is alive
+ context.heartbeat(i);
+ } catch (ActivityCompletionException e) {
+ System.out.println(
+ "** Activity - Canceling complete delivery activity for packet: "
+ + packet.getId()
+ + " with content: "
+ + packet.getContent());
+ throw e;
+ }
+ }
+ // For sample we just confirm
+ return randomCompletionDeliveryResult(packet);
+ }
+
+ @Override
+ public String compensateDelivery(Packet packet) {
+ System.out.println(
+ "** Activity - Compensating delivery for package: "
+ + packet.getId()
+ + " with content: "
+ + packet.getContent());
+ sleep(1);
+ return PacketUtils.COMPENSATION_COMPLETED;
+ }
+
+ /**
+ * For this sample activity completion result can drive if 1. Delivery confirmation is completed,
+ * in which case we complete delivery 2. Delivery confirmation is failed, in which case we run the
+ * delivery again 3. Delivery confirmation is cancelled, in which case we want to cancel delivery
+ * and perform "cleanup activity" Note that any delivery can cancel itself OR another delivery, so
+ * for example Furniure delivery can cancel the Food delivery. For sample we have some specific
+ * rules Which delivery can cancel which
+ */
+ private String randomCompletionDeliveryResult(Packet packet) {
+ Random random = new Random();
+ double randomValue = random.nextDouble();
+ if (randomValue < 0.10) { // 10% chance for delivery completion to be canceled
+ int toCancelDelivery = determineCancelRules(packet);
+ System.out.println(
+ "** Activity - Delivery completion result for package: "
+ + packet.getId()
+ + " with content: "
+ + packet.getContent()
+ + ": "
+ + "Cancelling delivery: "
+ + toCancelDelivery);
+
+ // send cancellation signal for packet to be canceled
+ PacketDeliveryWorkflow packetWorkflow =
+ client.newWorkflowStub(
+ PacketDeliveryWorkflow.class,
+ Activity.getExecutionContext().getInfo().getWorkflowId());
+ packetWorkflow.cancelDelivery(toCancelDelivery, "canceled from delivery " + packet.getId());
+
+ return PacketUtils.COMPLETION_CANCELLED;
+ }
+ if (randomValue < 0.20) { // 20% chance for delivery completion to fail
+ System.out.println(
+ "** Activity - Delivery completion result for package: "
+ + packet.getId()
+ + " with content: "
+ + packet.getContent()
+ + ": "
+ + "Failed");
+ return PacketUtils.COMPLETION_FAILURE;
+ }
+
+ System.out.println(
+ "** Activity - Delivery completion result for package: "
+ + packet.getId()
+ + " with content: "
+ + packet.getContent()
+ + ": "
+ + "Successful");
+ return PacketUtils.COMPLETION_SUCCESS;
+ }
+
+ private void sleep(int seconds) {
+ try {
+ Thread.sleep(seconds * 1000L);
+ } catch (Exception e) {
+ System.out.println(e.getMessage());
+ }
+ }
+
+ /**
+ * Sample rules for canceling different deliveries We just rotate the list 1-5 (packet ids) by
+ * packet id and return first result
+ */
+ private int determineCancelRules(Packet packet) {
+ List list = new ArrayList<>(Arrays.asList(1, 2, 3, 4, 5));
+ Collections.rotate(list, packet.getId());
+ System.out.println(
+ "** Activity - Package delivery : "
+ + packet.getId()
+ + " canceling package delivery: "
+ + list.get(0));
+ return list.get(0);
+ }
+}
diff --git a/core/src/main/java/io/temporal/samples/packetdelivery/PacketDeliveryWorkflow.java b/core/src/main/java/io/temporal/samples/packetdelivery/PacketDeliveryWorkflow.java
new file mode 100644
index 000000000..1f48fac08
--- /dev/null
+++ b/core/src/main/java/io/temporal/samples/packetdelivery/PacketDeliveryWorkflow.java
@@ -0,0 +1,22 @@
+package io.temporal.samples.packetdelivery;
+
+import io.temporal.workflow.QueryMethod;
+import io.temporal.workflow.SignalMethod;
+import io.temporal.workflow.WorkflowInterface;
+import io.temporal.workflow.WorkflowMethod;
+import java.util.List;
+
+@WorkflowInterface
+public interface PacketDeliveryWorkflow {
+ @WorkflowMethod
+ String execute();
+
+ @SignalMethod
+ void confirmDelivery(int deliveryId);
+
+ @SignalMethod
+ void cancelDelivery(int deliveryId, String reason);
+
+ @QueryMethod
+ List deliveryConfirmationPackets();
+}
diff --git a/core/src/main/java/io/temporal/samples/packetdelivery/PacketDeliveryWorkflowImpl.java b/core/src/main/java/io/temporal/samples/packetdelivery/PacketDeliveryWorkflowImpl.java
new file mode 100644
index 000000000..6236458d3
--- /dev/null
+++ b/core/src/main/java/io/temporal/samples/packetdelivery/PacketDeliveryWorkflowImpl.java
@@ -0,0 +1,79 @@
+package io.temporal.samples.packetdelivery;
+
+import io.temporal.activity.ActivityOptions;
+import io.temporal.workflow.Promise;
+import io.temporal.workflow.Workflow;
+import java.time.Duration;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import org.slf4j.Logger;
+
+public class PacketDeliveryWorkflowImpl implements PacketDeliveryWorkflow {
+ private final Map packetDeliveries = new HashMap<>();
+ private final Logger logger = Workflow.getLogger(this.getClass().getName());
+
+ private final PacketDeliveryActivities activities =
+ Workflow.newActivityStub(
+ PacketDeliveryActivities.class,
+ ActivityOptions.newBuilder()
+ .setStartToCloseTimeout(Duration.ofSeconds(5))
+ .setHeartbeatTimeout(Duration.ofSeconds(2))
+ .build());
+
+ @Override
+ public String execute() {
+ List> packetsDelivered = new ArrayList<>();
+ // Step 1 - upload initial packets to deliver
+ List initialPackets = activities.generatePackets();
+ // Step 2 - set up delivery processing
+ for (Packet packet : initialPackets) {
+ PacketDelivery delivery = new PacketDelivery(packet);
+ packetDeliveries.put(packet.getId(), delivery);
+ packetsDelivered.add(delivery.getDelivered());
+ }
+
+ // Wait for all packet deliveries to complete
+ Promise.allOf(packetsDelivered).get();
+ return "completed";
+ }
+
+ @Override
+ public void confirmDelivery(int deliveryId) {
+ if (packetDeliveries.containsKey(deliveryId)) {
+ packetDeliveries.get(deliveryId).confirmDelivery();
+ }
+ }
+
+ @Override
+ public void cancelDelivery(int deliveryId, String reason) {
+ if (packetDeliveries.containsKey(deliveryId)) {
+ // Only makes sense to cancel if delivery is not done yet
+ if (!packetDeliveries.get(deliveryId).getDelivered().isCompleted()) {
+ logger.info("Sending cancellation for delivery : " + deliveryId + " and reason: " + reason);
+ packetDeliveries.get(deliveryId).cancelDelivery(reason);
+ }
+ logger.info(
+ "Bypassing sending cancellation for delivery : "
+ + deliveryId
+ + " and reason: "
+ + reason
+ + " because delivery already completed");
+ }
+ }
+
+ @Override
+ public List deliveryConfirmationPackets() {
+ List confirmationPackets = new ArrayList<>();
+ packetDeliveries
+ .values()
+ .forEach(
+ p -> {
+ if (p.isNeedDeliveryConfirmation()) {
+ confirmationPackets.add(p.getPacket());
+ }
+ });
+ return confirmationPackets;
+ }
+}
diff --git a/core/src/main/java/io/temporal/samples/packetdelivery/PacketUtils.java b/core/src/main/java/io/temporal/samples/packetdelivery/PacketUtils.java
new file mode 100644
index 000000000..193a2f4be
--- /dev/null
+++ b/core/src/main/java/io/temporal/samples/packetdelivery/PacketUtils.java
@@ -0,0 +1,8 @@
+package io.temporal.samples.packetdelivery;
+
+public class PacketUtils {
+ public static String COMPLETION_SUCCESS = "Delivery Completion Successful";
+ public static String COMPLETION_FAILURE = "Delivery Completion Failed";
+ public static String COMPLETION_CANCELLED = "Delivery Completion Cancelled";
+ public static String COMPENSATION_COMPLETED = "Delivery Compensation Completed";
+}
diff --git a/core/src/main/java/io/temporal/samples/packetdelivery/README.md b/core/src/main/java/io/temporal/samples/packetdelivery/README.md
new file mode 100644
index 000000000..d43309990
--- /dev/null
+++ b/core/src/main/java/io/temporal/samples/packetdelivery/README.md
@@ -0,0 +1,24 @@
+# Async Package Delivery Sample
+
+This sample show how to run multiple "paths" of execution async within single workflow.
+Sample starts deliveries of 5 items in parallel. Each item performs an activity
+and then waits for a confirmation signal, then performs second activity.
+
+Workflow waits until all packets have been delivered. Each packet delivery path can choose to
+also "cancel" delivery of another item. This is done via signal and cancellation of the
+CancellationScope.
+
+## Notes
+1. In this sample we do not handle event history count and size partitioning via ContinueAsNew. It is assumed
+that the total number of paths and path lengths (in terms of activity executions) would not exceed it.
+For your use case you might need to add ContinueAsNew checks to deal with this situation.
+2. Use this sample as all other ones as reference for your implementation. It was not tested on high scale
+so using it as-is without load testing is not recommended.
+
+## Start the Sample:
+```bash
+./gradlew -q execute -PmainClass=io.temporal.samples.packetdelivery.Starter
+```
+
+Run sample multiple times to see different scenarios (delivery failure and retry and delivery cancelation)
+There is a 10% chance delivery is going to be canceled and 20% chane it will fail.
\ No newline at end of file
diff --git a/core/src/main/java/io/temporal/samples/packetdelivery/Starter.java b/core/src/main/java/io/temporal/samples/packetdelivery/Starter.java
new file mode 100644
index 000000000..f6ca6000d
--- /dev/null
+++ b/core/src/main/java/io/temporal/samples/packetdelivery/Starter.java
@@ -0,0 +1,81 @@
+package io.temporal.samples.packetdelivery;
+
+import io.temporal.client.WorkflowClient;
+import io.temporal.client.WorkflowNotFoundException;
+import io.temporal.client.WorkflowOptions;
+import io.temporal.client.WorkflowStub;
+import io.temporal.envconfig.ClientConfigProfile;
+import io.temporal.serviceclient.WorkflowServiceStubs;
+import io.temporal.worker.Worker;
+import io.temporal.worker.WorkerFactory;
+import java.io.IOException;
+import java.util.Collections;
+import java.util.List;
+
+public class Starter {
+ public static void main(String[] args) {
+ // Load configuration from environment and files
+ ClientConfigProfile profile;
+ try {
+ profile = ClientConfigProfile.load();
+ } catch (IOException e) {
+ throw new RuntimeException("Failed to load client configuration", e);
+ }
+
+ WorkflowServiceStubs service =
+ WorkflowServiceStubs.newServiceStubs(profile.toWorkflowServiceStubsOptions());
+ WorkflowClient client = WorkflowClient.newInstance(service, profile.toWorkflowClientOptions());
+ WorkerFactory factory = WorkerFactory.newInstance(client);
+ Worker worker = factory.newWorker("packet-delivery-taskqueue");
+
+ worker.registerWorkflowImplementationTypes(PacketDeliveryWorkflowImpl.class);
+ worker.registerActivitiesImplementations(new PacketDeliveryActivitiesImpl(client));
+
+ factory.start();
+
+ PacketDeliveryWorkflow workflow =
+ client.newWorkflowStub(
+ PacketDeliveryWorkflow.class,
+ WorkflowOptions.newBuilder()
+ .setWorkflowId("packet-delivery-workflow")
+ .setTaskQueue("packet-delivery-taskqueue")
+ .build());
+
+ WorkflowClient.start(workflow::execute);
+
+ // start completing package deliveries (send confirmations)
+ // Query workflow for packets that need confirmation, confirm until none need confirmation any
+ // more
+ while (true) {
+ sleep(3);
+ List packets = workflow.deliveryConfirmationPackets();
+ if (packets.isEmpty()) {
+ break;
+ }
+ // for "fun", reverse the list we get from delivery confirmation list
+ Collections.reverse(packets);
+
+ for (Packet p : packets) {
+ try {
+ workflow.confirmDelivery(p.getId());
+ } catch (WorkflowNotFoundException e) {
+ // In some cases with cancellations happening, workflow could be completed by now
+ // We just ignore and exit out of loop
+ break;
+ }
+ }
+ }
+
+ // wait for workflow to complete
+ String result = WorkflowStub.fromTyped(workflow).getResult(String.class);
+ System.out.println("** Workflow Result: " + result);
+ }
+
+ private static void sleep(int seconds) {
+ try {
+ Thread.sleep(seconds * 1000L);
+ } catch (Exception e) {
+ System.out.println(e.getMessage());
+ }
+ }
+}
diff --git a/core/src/main/java/io/temporal/samples/payloadconverter/cloudevents/CEWorkflow.java b/core/src/main/java/io/temporal/samples/payloadconverter/cloudevents/CEWorkflow.java
index 455581e65..052445724 100644
--- a/core/src/main/java/io/temporal/samples/payloadconverter/cloudevents/CEWorkflow.java
+++ b/core/src/main/java/io/temporal/samples/payloadconverter/cloudevents/CEWorkflow.java
@@ -1,22 +1,3 @@
-/*
- * Copyright (c) 2020 Temporal Technologies, Inc. All Rights Reserved
- *
- * Copyright 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
- * Modifications copyright (C) 2017 Uber Technologies, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"). You may not
- * use this file except in compliance with the License. A copy of the License is
- * located at
- *
- * http://aws.amazon.com/apache2.0
- *
- * or in the "license" file accompanying this file. This file is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
package io.temporal.samples.payloadconverter.cloudevents;
import io.cloudevents.CloudEvent;
diff --git a/core/src/main/java/io/temporal/samples/payloadconverter/cloudevents/CEWorkflowImpl.java b/core/src/main/java/io/temporal/samples/payloadconverter/cloudevents/CEWorkflowImpl.java
index f307aa5b6..d22644741 100644
--- a/core/src/main/java/io/temporal/samples/payloadconverter/cloudevents/CEWorkflowImpl.java
+++ b/core/src/main/java/io/temporal/samples/payloadconverter/cloudevents/CEWorkflowImpl.java
@@ -1,22 +1,3 @@
-/*
- * Copyright (c) 2020 Temporal Technologies, Inc. All Rights Reserved
- *
- * Copyright 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
- * Modifications copyright (C) 2017 Uber Technologies, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"). You may not
- * use this file except in compliance with the License. A copy of the License is
- * located at
- *
- * http://aws.amazon.com/apache2.0
- *
- * or in the "license" file accompanying this file. This file is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
package io.temporal.samples.payloadconverter.cloudevents;
import io.cloudevents.CloudEvent;
diff --git a/core/src/main/java/io/temporal/samples/payloadconverter/cloudevents/CloudEventsPayloadConverter.java b/core/src/main/java/io/temporal/samples/payloadconverter/cloudevents/CloudEventsPayloadConverter.java
index 39659c64f..c1a06a780 100644
--- a/core/src/main/java/io/temporal/samples/payloadconverter/cloudevents/CloudEventsPayloadConverter.java
+++ b/core/src/main/java/io/temporal/samples/payloadconverter/cloudevents/CloudEventsPayloadConverter.java
@@ -1,22 +1,3 @@
-/*
- * Copyright (c) 2020 Temporal Technologies, Inc. All Rights Reserved
- *
- * Copyright 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
- * Modifications copyright (C) 2017 Uber Technologies, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"). You may not
- * use this file except in compliance with the License. A copy of the License is
- * located at
- *
- * http://aws.amazon.com/apache2.0
- *
- * or in the "license" file accompanying this file. This file is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
package io.temporal.samples.payloadconverter.cloudevents;
import com.google.protobuf.ByteString;
diff --git a/core/src/main/java/io/temporal/samples/payloadconverter/cloudevents/Starter.java b/core/src/main/java/io/temporal/samples/payloadconverter/cloudevents/Starter.java
index 630407e0e..e9e368a3b 100644
--- a/core/src/main/java/io/temporal/samples/payloadconverter/cloudevents/Starter.java
+++ b/core/src/main/java/io/temporal/samples/payloadconverter/cloudevents/Starter.java
@@ -1,22 +1,3 @@
-/*
- * Copyright (c) 2020 Temporal Technologies, Inc. All Rights Reserved
- *
- * Copyright 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
- * Modifications copyright (C) 2017 Uber Technologies, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"). You may not
- * use this file except in compliance with the License. A copy of the License is
- * located at
- *
- * http://aws.amazon.com/apache2.0
- *
- * or in the "license" file accompanying this file. This file is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
package io.temporal.samples.payloadconverter.cloudevents;
import io.cloudevents.CloudEvent;
@@ -26,9 +7,11 @@
import io.temporal.client.WorkflowClientOptions;
import io.temporal.client.WorkflowOptions;
import io.temporal.common.converter.DefaultDataConverter;
+import io.temporal.envconfig.ClientConfigProfile;
import io.temporal.serviceclient.WorkflowServiceStubs;
import io.temporal.worker.Worker;
import io.temporal.worker.WorkerFactory;
+import java.io.IOException;
import java.net.URI;
import java.nio.charset.Charset;
import java.util.ArrayList;
@@ -39,7 +22,16 @@ public class Starter {
private static final String TASK_QUEUE = "CloudEventsConverterQueue";
public static void main(String[] args) {
- WorkflowServiceStubs service = WorkflowServiceStubs.newLocalServiceStubs();
+ // Load configuration from environment and files
+ ClientConfigProfile profile;
+ try {
+ profile = ClientConfigProfile.load();
+ } catch (IOException e) {
+ throw new RuntimeException("Failed to load client configuration", e);
+ }
+
+ WorkflowServiceStubs service =
+ WorkflowServiceStubs.newServiceStubs(profile.toWorkflowServiceStubsOptions());
// Add CloudEventsPayloadConverter
// It has the same encoding type as JacksonJsonPayloadConverter
diff --git a/core/src/main/java/io/temporal/samples/payloadconverter/crypto/CryptoWorkflow.java b/core/src/main/java/io/temporal/samples/payloadconverter/crypto/CryptoWorkflow.java
index c6f11cc8c..c1445a9dd 100644
--- a/core/src/main/java/io/temporal/samples/payloadconverter/crypto/CryptoWorkflow.java
+++ b/core/src/main/java/io/temporal/samples/payloadconverter/crypto/CryptoWorkflow.java
@@ -1,22 +1,3 @@
-/*
- * Copyright (c) 2020 Temporal Technologies, Inc. All Rights Reserved
- *
- * Copyright 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
- * Modifications copyright (C) 2017 Uber Technologies, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"). You may not
- * use this file except in compliance with the License. A copy of the License is
- * located at
- *
- * http://aws.amazon.com/apache2.0
- *
- * or in the "license" file accompanying this file. This file is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
package io.temporal.samples.payloadconverter.crypto;
import io.temporal.workflow.WorkflowInterface;
diff --git a/core/src/main/java/io/temporal/samples/payloadconverter/crypto/CryptoWorkflowImpl.java b/core/src/main/java/io/temporal/samples/payloadconverter/crypto/CryptoWorkflowImpl.java
index fbf35f779..5ab041c55 100644
--- a/core/src/main/java/io/temporal/samples/payloadconverter/crypto/CryptoWorkflowImpl.java
+++ b/core/src/main/java/io/temporal/samples/payloadconverter/crypto/CryptoWorkflowImpl.java
@@ -1,22 +1,3 @@
-/*
- * Copyright (c) 2020 Temporal Technologies, Inc. All Rights Reserved
- *
- * Copyright 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
- * Modifications copyright (C) 2017 Uber Technologies, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"). You may not
- * use this file except in compliance with the License. A copy of the License is
- * located at
- *
- * http://aws.amazon.com/apache2.0
- *
- * or in the "license" file accompanying this file. This file is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
package io.temporal.samples.payloadconverter.crypto;
public class CryptoWorkflowImpl implements CryptoWorkflow {
diff --git a/core/src/main/java/io/temporal/samples/payloadconverter/crypto/MyCustomer.java b/core/src/main/java/io/temporal/samples/payloadconverter/crypto/MyCustomer.java
index d3096a12c..a9cf46cf1 100644
--- a/core/src/main/java/io/temporal/samples/payloadconverter/crypto/MyCustomer.java
+++ b/core/src/main/java/io/temporal/samples/payloadconverter/crypto/MyCustomer.java
@@ -1,22 +1,3 @@
-/*
- * Copyright (c) 2020 Temporal Technologies, Inc. All Rights Reserved
- *
- * Copyright 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
- * Modifications copyright (C) 2017 Uber Technologies, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"). You may not
- * use this file except in compliance with the License. A copy of the License is
- * located at
- *
- * http://aws.amazon.com/apache2.0
- *
- * or in the "license" file accompanying this file. This file is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
package io.temporal.samples.payloadconverter.crypto;
import com.codingrodent.jackson.crypto.Encrypt;
diff --git a/core/src/main/java/io/temporal/samples/payloadconverter/crypto/Starter.java b/core/src/main/java/io/temporal/samples/payloadconverter/crypto/Starter.java
index 3940c0f79..4a5e121ef 100644
--- a/core/src/main/java/io/temporal/samples/payloadconverter/crypto/Starter.java
+++ b/core/src/main/java/io/temporal/samples/payloadconverter/crypto/Starter.java
@@ -1,22 +1,3 @@
-/*
- * Copyright (c) 2020 Temporal Technologies, Inc. All Rights Reserved
- *
- * Copyright 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
- * Modifications copyright (C) 2017 Uber Technologies, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"). You may not
- * use this file except in compliance with the License. A copy of the License is
- * located at
- *
- * http://aws.amazon.com/apache2.0
- *
- * or in the "license" file accompanying this file. This file is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
package io.temporal.samples.payloadconverter.crypto;
import com.codingrodent.jackson.crypto.CryptoModule;
@@ -28,16 +9,27 @@
import io.temporal.client.WorkflowOptions;
import io.temporal.common.converter.DefaultDataConverter;
import io.temporal.common.converter.JacksonJsonPayloadConverter;
+import io.temporal.envconfig.ClientConfigProfile;
import io.temporal.serviceclient.WorkflowServiceStubs;
import io.temporal.worker.Worker;
import io.temporal.worker.WorkerFactory;
+import java.io.IOException;
public class Starter {
private static final String TASK_QUEUE = "CryptoConverterQueue";
private static final String encryptDecryptPassword = "encryptDecryptPassword";
public static void main(String[] args) {
- WorkflowServiceStubs service = WorkflowServiceStubs.newLocalServiceStubs();
+ // Load configuration from environment and files
+ ClientConfigProfile profile;
+ try {
+ profile = ClientConfigProfile.load();
+ } catch (IOException e) {
+ throw new RuntimeException("Failed to load client configuration", e);
+ }
+
+ WorkflowServiceStubs service =
+ WorkflowServiceStubs.newServiceStubs(profile.toWorkflowServiceStubsOptions());
// Set crypto data converter in client options
WorkflowClient client =
diff --git a/core/src/main/java/io/temporal/samples/peractivityoptions/FailingActivities.java b/core/src/main/java/io/temporal/samples/peractivityoptions/FailingActivities.java
index 109ec98ae..08dc596ba 100644
--- a/core/src/main/java/io/temporal/samples/peractivityoptions/FailingActivities.java
+++ b/core/src/main/java/io/temporal/samples/peractivityoptions/FailingActivities.java
@@ -1,22 +1,3 @@
-/*
- * Copyright (c) 2020 Temporal Technologies, Inc. All Rights Reserved
- *
- * Copyright 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
- * Modifications copyright (C) 2017 Uber Technologies, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"). You may not
- * use this file except in compliance with the License. A copy of the License is
- * located at
- *
- * http://aws.amazon.com/apache2.0
- *
- * or in the "license" file accompanying this file. This file is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
package io.temporal.samples.peractivityoptions;
import io.temporal.activity.ActivityInterface;
diff --git a/core/src/main/java/io/temporal/samples/peractivityoptions/FailingActivitiesImpl.java b/core/src/main/java/io/temporal/samples/peractivityoptions/FailingActivitiesImpl.java
index 928b735f5..8e8810566 100644
--- a/core/src/main/java/io/temporal/samples/peractivityoptions/FailingActivitiesImpl.java
+++ b/core/src/main/java/io/temporal/samples/peractivityoptions/FailingActivitiesImpl.java
@@ -1,22 +1,3 @@
-/*
- * Copyright (c) 2020 Temporal Technologies, Inc. All Rights Reserved
- *
- * Copyright 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
- * Modifications copyright (C) 2017 Uber Technologies, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"). You may not
- * use this file except in compliance with the License. A copy of the License is
- * located at
- *
- * http://aws.amazon.com/apache2.0
- *
- * or in the "license" file accompanying this file. This file is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
package io.temporal.samples.peractivityoptions;
import io.temporal.activity.Activity;
diff --git a/core/src/main/java/io/temporal/samples/peractivityoptions/PerActivityOptionsWorkflow.java b/core/src/main/java/io/temporal/samples/peractivityoptions/PerActivityOptionsWorkflow.java
index 6c54ba0ce..b2bb7fd79 100644
--- a/core/src/main/java/io/temporal/samples/peractivityoptions/PerActivityOptionsWorkflow.java
+++ b/core/src/main/java/io/temporal/samples/peractivityoptions/PerActivityOptionsWorkflow.java
@@ -1,22 +1,3 @@
-/*
- * Copyright (c) 2020 Temporal Technologies, Inc. All Rights Reserved
- *
- * Copyright 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
- * Modifications copyright (C) 2017 Uber Technologies, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"). You may not
- * use this file except in compliance with the License. A copy of the License is
- * located at
- *
- * http://aws.amazon.com/apache2.0
- *
- * or in the "license" file accompanying this file. This file is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
package io.temporal.samples.peractivityoptions;
import io.temporal.workflow.WorkflowInterface;
diff --git a/core/src/main/java/io/temporal/samples/peractivityoptions/PerActivityOptionsWorkflowImpl.java b/core/src/main/java/io/temporal/samples/peractivityoptions/PerActivityOptionsWorkflowImpl.java
index 48f0e6bdf..1fa28beb1 100644
--- a/core/src/main/java/io/temporal/samples/peractivityoptions/PerActivityOptionsWorkflowImpl.java
+++ b/core/src/main/java/io/temporal/samples/peractivityoptions/PerActivityOptionsWorkflowImpl.java
@@ -1,22 +1,3 @@
-/*
- * Copyright (c) 2020 Temporal Technologies, Inc. All Rights Reserved
- *
- * Copyright 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
- * Modifications copyright (C) 2017 Uber Technologies, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"). You may not
- * use this file except in compliance with the License. A copy of the License is
- * located at
- *
- * http://aws.amazon.com/apache2.0
- *
- * or in the "license" file accompanying this file. This file is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
package io.temporal.samples.peractivityoptions;
import io.temporal.failure.ActivityFailure;
diff --git a/core/src/main/java/io/temporal/samples/peractivityoptions/Starter.java b/core/src/main/java/io/temporal/samples/peractivityoptions/Starter.java
index c99bc0206..58062c176 100644
--- a/core/src/main/java/io/temporal/samples/peractivityoptions/Starter.java
+++ b/core/src/main/java/io/temporal/samples/peractivityoptions/Starter.java
@@ -1,22 +1,3 @@
-/*
- * Copyright (c) 2020 Temporal Technologies, Inc. All Rights Reserved
- *
- * Copyright 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
- * Modifications copyright (C) 2017 Uber Technologies, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"). You may not
- * use this file except in compliance with the License. A copy of the License is
- * located at
- *
- * http://aws.amazon.com/apache2.0
- *
- * or in the "license" file accompanying this file. This file is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
package io.temporal.samples.peractivityoptions;
import com.google.common.collect.ImmutableMap;
@@ -24,20 +5,32 @@
import io.temporal.client.WorkflowClient;
import io.temporal.client.WorkflowOptions;
import io.temporal.common.RetryOptions;
+import io.temporal.envconfig.ClientConfigProfile;
import io.temporal.serviceclient.WorkflowServiceStubs;
import io.temporal.worker.Worker;
import io.temporal.worker.WorkerFactory;
import io.temporal.worker.WorkflowImplementationOptions;
+import java.io.IOException;
import java.time.Duration;
public class Starter {
public static final String TASK_QUEUE = "perActivityTaskQueue";
- private static final WorkflowServiceStubs service = WorkflowServiceStubs.newLocalServiceStubs();
- private static final WorkflowClient client = WorkflowClient.newInstance(service);
- private static final WorkerFactory factory = WorkerFactory.newInstance(client);
public static void main(String[] args) {
+ // Load configuration from environment and files
+ ClientConfigProfile profile;
+ try {
+ profile = ClientConfigProfile.load();
+ } catch (IOException e) {
+ throw new RuntimeException("Failed to load client configuration", e);
+ }
+
+ WorkflowServiceStubs service =
+ WorkflowServiceStubs.newServiceStubs(profile.toWorkflowServiceStubsOptions());
+ WorkflowClient client = WorkflowClient.newInstance(service, profile.toWorkflowClientOptions());
+ WorkerFactory factory = WorkerFactory.newInstance(client);
+
// Create Worker
Worker worker = factory.newWorker(TASK_QUEUE);
// Register workflow impl and set the per-activity options
diff --git a/core/src/main/java/io/temporal/samples/polling/PollingActivities.java b/core/src/main/java/io/temporal/samples/polling/PollingActivities.java
index e105e220e..a0fc767e6 100644
--- a/core/src/main/java/io/temporal/samples/polling/PollingActivities.java
+++ b/core/src/main/java/io/temporal/samples/polling/PollingActivities.java
@@ -1,22 +1,3 @@
-/*
- * Copyright (c) 2020 Temporal Technologies, Inc. All Rights Reserved
- *
- * Copyright 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
- * Modifications copyright (C) 2017 Uber Technologies, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"). You may not
- * use this file except in compliance with the License. A copy of the License is
- * located at
- *
- * http://aws.amazon.com/apache2.0
- *
- * or in the "license" file accompanying this file. This file is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
package io.temporal.samples.polling;
import io.temporal.activity.ActivityInterface;
diff --git a/core/src/main/java/io/temporal/samples/polling/PollingWorkflow.java b/core/src/main/java/io/temporal/samples/polling/PollingWorkflow.java
index c68adf955..10ed346a6 100644
--- a/core/src/main/java/io/temporal/samples/polling/PollingWorkflow.java
+++ b/core/src/main/java/io/temporal/samples/polling/PollingWorkflow.java
@@ -1,22 +1,3 @@
-/*
- * Copyright (c) 2020 Temporal Technologies, Inc. All Rights Reserved
- *
- * Copyright 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
- * Modifications copyright (C) 2017 Uber Technologies, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"). You may not
- * use this file except in compliance with the License. A copy of the License is
- * located at
- *
- * http://aws.amazon.com/apache2.0
- *
- * or in the "license" file accompanying this file. This file is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
package io.temporal.samples.polling;
import io.temporal.workflow.WorkflowInterface;
diff --git a/core/src/main/java/io/temporal/samples/polling/TestService.java b/core/src/main/java/io/temporal/samples/polling/TestService.java
index 829bfc9d4..ec48baed5 100644
--- a/core/src/main/java/io/temporal/samples/polling/TestService.java
+++ b/core/src/main/java/io/temporal/samples/polling/TestService.java
@@ -1,22 +1,3 @@
-/*
- * Copyright (c) 2020 Temporal Technologies, Inc. All Rights Reserved
- *
- * Copyright 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
- * Modifications copyright (C) 2017 Uber Technologies, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"). You may not
- * use this file except in compliance with the License. A copy of the License is
- * located at
- *
- * http://aws.amazon.com/apache2.0
- *
- * or in the "license" file accompanying this file. This file is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
package io.temporal.samples.polling;
import java.util.concurrent.ThreadLocalRandom;
diff --git a/core/src/main/java/io/temporal/samples/polling/frequent/FrequentPollingActivityImpl.java b/core/src/main/java/io/temporal/samples/polling/frequent/FrequentPollingActivityImpl.java
index fe3c85e5b..f5b3fbb2b 100644
--- a/core/src/main/java/io/temporal/samples/polling/frequent/FrequentPollingActivityImpl.java
+++ b/core/src/main/java/io/temporal/samples/polling/frequent/FrequentPollingActivityImpl.java
@@ -1,22 +1,3 @@
-/*
- * Copyright (c) 2020 Temporal Technologies, Inc. All Rights Reserved
- *
- * Copyright 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
- * Modifications copyright (C) 2017 Uber Technologies, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"). You may not
- * use this file except in compliance with the License. A copy of the License is
- * located at
- *
- * http://aws.amazon.com/apache2.0
- *
- * or in the "license" file accompanying this file. This file is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
package io.temporal.samples.polling.frequent;
import io.temporal.activity.Activity;
diff --git a/core/src/main/java/io/temporal/samples/polling/frequent/FrequentPollingStarter.java b/core/src/main/java/io/temporal/samples/polling/frequent/FrequentPollingStarter.java
index a795348c4..ed8fa477f 100644
--- a/core/src/main/java/io/temporal/samples/polling/frequent/FrequentPollingStarter.java
+++ b/core/src/main/java/io/temporal/samples/polling/frequent/FrequentPollingStarter.java
@@ -1,35 +1,32 @@
-/*
- * Copyright (c) 2020 Temporal Technologies, Inc. All Rights Reserved
- *
- * Copyright 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
- * Modifications copyright (C) 2017 Uber Technologies, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"). You may not
- * use this file except in compliance with the License. A copy of the License is
- * located at
- *
- * http://aws.amazon.com/apache2.0
- *
- * or in the "license" file accompanying this file. This file is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
package io.temporal.samples.polling.frequent;
import io.temporal.client.WorkflowClient;
import io.temporal.client.WorkflowOptions;
+import io.temporal.envconfig.ClientConfigProfile;
import io.temporal.samples.polling.PollingWorkflow;
import io.temporal.samples.polling.TestService;
import io.temporal.serviceclient.WorkflowServiceStubs;
import io.temporal.worker.Worker;
import io.temporal.worker.WorkerFactory;
+import java.io.IOException;
public class FrequentPollingStarter {
- private static final WorkflowServiceStubs service = WorkflowServiceStubs.newLocalServiceStubs();
- private static final WorkflowClient client = WorkflowClient.newInstance(service);
+ private static WorkflowServiceStubs service;
+ private static WorkflowClient client;
+
+ static {
+ // Load configuration from environment and files
+ ClientConfigProfile profile;
+ try {
+ profile = ClientConfigProfile.load();
+ } catch (IOException e) {
+ throw new RuntimeException("Failed to load client configuration", e);
+ }
+
+ service = WorkflowServiceStubs.newServiceStubs(profile.toWorkflowServiceStubsOptions());
+ client = WorkflowClient.newInstance(service, profile.toWorkflowClientOptions());
+ }
+
private static final String taskQueue = "pollingSampleQueue";
private static final String workflowId = "FrequentPollingSampleWorkflow";
diff --git a/core/src/main/java/io/temporal/samples/polling/frequent/FrequentPollingWorkflowImpl.java b/core/src/main/java/io/temporal/samples/polling/frequent/FrequentPollingWorkflowImpl.java
index b50f538c3..1bab28261 100644
--- a/core/src/main/java/io/temporal/samples/polling/frequent/FrequentPollingWorkflowImpl.java
+++ b/core/src/main/java/io/temporal/samples/polling/frequent/FrequentPollingWorkflowImpl.java
@@ -1,22 +1,3 @@
-/*
- * Copyright (c) 2020 Temporal Technologies, Inc. All Rights Reserved
- *
- * Copyright 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
- * Modifications copyright (C) 2017 Uber Technologies, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"). You may not
- * use this file except in compliance with the License. A copy of the License is
- * located at
- *
- * http://aws.amazon.com/apache2.0
- *
- * or in the "license" file accompanying this file. This file is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
package io.temporal.samples.polling.frequent;
import io.temporal.activity.ActivityOptions;
diff --git a/core/src/main/java/io/temporal/samples/polling/infrequent/InfrequentPollingActivityImpl.java b/core/src/main/java/io/temporal/samples/polling/infrequent/InfrequentPollingActivityImpl.java
index 687573b9d..1bca960a9 100644
--- a/core/src/main/java/io/temporal/samples/polling/infrequent/InfrequentPollingActivityImpl.java
+++ b/core/src/main/java/io/temporal/samples/polling/infrequent/InfrequentPollingActivityImpl.java
@@ -1,30 +1,12 @@
-/*
- * Copyright (c) 2020 Temporal Technologies, Inc. All Rights Reserved
- *
- * Copyright 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
- * Modifications copyright (C) 2017 Uber Technologies, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"). You may not
- * use this file except in compliance with the License. A copy of the License is
- * located at
- *
- * http://aws.amazon.com/apache2.0
- *
- * or in the "license" file accompanying this file. This file is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
package io.temporal.samples.polling.infrequent;
-import io.temporal.activity.Activity;
+import io.temporal.failure.ApplicationErrorCategory;
+import io.temporal.failure.ApplicationFailure;
import io.temporal.samples.polling.PollingActivities;
import io.temporal.samples.polling.TestService;
public class InfrequentPollingActivityImpl implements PollingActivities {
- private TestService service;
+ private final TestService service;
public InfrequentPollingActivityImpl(TestService service) {
this.service = service;
@@ -36,7 +18,13 @@ public String doPoll() {
return service.getServiceResult();
} catch (TestService.TestServiceException e) {
// We want to rethrow the service exception so we can poll via activity retries
- throw Activity.wrap(e);
+ throw ApplicationFailure.newBuilder()
+ .setMessage(e.getMessage())
+ .setType(e.getClass().getName())
+ .setCause(e)
+ // This failure is expected so we set it as benign to avoid excessive logging
+ .setCategory(ApplicationErrorCategory.BENIGN)
+ .build();
}
}
}
diff --git a/core/src/main/java/io/temporal/samples/polling/infrequent/InfrequentPollingStarter.java b/core/src/main/java/io/temporal/samples/polling/infrequent/InfrequentPollingStarter.java
index 096ea2c4c..f778ce287 100644
--- a/core/src/main/java/io/temporal/samples/polling/infrequent/InfrequentPollingStarter.java
+++ b/core/src/main/java/io/temporal/samples/polling/infrequent/InfrequentPollingStarter.java
@@ -1,35 +1,32 @@
-/*
- * Copyright (c) 2020 Temporal Technologies, Inc. All Rights Reserved
- *
- * Copyright 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
- * Modifications copyright (C) 2017 Uber Technologies, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"). You may not
- * use this file except in compliance with the License. A copy of the License is
- * located at
- *
- * http://aws.amazon.com/apache2.0
- *
- * or in the "license" file accompanying this file. This file is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
package io.temporal.samples.polling.infrequent;
import io.temporal.client.WorkflowClient;
import io.temporal.client.WorkflowOptions;
+import io.temporal.envconfig.ClientConfigProfile;
import io.temporal.samples.polling.PollingWorkflow;
import io.temporal.samples.polling.TestService;
import io.temporal.serviceclient.WorkflowServiceStubs;
import io.temporal.worker.Worker;
import io.temporal.worker.WorkerFactory;
+import java.io.IOException;
public class InfrequentPollingStarter {
- private static final WorkflowServiceStubs service = WorkflowServiceStubs.newLocalServiceStubs();
- private static final WorkflowClient client = WorkflowClient.newInstance(service);
+ private static WorkflowServiceStubs service;
+ private static WorkflowClient client;
+
+ static {
+ // Load configuration from environment and files
+ ClientConfigProfile profile;
+ try {
+ profile = ClientConfigProfile.load();
+ } catch (IOException e) {
+ throw new RuntimeException("Failed to load client configuration", e);
+ }
+
+ service = WorkflowServiceStubs.newServiceStubs(profile.toWorkflowServiceStubsOptions());
+ client = WorkflowClient.newInstance(service, profile.toWorkflowClientOptions());
+ }
+
private static final String taskQueue = "pollingSampleQueue";
private static final String workflowId = "InfrequentPollingSampleWorkflow";
diff --git a/core/src/main/java/io/temporal/samples/polling/infrequent/InfrequentPollingWorkflowImpl.java b/core/src/main/java/io/temporal/samples/polling/infrequent/InfrequentPollingWorkflowImpl.java
index 7d1854558..8831fd4ff 100644
--- a/core/src/main/java/io/temporal/samples/polling/infrequent/InfrequentPollingWorkflowImpl.java
+++ b/core/src/main/java/io/temporal/samples/polling/infrequent/InfrequentPollingWorkflowImpl.java
@@ -1,22 +1,3 @@
-/*
- * Copyright (c) 2020 Temporal Technologies, Inc. All Rights Reserved
- *
- * Copyright 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
- * Modifications copyright (C) 2017 Uber Technologies, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"). You may not
- * use this file except in compliance with the License. A copy of the License is
- * located at
- *
- * http://aws.amazon.com/apache2.0
- *
- * or in the "license" file accompanying this file. This file is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
package io.temporal.samples.polling.infrequent;
import io.temporal.activity.ActivityOptions;
diff --git a/core/src/main/java/io/temporal/samples/polling/infrequentwithretryafter/InfrequentPollingWithRetryAfterActivityImpl.java b/core/src/main/java/io/temporal/samples/polling/infrequentwithretryafter/InfrequentPollingWithRetryAfterActivityImpl.java
index 41cbba1f2..2de6a7731 100644
--- a/core/src/main/java/io/temporal/samples/polling/infrequentwithretryafter/InfrequentPollingWithRetryAfterActivityImpl.java
+++ b/core/src/main/java/io/temporal/samples/polling/infrequentwithretryafter/InfrequentPollingWithRetryAfterActivityImpl.java
@@ -1,25 +1,7 @@
-/*
- * Copyright (c) 2020 Temporal Technologies, Inc. All Rights Reserved
- *
- * Copyright 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
- * Modifications copyright (C) 2017 Uber Technologies, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"). You may not
- * use this file except in compliance with the License. A copy of the License is
- * located at
- *
- * http://aws.amazon.com/apache2.0
- *
- * or in the "license" file accompanying this file. This file is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
package io.temporal.samples.polling.infrequentwithretryafter;
import io.temporal.activity.Activity;
+import io.temporal.failure.ApplicationErrorCategory;
import io.temporal.failure.ApplicationFailure;
import io.temporal.samples.polling.PollingActivities;
import io.temporal.samples.polling.TestService;
@@ -29,7 +11,7 @@
import java.time.format.DateTimeFormatter;
public class InfrequentPollingWithRetryAfterActivityImpl implements PollingActivities {
- private TestService service;
+ private final TestService service;
final DateTimeFormatter ISO_FORMATTER = DateTimeFormatter.ISO_DATE_TIME;
public InfrequentPollingWithRetryAfterActivityImpl(TestService service) {
@@ -51,13 +33,16 @@ public String doPoll() {
// which is the test service exception
// and delay which is the interval to next retry based on test service retry-after directive
System.out.println("Activity next retry in: " + e.getRetryAfterInMinutes() + " minutes");
- throw ApplicationFailure.newFailureWithCauseAndDelay(
- e.getMessage(),
- e.getClass().getName(),
- e,
- // here we set the next retry interval based on Retry-After duration given to us by our
+ throw ApplicationFailure.newBuilder()
+ .setMessage(e.getMessage())
+ .setType(e.getClass().getName())
+ .setCause(e)
+ // Here we set the next retry interval based on Retry-After duration given to us by our
// service
- Duration.ofMinutes(e.getRetryAfterInMinutes()));
+ .setNextRetryDelay(Duration.ofMinutes(e.getRetryAfterInMinutes()))
+ // This failure is expected so we set it as benign to avoid excessive logging
+ .setCategory(ApplicationErrorCategory.BENIGN)
+ .build();
}
}
}
diff --git a/core/src/main/java/io/temporal/samples/polling/infrequentwithretryafter/InfrequentPollingWithRetryAfterStarter.java b/core/src/main/java/io/temporal/samples/polling/infrequentwithretryafter/InfrequentPollingWithRetryAfterStarter.java
index ff8d0dd73..93e3c9e6b 100644
--- a/core/src/main/java/io/temporal/samples/polling/infrequentwithretryafter/InfrequentPollingWithRetryAfterStarter.java
+++ b/core/src/main/java/io/temporal/samples/polling/infrequentwithretryafter/InfrequentPollingWithRetryAfterStarter.java
@@ -1,35 +1,32 @@
-/*
- * Copyright (c) 2020 Temporal Technologies, Inc. All Rights Reserved
- *
- * Copyright 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
- * Modifications copyright (C) 2017 Uber Technologies, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"). You may not
- * use this file except in compliance with the License. A copy of the License is
- * located at
- *
- * http://aws.amazon.com/apache2.0
- *
- * or in the "license" file accompanying this file. This file is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
package io.temporal.samples.polling.infrequentwithretryafter;
import io.temporal.client.WorkflowClient;
import io.temporal.client.WorkflowOptions;
+import io.temporal.envconfig.ClientConfigProfile;
import io.temporal.samples.polling.PollingWorkflow;
import io.temporal.samples.polling.TestService;
import io.temporal.serviceclient.WorkflowServiceStubs;
import io.temporal.worker.Worker;
import io.temporal.worker.WorkerFactory;
+import java.io.IOException;
public class InfrequentPollingWithRetryAfterStarter {
- private static final WorkflowServiceStubs service = WorkflowServiceStubs.newLocalServiceStubs();
- private static final WorkflowClient client = WorkflowClient.newInstance(service);
+ private static WorkflowServiceStubs service;
+ private static WorkflowClient client;
+
+ static {
+ // Load configuration from environment and files
+ ClientConfigProfile profile;
+ try {
+ profile = ClientConfigProfile.load();
+ } catch (IOException e) {
+ throw new RuntimeException("Failed to load client configuration", e);
+ }
+
+ service = WorkflowServiceStubs.newServiceStubs(profile.toWorkflowServiceStubsOptions());
+ client = WorkflowClient.newInstance(service, profile.toWorkflowClientOptions());
+ }
+
private static final String taskQueue = "pollingSampleQueue";
private static final String workflowId = "InfrequentPollingWithRetryAfterWorkflow";
diff --git a/core/src/main/java/io/temporal/samples/polling/infrequentwithretryafter/InfrequentPollingWithRetryAfterWorkflowImpl.java b/core/src/main/java/io/temporal/samples/polling/infrequentwithretryafter/InfrequentPollingWithRetryAfterWorkflowImpl.java
index 96ff76968..34042c10c 100644
--- a/core/src/main/java/io/temporal/samples/polling/infrequentwithretryafter/InfrequentPollingWithRetryAfterWorkflowImpl.java
+++ b/core/src/main/java/io/temporal/samples/polling/infrequentwithretryafter/InfrequentPollingWithRetryAfterWorkflowImpl.java
@@ -1,22 +1,3 @@
-/*
- * Copyright (c) 2020 Temporal Technologies, Inc. All Rights Reserved
- *
- * Copyright 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
- * Modifications copyright (C) 2017 Uber Technologies, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"). You may not
- * use this file except in compliance with the License. A copy of the License is
- * located at
- *
- * http://aws.amazon.com/apache2.0
- *
- * or in the "license" file accompanying this file. This file is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
package io.temporal.samples.polling.infrequentwithretryafter;
import io.temporal.activity.ActivityOptions;
diff --git a/core/src/main/java/io/temporal/samples/polling/periodicsequence/PeriodicPollingActivityImpl.java b/core/src/main/java/io/temporal/samples/polling/periodicsequence/PeriodicPollingActivityImpl.java
index c8a999a4c..272bc4cef 100644
--- a/core/src/main/java/io/temporal/samples/polling/periodicsequence/PeriodicPollingActivityImpl.java
+++ b/core/src/main/java/io/temporal/samples/polling/periodicsequence/PeriodicPollingActivityImpl.java
@@ -1,22 +1,3 @@
-/*
- * Copyright (c) 2020 Temporal Technologies, Inc. All Rights Reserved
- *
- * Copyright 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
- * Modifications copyright (C) 2017 Uber Technologies, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"). You may not
- * use this file except in compliance with the License. A copy of the License is
- * located at
- *
- * http://aws.amazon.com/apache2.0
- *
- * or in the "license" file accompanying this file. This file is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
package io.temporal.samples.polling.periodicsequence;
import io.temporal.activity.Activity;
diff --git a/core/src/main/java/io/temporal/samples/polling/periodicsequence/PeriodicPollingChildWorkflowImpl.java b/core/src/main/java/io/temporal/samples/polling/periodicsequence/PeriodicPollingChildWorkflowImpl.java
index a877946ee..e36f18ae6 100644
--- a/core/src/main/java/io/temporal/samples/polling/periodicsequence/PeriodicPollingChildWorkflowImpl.java
+++ b/core/src/main/java/io/temporal/samples/polling/periodicsequence/PeriodicPollingChildWorkflowImpl.java
@@ -1,22 +1,3 @@
-/*
- * Copyright (c) 2020 Temporal Technologies, Inc. All Rights Reserved
- *
- * Copyright 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
- * Modifications copyright (C) 2017 Uber Technologies, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"). You may not
- * use this file except in compliance with the License. A copy of the License is
- * located at
- *
- * http://aws.amazon.com/apache2.0
- *
- * or in the "license" file accompanying this file. This file is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
package io.temporal.samples.polling.periodicsequence;
import io.temporal.activity.ActivityOptions;
diff --git a/core/src/main/java/io/temporal/samples/polling/periodicsequence/PeriodicPollingStarter.java b/core/src/main/java/io/temporal/samples/polling/periodicsequence/PeriodicPollingStarter.java
index ef251260f..34c3e8a5a 100644
--- a/core/src/main/java/io/temporal/samples/polling/periodicsequence/PeriodicPollingStarter.java
+++ b/core/src/main/java/io/temporal/samples/polling/periodicsequence/PeriodicPollingStarter.java
@@ -1,35 +1,32 @@
-/*
- * Copyright (c) 2020 Temporal Technologies, Inc. All Rights Reserved
- *
- * Copyright 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
- * Modifications copyright (C) 2017 Uber Technologies, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"). You may not
- * use this file except in compliance with the License. A copy of the License is
- * located at
- *
- * http://aws.amazon.com/apache2.0
- *
- * or in the "license" file accompanying this file. This file is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
package io.temporal.samples.polling.periodicsequence;
import io.temporal.client.WorkflowClient;
import io.temporal.client.WorkflowOptions;
+import io.temporal.envconfig.ClientConfigProfile;
import io.temporal.samples.polling.PollingWorkflow;
import io.temporal.samples.polling.TestService;
import io.temporal.serviceclient.WorkflowServiceStubs;
import io.temporal.worker.Worker;
import io.temporal.worker.WorkerFactory;
+import java.io.IOException;
public class PeriodicPollingStarter {
- private static final WorkflowServiceStubs service = WorkflowServiceStubs.newLocalServiceStubs();
- private static final WorkflowClient client = WorkflowClient.newInstance(service);
+ private static WorkflowServiceStubs service;
+ private static WorkflowClient client;
+
+ static {
+ // Load configuration from environment and files
+ ClientConfigProfile profile;
+ try {
+ profile = ClientConfigProfile.load();
+ } catch (IOException e) {
+ throw new RuntimeException("Failed to load client configuration", e);
+ }
+
+ service = WorkflowServiceStubs.newServiceStubs(profile.toWorkflowServiceStubsOptions());
+ client = WorkflowClient.newInstance(service, profile.toWorkflowClientOptions());
+ }
+
private static final String taskQueue = "pollingSampleQueue";
private static final String workflowId = "PeriodicPollingSampleWorkflow";
diff --git a/core/src/main/java/io/temporal/samples/polling/periodicsequence/PeriodicPollingWorkflowImpl.java b/core/src/main/java/io/temporal/samples/polling/periodicsequence/PeriodicPollingWorkflowImpl.java
index cb7549b1f..7be46d245 100644
--- a/core/src/main/java/io/temporal/samples/polling/periodicsequence/PeriodicPollingWorkflowImpl.java
+++ b/core/src/main/java/io/temporal/samples/polling/periodicsequence/PeriodicPollingWorkflowImpl.java
@@ -1,22 +1,3 @@
-/*
- * Copyright (c) 2020 Temporal Technologies, Inc. All Rights Reserved
- *
- * Copyright 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
- * Modifications copyright (C) 2017 Uber Technologies, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"). You may not
- * use this file except in compliance with the License. A copy of the License is
- * located at
- *
- * http://aws.amazon.com/apache2.0
- *
- * or in the "license" file accompanying this file. This file is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
package io.temporal.samples.polling.periodicsequence;
import io.temporal.samples.polling.PollingWorkflow;
diff --git a/core/src/main/java/io/temporal/samples/polling/periodicsequence/PollingChildWorkflow.java b/core/src/main/java/io/temporal/samples/polling/periodicsequence/PollingChildWorkflow.java
index c0291a305..2e6a55b3b 100644
--- a/core/src/main/java/io/temporal/samples/polling/periodicsequence/PollingChildWorkflow.java
+++ b/core/src/main/java/io/temporal/samples/polling/periodicsequence/PollingChildWorkflow.java
@@ -1,22 +1,3 @@
-/*
- * Copyright (c) 2020 Temporal Technologies, Inc. All Rights Reserved
- *
- * Copyright 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
- * Modifications copyright (C) 2017 Uber Technologies, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"). You may not
- * use this file except in compliance with the License. A copy of the License is
- * located at
- *
- * http://aws.amazon.com/apache2.0
- *
- * or in the "license" file accompanying this file. This file is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
package io.temporal.samples.polling.periodicsequence;
import io.temporal.workflow.WorkflowInterface;
diff --git a/core/src/main/java/io/temporal/samples/retryonsignalinterceptor/FailureRequester.java b/core/src/main/java/io/temporal/samples/retryonsignalinterceptor/FailureRequester.java
index 78bc3b7c7..c948ba02e 100644
--- a/core/src/main/java/io/temporal/samples/retryonsignalinterceptor/FailureRequester.java
+++ b/core/src/main/java/io/temporal/samples/retryonsignalinterceptor/FailureRequester.java
@@ -1,28 +1,11 @@
-/*
- * Copyright (c) 2020 Temporal Technologies, Inc. All Rights Reserved
- *
- * Copyright 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
- * Modifications copyright (C) 2017 Uber Technologies, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"). You may not
- * use this file except in compliance with the License. A copy of the License is
- * located at
- *
- * http://aws.amazon.com/apache2.0
- *
- * or in the "license" file accompanying this file. This file is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
package io.temporal.samples.retryonsignalinterceptor;
import static io.temporal.samples.retryonsignalinterceptor.MyWorkflowWorker.WORKFLOW_ID;
import io.temporal.client.WorkflowClient;
+import io.temporal.envconfig.ClientConfigProfile;
import io.temporal.serviceclient.WorkflowServiceStubs;
+import java.io.IOException;
/**
* Send signal requesting that an exception thrown from the activity is propagated to the workflow.
@@ -30,8 +13,17 @@
public class FailureRequester {
public static void main(String[] args) {
- WorkflowServiceStubs service = WorkflowServiceStubs.newLocalServiceStubs();
- WorkflowClient client = WorkflowClient.newInstance(service);
+ // Load configuration from environment and files
+ ClientConfigProfile profile;
+ try {
+ profile = ClientConfigProfile.load();
+ } catch (IOException e) {
+ throw new RuntimeException("Failed to load client configuration", e);
+ }
+
+ WorkflowServiceStubs service =
+ WorkflowServiceStubs.newServiceStubs(profile.toWorkflowServiceStubsOptions());
+ WorkflowClient client = WorkflowClient.newInstance(service, profile.toWorkflowClientOptions());
// Note that we use the listener interface that the interceptor registered dynamically, not the
// workflow interface.
diff --git a/core/src/main/java/io/temporal/samples/retryonsignalinterceptor/MyActivity.java b/core/src/main/java/io/temporal/samples/retryonsignalinterceptor/MyActivity.java
index 515d93b33..f6a4f8201 100644
--- a/core/src/main/java/io/temporal/samples/retryonsignalinterceptor/MyActivity.java
+++ b/core/src/main/java/io/temporal/samples/retryonsignalinterceptor/MyActivity.java
@@ -1,22 +1,3 @@
-/*
- * Copyright (c) 2020 Temporal Technologies, Inc. All Rights Reserved
- *
- * Copyright 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
- * Modifications copyright (C) 2017 Uber Technologies, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"). You may not
- * use this file except in compliance with the License. A copy of the License is
- * located at
- *
- * http://aws.amazon.com/apache2.0
- *
- * or in the "license" file accompanying this file. This file is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
package io.temporal.samples.retryonsignalinterceptor;
import io.temporal.activity.ActivityInterface;
diff --git a/core/src/main/java/io/temporal/samples/retryonsignalinterceptor/MyActivityImpl.java b/core/src/main/java/io/temporal/samples/retryonsignalinterceptor/MyActivityImpl.java
index 2e120c353..494dcc653 100644
--- a/core/src/main/java/io/temporal/samples/retryonsignalinterceptor/MyActivityImpl.java
+++ b/core/src/main/java/io/temporal/samples/retryonsignalinterceptor/MyActivityImpl.java
@@ -1,22 +1,3 @@
-/*
- * Copyright (c) 2020 Temporal Technologies, Inc. All Rights Reserved
- *
- * Copyright 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
- * Modifications copyright (C) 2017 Uber Technologies, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"). You may not
- * use this file except in compliance with the License. A copy of the License is
- * located at
- *
- * http://aws.amazon.com/apache2.0
- *
- * or in the "license" file accompanying this file. This file is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
package io.temporal.samples.retryonsignalinterceptor;
import io.temporal.failure.ApplicationFailure;
diff --git a/core/src/main/java/io/temporal/samples/retryonsignalinterceptor/MyWorkflow.java b/core/src/main/java/io/temporal/samples/retryonsignalinterceptor/MyWorkflow.java
index b9449b3c0..4dae45a5b 100644
--- a/core/src/main/java/io/temporal/samples/retryonsignalinterceptor/MyWorkflow.java
+++ b/core/src/main/java/io/temporal/samples/retryonsignalinterceptor/MyWorkflow.java
@@ -1,22 +1,3 @@
-/*
- * Copyright (c) 2020 Temporal Technologies, Inc. All Rights Reserved
- *
- * Copyright 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
- * Modifications copyright (C) 2017 Uber Technologies, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"). You may not
- * use this file except in compliance with the License. A copy of the License is
- * located at
- *
- * http://aws.amazon.com/apache2.0
- *
- * or in the "license" file accompanying this file. This file is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
package io.temporal.samples.retryonsignalinterceptor;
import io.temporal.workflow.WorkflowInterface;
diff --git a/core/src/main/java/io/temporal/samples/retryonsignalinterceptor/MyWorkflowImpl.java b/core/src/main/java/io/temporal/samples/retryonsignalinterceptor/MyWorkflowImpl.java
index b12ee8307..3db46cf51 100644
--- a/core/src/main/java/io/temporal/samples/retryonsignalinterceptor/MyWorkflowImpl.java
+++ b/core/src/main/java/io/temporal/samples/retryonsignalinterceptor/MyWorkflowImpl.java
@@ -1,22 +1,3 @@
-/*
- * Copyright (c) 2020 Temporal Technologies, Inc. All Rights Reserved
- *
- * Copyright 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
- * Modifications copyright (C) 2017 Uber Technologies, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"). You may not
- * use this file except in compliance with the License. A copy of the License is
- * located at
- *
- * http://aws.amazon.com/apache2.0
- *
- * or in the "license" file accompanying this file. This file is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
package io.temporal.samples.retryonsignalinterceptor;
import io.temporal.activity.ActivityOptions;
diff --git a/core/src/main/java/io/temporal/samples/retryonsignalinterceptor/MyWorkflowWorker.java b/core/src/main/java/io/temporal/samples/retryonsignalinterceptor/MyWorkflowWorker.java
index f191ba1ad..55b9ebe17 100644
--- a/core/src/main/java/io/temporal/samples/retryonsignalinterceptor/MyWorkflowWorker.java
+++ b/core/src/main/java/io/temporal/samples/retryonsignalinterceptor/MyWorkflowWorker.java
@@ -1,30 +1,13 @@
-/*
- * Copyright (c) 2020 Temporal Technologies, Inc. All Rights Reserved
- *
- * Copyright 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
- * Modifications copyright (C) 2017 Uber Technologies, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"). You may not
- * use this file except in compliance with the License. A copy of the License is
- * located at
- *
- * http://aws.amazon.com/apache2.0
- *
- * or in the "license" file accompanying this file. This file is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
package io.temporal.samples.retryonsignalinterceptor;
import io.temporal.client.WorkflowClient;
import io.temporal.client.WorkflowOptions;
+import io.temporal.envconfig.ClientConfigProfile;
import io.temporal.serviceclient.WorkflowServiceStubs;
import io.temporal.worker.Worker;
import io.temporal.worker.WorkerFactory;
import io.temporal.worker.WorkerFactoryOptions;
+import java.io.IOException;
public class MyWorkflowWorker {
@@ -33,8 +16,17 @@ public class MyWorkflowWorker {
public static void main(String[] args) {
- WorkflowServiceStubs service = WorkflowServiceStubs.newLocalServiceStubs();
- WorkflowClient client = WorkflowClient.newInstance(service);
+ // Load configuration from environment and files
+ ClientConfigProfile profile;
+ try {
+ profile = ClientConfigProfile.load();
+ } catch (IOException e) {
+ throw new RuntimeException("Failed to load client configuration", e);
+ }
+
+ WorkflowServiceStubs service =
+ WorkflowServiceStubs.newServiceStubs(profile.toWorkflowServiceStubsOptions());
+ WorkflowClient client = WorkflowClient.newInstance(service, profile.toWorkflowClientOptions());
// Register interceptor with the factory.
WorkerFactoryOptions factoryOptions =
WorkerFactoryOptions.newBuilder()
diff --git a/core/src/main/java/io/temporal/samples/retryonsignalinterceptor/QueryRequester.java b/core/src/main/java/io/temporal/samples/retryonsignalinterceptor/QueryRequester.java
index 06adda488..08a7afcbb 100644
--- a/core/src/main/java/io/temporal/samples/retryonsignalinterceptor/QueryRequester.java
+++ b/core/src/main/java/io/temporal/samples/retryonsignalinterceptor/QueryRequester.java
@@ -1,34 +1,26 @@
-/*
- * Copyright (c) 2020 Temporal Technologies, Inc. All Rights Reserved
- *
- * Copyright 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
- * Modifications copyright (C) 2017 Uber Technologies, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"). You may not
- * use this file except in compliance with the License. A copy of the License is
- * located at
- *
- * http://aws.amazon.com/apache2.0
- *
- * or in the "license" file accompanying this file. This file is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
package io.temporal.samples.retryonsignalinterceptor;
import static io.temporal.samples.retryonsignalinterceptor.MyWorkflowWorker.WORKFLOW_ID;
import io.temporal.client.WorkflowClient;
+import io.temporal.envconfig.ClientConfigProfile;
import io.temporal.serviceclient.WorkflowServiceStubs;
+import java.io.IOException;
public class QueryRequester {
public static void main(String[] args) {
- WorkflowServiceStubs service = WorkflowServiceStubs.newLocalServiceStubs();
- WorkflowClient client = WorkflowClient.newInstance(service);
+ // Load configuration from environment and files
+ ClientConfigProfile profile;
+ try {
+ profile = ClientConfigProfile.load();
+ } catch (IOException e) {
+ throw new RuntimeException("Failed to load client configuration", e);
+ }
+
+ WorkflowServiceStubs service =
+ WorkflowServiceStubs.newServiceStubs(profile.toWorkflowServiceStubsOptions());
+ WorkflowClient client = WorkflowClient.newInstance(service, profile.toWorkflowClientOptions());
// Note that we use the listener interface that the interceptor registered dynamically, not the
// workflow interface.
diff --git a/core/src/main/java/io/temporal/samples/retryonsignalinterceptor/RetryOnSignalInterceptorListener.java b/core/src/main/java/io/temporal/samples/retryonsignalinterceptor/RetryOnSignalInterceptorListener.java
index 8b56cd0cd..ba55e32bc 100644
--- a/core/src/main/java/io/temporal/samples/retryonsignalinterceptor/RetryOnSignalInterceptorListener.java
+++ b/core/src/main/java/io/temporal/samples/retryonsignalinterceptor/RetryOnSignalInterceptorListener.java
@@ -1,22 +1,3 @@
-/*
- * Copyright (c) 2020 Temporal Technologies, Inc. All Rights Reserved
- *
- * Copyright 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
- * Modifications copyright (C) 2017 Uber Technologies, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"). You may not
- * use this file except in compliance with the License. A copy of the License is
- * located at
- *
- * http://aws.amazon.com/apache2.0
- *
- * or in the "license" file accompanying this file. This file is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
package io.temporal.samples.retryonsignalinterceptor;
import io.temporal.workflow.QueryMethod;
diff --git a/core/src/main/java/io/temporal/samples/retryonsignalinterceptor/RetryOnSignalWorkerInterceptor.java b/core/src/main/java/io/temporal/samples/retryonsignalinterceptor/RetryOnSignalWorkerInterceptor.java
index 180306447..1875d8813 100644
--- a/core/src/main/java/io/temporal/samples/retryonsignalinterceptor/RetryOnSignalWorkerInterceptor.java
+++ b/core/src/main/java/io/temporal/samples/retryonsignalinterceptor/RetryOnSignalWorkerInterceptor.java
@@ -1,22 +1,3 @@
-/*
- * Copyright (c) 2020 Temporal Technologies, Inc. All Rights Reserved
- *
- * Copyright 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
- * Modifications copyright (C) 2017 Uber Technologies, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"). You may not
- * use this file except in compliance with the License. A copy of the License is
- * located at
- *
- * http://aws.amazon.com/apache2.0
- *
- * or in the "license" file accompanying this file. This file is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
package io.temporal.samples.retryonsignalinterceptor;
import io.temporal.common.interceptors.*;
diff --git a/core/src/main/java/io/temporal/samples/retryonsignalinterceptor/RetryOnSignalWorkflowInboundCallsInterceptor.java b/core/src/main/java/io/temporal/samples/retryonsignalinterceptor/RetryOnSignalWorkflowInboundCallsInterceptor.java
index 7b62aee9f..776c7e5d3 100644
--- a/core/src/main/java/io/temporal/samples/retryonsignalinterceptor/RetryOnSignalWorkflowInboundCallsInterceptor.java
+++ b/core/src/main/java/io/temporal/samples/retryonsignalinterceptor/RetryOnSignalWorkflowInboundCallsInterceptor.java
@@ -1,22 +1,3 @@
-/*
- * Copyright (c) 2020 Temporal Technologies, Inc. All Rights Reserved
- *
- * Copyright 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
- * Modifications copyright (C) 2017 Uber Technologies, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"). You may not
- * use this file except in compliance with the License. A copy of the License is
- * located at
- *
- * http://aws.amazon.com/apache2.0
- *
- * or in the "license" file accompanying this file. This file is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
package io.temporal.samples.retryonsignalinterceptor;
import io.temporal.common.interceptors.WorkflowInboundCallsInterceptor;
diff --git a/core/src/main/java/io/temporal/samples/retryonsignalinterceptor/RetryOnSignalWorkflowOutboundCallsInterceptor.java b/core/src/main/java/io/temporal/samples/retryonsignalinterceptor/RetryOnSignalWorkflowOutboundCallsInterceptor.java
index a7ac7e33c..9bc9212c3 100644
--- a/core/src/main/java/io/temporal/samples/retryonsignalinterceptor/RetryOnSignalWorkflowOutboundCallsInterceptor.java
+++ b/core/src/main/java/io/temporal/samples/retryonsignalinterceptor/RetryOnSignalWorkflowOutboundCallsInterceptor.java
@@ -1,22 +1,3 @@
-/*
- * Copyright (c) 2020 Temporal Technologies, Inc. All Rights Reserved
- *
- * Copyright 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
- * Modifications copyright (C) 2017 Uber Technologies, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"). You may not
- * use this file except in compliance with the License. A copy of the License is
- * located at
- *
- * http://aws.amazon.com/apache2.0
- *
- * or in the "license" file accompanying this file. This file is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
package io.temporal.samples.retryonsignalinterceptor;
import com.google.common.base.Throwables;
diff --git a/core/src/main/java/io/temporal/samples/retryonsignalinterceptor/RetryRequester.java b/core/src/main/java/io/temporal/samples/retryonsignalinterceptor/RetryRequester.java
index f5113d3a4..a5469d80f 100644
--- a/core/src/main/java/io/temporal/samples/retryonsignalinterceptor/RetryRequester.java
+++ b/core/src/main/java/io/temporal/samples/retryonsignalinterceptor/RetryRequester.java
@@ -1,34 +1,26 @@
-/*
- * Copyright (c) 2020 Temporal Technologies, Inc. All Rights Reserved
- *
- * Copyright 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
- * Modifications copyright (C) 2017 Uber Technologies, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"). You may not
- * use this file except in compliance with the License. A copy of the License is
- * located at
- *
- * http://aws.amazon.com/apache2.0
- *
- * or in the "license" file accompanying this file. This file is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
package io.temporal.samples.retryonsignalinterceptor;
import static io.temporal.samples.retryonsignalinterceptor.MyWorkflowWorker.WORKFLOW_ID;
import io.temporal.client.WorkflowClient;
+import io.temporal.envconfig.ClientConfigProfile;
import io.temporal.serviceclient.WorkflowServiceStubs;
+import java.io.IOException;
public class RetryRequester {
public static void main(String[] args) {
- WorkflowServiceStubs service = WorkflowServiceStubs.newLocalServiceStubs();
- WorkflowClient client = WorkflowClient.newInstance(service);
+ // Load configuration from environment and files
+ ClientConfigProfile profile;
+ try {
+ profile = ClientConfigProfile.load();
+ } catch (IOException e) {
+ throw new RuntimeException("Failed to load client configuration", e);
+ }
+
+ WorkflowServiceStubs service =
+ WorkflowServiceStubs.newServiceStubs(profile.toWorkflowServiceStubsOptions());
+ WorkflowClient client = WorkflowClient.newInstance(service, profile.toWorkflowClientOptions());
// Note that we use the listener interface that the interceptor registered dynamically, not the
// workflow interface.
diff --git a/core/src/main/java/io/temporal/samples/safemessagepassing/ClusterManagerActivities.java b/core/src/main/java/io/temporal/samples/safemessagepassing/ClusterManagerActivities.java
index 267a9626f..2a76cede2 100644
--- a/core/src/main/java/io/temporal/samples/safemessagepassing/ClusterManagerActivities.java
+++ b/core/src/main/java/io/temporal/samples/safemessagepassing/ClusterManagerActivities.java
@@ -1,22 +1,3 @@
-/*
- * Copyright (c) 2020 Temporal Technologies, Inc. All Rights Reserved
- *
- * Copyright 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
- * Modifications copyright (C) 2017 Uber Technologies, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"). You may not
- * use this file except in compliance with the License. A copy of the License is
- * located at
- *
- * http://aws.amazon.com/apache2.0
- *
- * or in the "license" file accompanying this file. This file is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
package io.temporal.samples.safemessagepassing;
import com.fasterxml.jackson.annotation.JsonCreator;
diff --git a/core/src/main/java/io/temporal/samples/safemessagepassing/ClusterManagerActivitiesImpl.java b/core/src/main/java/io/temporal/samples/safemessagepassing/ClusterManagerActivitiesImpl.java
index 827ea2e1b..c82380577 100644
--- a/core/src/main/java/io/temporal/samples/safemessagepassing/ClusterManagerActivitiesImpl.java
+++ b/core/src/main/java/io/temporal/samples/safemessagepassing/ClusterManagerActivitiesImpl.java
@@ -1,22 +1,3 @@
-/*
- * Copyright (c) 2020 Temporal Technologies, Inc. All Rights Reserved
- *
- * Copyright 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
- * Modifications copyright (C) 2017 Uber Technologies, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"). You may not
- * use this file except in compliance with the License. A copy of the License is
- * located at
- *
- * http://aws.amazon.com/apache2.0
- *
- * or in the "license" file accompanying this file. This file is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
package io.temporal.samples.safemessagepassing;
import java.util.Set;
diff --git a/core/src/main/java/io/temporal/samples/safemessagepassing/ClusterManagerWorkflow.java b/core/src/main/java/io/temporal/samples/safemessagepassing/ClusterManagerWorkflow.java
index afe42b37c..33ddb95be 100644
--- a/core/src/main/java/io/temporal/samples/safemessagepassing/ClusterManagerWorkflow.java
+++ b/core/src/main/java/io/temporal/samples/safemessagepassing/ClusterManagerWorkflow.java
@@ -1,22 +1,3 @@
-/*
- * Copyright (c) 2020 Temporal Technologies, Inc. All Rights Reserved
- *
- * Copyright 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
- * Modifications copyright (C) 2017 Uber Technologies, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"). You may not
- * use this file except in compliance with the License. A copy of the License is
- * located at
- *
- * http://aws.amazon.com/apache2.0
- *
- * or in the "license" file accompanying this file. This file is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
package io.temporal.samples.safemessagepassing;
import com.fasterxml.jackson.annotation.JsonCreator;
diff --git a/core/src/main/java/io/temporal/samples/safemessagepassing/ClusterManagerWorkflowImpl.java b/core/src/main/java/io/temporal/samples/safemessagepassing/ClusterManagerWorkflowImpl.java
index d25453eca..e27ad5ac4 100644
--- a/core/src/main/java/io/temporal/samples/safemessagepassing/ClusterManagerWorkflowImpl.java
+++ b/core/src/main/java/io/temporal/samples/safemessagepassing/ClusterManagerWorkflowImpl.java
@@ -1,22 +1,3 @@
-/*
- * Copyright (c) 2020 Temporal Technologies, Inc. All Rights Reserved
- *
- * Copyright 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
- * Modifications copyright (C) 2017 Uber Technologies, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"). You may not
- * use this file except in compliance with the License. A copy of the License is
- * located at
- *
- * http://aws.amazon.com/apache2.0
- *
- * or in the "license" file accompanying this file. This file is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
package io.temporal.samples.safemessagepassing;
import io.temporal.activity.ActivityOptions;
diff --git a/core/src/main/java/io/temporal/samples/safemessagepassing/ClusterManagerWorkflowStarter.java b/core/src/main/java/io/temporal/samples/safemessagepassing/ClusterManagerWorkflowStarter.java
index ea3aa4437..71ae380cb 100644
--- a/core/src/main/java/io/temporal/samples/safemessagepassing/ClusterManagerWorkflowStarter.java
+++ b/core/src/main/java/io/temporal/samples/safemessagepassing/ClusterManagerWorkflowStarter.java
@@ -1,22 +1,3 @@
-/*
- * Copyright (c) 2020 Temporal Technologies, Inc. All Rights Reserved
- *
- * Copyright 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
- * Modifications copyright (C) 2017 Uber Technologies, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"). You may not
- * use this file except in compliance with the License. A copy of the License is
- * located at
- *
- * http://aws.amazon.com/apache2.0
- *
- * or in the "license" file accompanying this file. This file is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
package io.temporal.samples.safemessagepassing;
import static io.temporal.samples.safemessagepassing.ClusterManagerWorkflowWorker.CLUSTER_MANAGER_WORKFLOW_ID;
@@ -26,7 +7,9 @@
import io.temporal.client.WorkflowOptions;
import io.temporal.client.WorkflowStub;
import io.temporal.client.WorkflowUpdateStage;
+import io.temporal.envconfig.ClientConfigProfile;
import io.temporal.serviceclient.WorkflowServiceStubs;
+import java.io.IOException;
import java.time.Duration;
import java.util.ArrayList;
import java.util.List;
@@ -48,8 +31,17 @@ public static void main(String[] args) {
+ " ");
System.exit(1);
}
- WorkflowServiceStubs service = WorkflowServiceStubs.newLocalServiceStubs();
- WorkflowClient client = WorkflowClient.newInstance(service);
+ // Load configuration from environment and files
+ ClientConfigProfile profile;
+ try {
+ profile = ClientConfigProfile.load();
+ } catch (IOException e) {
+ throw new RuntimeException("Failed to load client configuration", e);
+ }
+
+ WorkflowServiceStubs service =
+ WorkflowServiceStubs.newServiceStubs(profile.toWorkflowServiceStubsOptions());
+ WorkflowClient client = WorkflowClient.newInstance(service, profile.toWorkflowClientOptions());
boolean shouldTestContinueAsNew = args.length > 0 ? Boolean.parseBoolean(args[0]) : false;
ClusterManagerWorkflow cluster =
client.newWorkflowStub(
diff --git a/core/src/main/java/io/temporal/samples/safemessagepassing/ClusterManagerWorkflowWorker.java b/core/src/main/java/io/temporal/samples/safemessagepassing/ClusterManagerWorkflowWorker.java
index ae98968e4..a4fa8d69f 100644
--- a/core/src/main/java/io/temporal/samples/safemessagepassing/ClusterManagerWorkflowWorker.java
+++ b/core/src/main/java/io/temporal/samples/safemessagepassing/ClusterManagerWorkflowWorker.java
@@ -1,28 +1,11 @@
-/*
- * Copyright (c) 2020 Temporal Technologies, Inc. All Rights Reserved
- *
- * Copyright 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
- * Modifications copyright (C) 2017 Uber Technologies, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"). You may not
- * use this file except in compliance with the License. A copy of the License is
- * located at
- *
- * http://aws.amazon.com/apache2.0
- *
- * or in the "license" file accompanying this file. This file is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
package io.temporal.samples.safemessagepassing;
import io.temporal.client.WorkflowClient;
+import io.temporal.envconfig.ClientConfigProfile;
import io.temporal.serviceclient.WorkflowServiceStubs;
import io.temporal.worker.Worker;
import io.temporal.worker.WorkerFactory;
+import java.io.IOException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -32,8 +15,17 @@ public class ClusterManagerWorkflowWorker {
static final String CLUSTER_MANAGER_WORKFLOW_ID = "ClusterManagerWorkflow";
public static void main(String[] args) {
- WorkflowServiceStubs service = WorkflowServiceStubs.newLocalServiceStubs();
- WorkflowClient client = WorkflowClient.newInstance(service);
+ // Load configuration from environment and files
+ ClientConfigProfile profile;
+ try {
+ profile = ClientConfigProfile.load();
+ } catch (IOException e) {
+ throw new RuntimeException("Failed to load client configuration", e);
+ }
+
+ WorkflowServiceStubs service =
+ WorkflowServiceStubs.newServiceStubs(profile.toWorkflowServiceStubsOptions());
+ WorkflowClient client = WorkflowClient.newInstance(service, profile.toWorkflowClientOptions());
WorkerFactory factory = WorkerFactory.newInstance(client);
final Worker worker = factory.newWorker(TASK_QUEUE);
worker.registerWorkflowImplementationTypes(ClusterManagerWorkflowImpl.class);
diff --git a/core/src/main/java/io/temporal/samples/sleepfordays/SendEmailActivity.java b/core/src/main/java/io/temporal/samples/sleepfordays/SendEmailActivity.java
index 94eba7746..984f2e8ff 100644
--- a/core/src/main/java/io/temporal/samples/sleepfordays/SendEmailActivity.java
+++ b/core/src/main/java/io/temporal/samples/sleepfordays/SendEmailActivity.java
@@ -1,22 +1,3 @@
-/*
- * Copyright (c) 2020 Temporal Technologies, Inc. All Rights Reserved
- *
- * Copyright 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
- * Modifications copyright (C) 2017 Uber Technologies, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"). You may not
- * use this file except in compliance with the License. A copy of the License is
- * located at
- *
- * http://aws.amazon.com/apache2.0
- *
- * or in the "license" file accompanying this file. This file is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
package io.temporal.samples.sleepfordays;
import io.temporal.activity.ActivityInterface;
diff --git a/core/src/main/java/io/temporal/samples/sleepfordays/SendEmailActivityImpl.java b/core/src/main/java/io/temporal/samples/sleepfordays/SendEmailActivityImpl.java
index a8cd72536..52600f991 100644
--- a/core/src/main/java/io/temporal/samples/sleepfordays/SendEmailActivityImpl.java
+++ b/core/src/main/java/io/temporal/samples/sleepfordays/SendEmailActivityImpl.java
@@ -1,22 +1,3 @@
-/*
- * Copyright (c) 2020 Temporal Technologies, Inc. All Rights Reserved
- *
- * Copyright 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
- * Modifications copyright (C) 2017 Uber Technologies, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"). You may not
- * use this file except in compliance with the License. A copy of the License is
- * located at
- *
- * http://aws.amazon.com/apache2.0
- *
- * or in the "license" file accompanying this file. This file is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
package io.temporal.samples.sleepfordays;
public class SendEmailActivityImpl implements SendEmailActivity {
diff --git a/core/src/main/java/io/temporal/samples/sleepfordays/SleepForDaysImpl.java b/core/src/main/java/io/temporal/samples/sleepfordays/SleepForDaysImpl.java
index 2828a3ada..6814e76f3 100644
--- a/core/src/main/java/io/temporal/samples/sleepfordays/SleepForDaysImpl.java
+++ b/core/src/main/java/io/temporal/samples/sleepfordays/SleepForDaysImpl.java
@@ -1,22 +1,3 @@
-/*
- * Copyright (c) 2020 Temporal Technologies, Inc. All Rights Reserved
- *
- * Copyright 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
- * Modifications copyright (C) 2017 Uber Technologies, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"). You may not
- * use this file except in compliance with the License. A copy of the License is
- * located at
- *
- * http://aws.amazon.com/apache2.0
- *
- * or in the "license" file accompanying this file. This file is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
package io.temporal.samples.sleepfordays;
import io.temporal.activity.ActivityOptions;
diff --git a/core/src/main/java/io/temporal/samples/sleepfordays/SleepForDaysWorkflow.java b/core/src/main/java/io/temporal/samples/sleepfordays/SleepForDaysWorkflow.java
index 1bced9729..e7c82669f 100644
--- a/core/src/main/java/io/temporal/samples/sleepfordays/SleepForDaysWorkflow.java
+++ b/core/src/main/java/io/temporal/samples/sleepfordays/SleepForDaysWorkflow.java
@@ -1,22 +1,3 @@
-/*
- * Copyright (c) 2020 Temporal Technologies, Inc. All Rights Reserved
- *
- * Copyright 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
- * Modifications copyright (C) 2017 Uber Technologies, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"). You may not
- * use this file except in compliance with the License. A copy of the License is
- * located at
- *
- * http://aws.amazon.com/apache2.0
- *
- * or in the "license" file accompanying this file. This file is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
package io.temporal.samples.sleepfordays;
import io.temporal.workflow.SignalMethod;
diff --git a/core/src/main/java/io/temporal/samples/sleepfordays/Starter.java b/core/src/main/java/io/temporal/samples/sleepfordays/Starter.java
index a9660de7c..91ed89325 100644
--- a/core/src/main/java/io/temporal/samples/sleepfordays/Starter.java
+++ b/core/src/main/java/io/temporal/samples/sleepfordays/Starter.java
@@ -1,36 +1,32 @@
-/*
- * Copyright (c) 2020 Temporal Technologies, Inc. All Rights Reserved
- *
- * Copyright 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
- * Modifications copyright (C) 2017 Uber Technologies, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"). You may not
- * use this file except in compliance with the License. A copy of the License is
- * located at
- *
- * http://aws.amazon.com/apache2.0
- *
- * or in the "license" file accompanying this file. This file is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
package io.temporal.samples.sleepfordays;
import io.temporal.client.WorkflowClient;
import io.temporal.client.WorkflowOptions;
import io.temporal.client.WorkflowStub;
+import io.temporal.envconfig.ClientConfigProfile;
+import io.temporal.serviceclient.WorkflowServiceStubs;
+import java.io.IOException;
public class Starter {
public static final String TASK_QUEUE = "SleepForDaysTaskQueue";
public static void main(String[] args) {
+ // Load configuration from environment and files
+ ClientConfigProfile profile;
+ try {
+ profile = ClientConfigProfile.load();
+ } catch (IOException e) {
+ throw new RuntimeException("Failed to load client configuration", e);
+ }
+
+ WorkflowServiceStubs service =
+ WorkflowServiceStubs.newServiceStubs(profile.toWorkflowServiceStubsOptions());
+ WorkflowClient client = WorkflowClient.newInstance(service, profile.toWorkflowClientOptions());
+
// Start a workflow execution.
SleepForDaysWorkflow workflow =
- Worker.client.newWorkflowStub(
+ client.newWorkflowStub(
SleepForDaysWorkflow.class,
WorkflowOptions.newBuilder().setTaskQueue(TASK_QUEUE).build());
diff --git a/core/src/main/java/io/temporal/samples/sleepfordays/Worker.java b/core/src/main/java/io/temporal/samples/sleepfordays/Worker.java
index 28ae326cc..b5abac1cb 100644
--- a/core/src/main/java/io/temporal/samples/sleepfordays/Worker.java
+++ b/core/src/main/java/io/temporal/samples/sleepfordays/Worker.java
@@ -1,35 +1,28 @@
-/*
- * Copyright (c) 2020 Temporal Technologies, Inc. All Rights Reserved
- *
- * Copyright 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
- * Modifications copyright (C) 2017 Uber Technologies, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"). You may not
- * use this file except in compliance with the License. A copy of the License is
- * located at
- *
- * http://aws.amazon.com/apache2.0
- *
- * or in the "license" file accompanying this file. This file is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
package io.temporal.samples.sleepfordays;
import io.temporal.client.WorkflowClient;
+import io.temporal.envconfig.ClientConfigProfile;
import io.temporal.serviceclient.WorkflowServiceStubs;
import io.temporal.worker.WorkerFactory;
+import java.io.IOException;
public class Worker {
public static final String TASK_QUEUE = "SleepForDaysTaskQueue";
- public static final WorkflowServiceStubs service = WorkflowServiceStubs.newLocalServiceStubs();
- public static final WorkflowClient client = WorkflowClient.newInstance(service);
- public static final WorkerFactory factory = WorkerFactory.newInstance(client);
public static void main(String[] args) {
+ // Load configuration from environment and files
+ ClientConfigProfile profile;
+ try {
+ profile = ClientConfigProfile.load();
+ } catch (IOException e) {
+ throw new RuntimeException("Failed to load client configuration", e);
+ }
+
+ WorkflowServiceStubs service =
+ WorkflowServiceStubs.newServiceStubs(profile.toWorkflowServiceStubsOptions());
+ WorkflowClient client = WorkflowClient.newInstance(service, profile.toWorkflowClientOptions());
+ WorkerFactory factory = WorkerFactory.newInstance(client);
+
io.temporal.worker.Worker worker = factory.newWorker(TASK_QUEUE);
worker.registerWorkflowImplementationTypes(SleepForDaysImpl.class);
worker.registerActivitiesImplementations(new SendEmailActivityImpl());
diff --git a/core/src/main/java/io/temporal/samples/ssl/MyWorkflow.java b/core/src/main/java/io/temporal/samples/ssl/MyWorkflow.java
index a816ed45a..146ccc056 100644
--- a/core/src/main/java/io/temporal/samples/ssl/MyWorkflow.java
+++ b/core/src/main/java/io/temporal/samples/ssl/MyWorkflow.java
@@ -1,22 +1,3 @@
-/*
- * Copyright (c) 2020 Temporal Technologies, Inc. All Rights Reserved
- *
- * Copyright 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
- * Modifications copyright (C) 2017 Uber Technologies, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"). You may not
- * use this file except in compliance with the License. A copy of the License is
- * located at
- *
- * http://aws.amazon.com/apache2.0
- *
- * or in the "license" file accompanying this file. This file is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
package io.temporal.samples.ssl;
import io.temporal.workflow.WorkflowInterface;
diff --git a/core/src/main/java/io/temporal/samples/ssl/MyWorkflowImpl.java b/core/src/main/java/io/temporal/samples/ssl/MyWorkflowImpl.java
index 645e6a946..701cc2f60 100644
--- a/core/src/main/java/io/temporal/samples/ssl/MyWorkflowImpl.java
+++ b/core/src/main/java/io/temporal/samples/ssl/MyWorkflowImpl.java
@@ -1,22 +1,3 @@
-/*
- * Copyright (c) 2020 Temporal Technologies, Inc. All Rights Reserved
- *
- * Copyright 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
- * Modifications copyright (C) 2017 Uber Technologies, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"). You may not
- * use this file except in compliance with the License. A copy of the License is
- * located at
- *
- * http://aws.amazon.com/apache2.0
- *
- * or in the "license" file accompanying this file. This file is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
package io.temporal.samples.ssl;
public class MyWorkflowImpl implements MyWorkflow {
diff --git a/core/src/main/java/io/temporal/samples/ssl/SslEnabledWorkerCustomCA.java b/core/src/main/java/io/temporal/samples/ssl/SslEnabledWorkerCustomCA.java
index 165737ffa..427fefcb8 100644
--- a/core/src/main/java/io/temporal/samples/ssl/SslEnabledWorkerCustomCA.java
+++ b/core/src/main/java/io/temporal/samples/ssl/SslEnabledWorkerCustomCA.java
@@ -1,22 +1,3 @@
-/*
- * Copyright (c) 2020 Temporal Technologies, Inc. All Rights Reserved
- *
- * Copyright 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
- * Modifications copyright (C) 2017 Uber Technologies, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"). You may not
- * use this file except in compliance with the License. A copy of the License is
- * located at
- *
- * http://aws.amazon.com/apache2.0
- *
- * or in the "license" file accompanying this file. This file is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
package io.temporal.samples.ssl;
import io.grpc.netty.shaded.io.grpc.netty.GrpcSslContexts;
diff --git a/core/src/main/java/io/temporal/samples/ssl/Starter.java b/core/src/main/java/io/temporal/samples/ssl/Starter.java
index ca748ffc3..25b9df6ba 100644
--- a/core/src/main/java/io/temporal/samples/ssl/Starter.java
+++ b/core/src/main/java/io/temporal/samples/ssl/Starter.java
@@ -1,22 +1,3 @@
-/*
- * Copyright (c) 2020 Temporal Technologies, Inc. All Rights Reserved
- *
- * Copyright 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
- * Modifications copyright (C) 2017 Uber Technologies, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"). You may not
- * use this file except in compliance with the License. A copy of the License is
- * located at
- *
- * http://aws.amazon.com/apache2.0
- *
- * or in the "license" file accompanying this file. This file is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
package io.temporal.samples.ssl;
import io.grpc.netty.shaded.io.grpc.netty.GrpcSslContexts;
@@ -69,9 +50,9 @@ public static void main(String[] args) throws Exception {
if (refreshPeriod > 0) {
AdvancedTlsX509KeyManager clientKeyManager = new AdvancedTlsX509KeyManager();
// Reload credentials every minute
- clientKeyManager.updateIdentityCredentialsFromFile(
- clientKeyFile,
+ clientKeyManager.updateIdentityCredentials(
clientCertFile,
+ clientKeyFile,
refreshPeriod,
TimeUnit.MINUTES,
Executors.newScheduledThreadPool(1));
diff --git a/core/src/main/java/io/temporal/samples/terminateworkflow/MyWorkflow.java b/core/src/main/java/io/temporal/samples/terminateworkflow/MyWorkflow.java
index 4c517bd67..b22060095 100644
--- a/core/src/main/java/io/temporal/samples/terminateworkflow/MyWorkflow.java
+++ b/core/src/main/java/io/temporal/samples/terminateworkflow/MyWorkflow.java
@@ -1,22 +1,3 @@
-/*
- * Copyright (c) 2020 Temporal Technologies, Inc. All Rights Reserved
- *
- * Copyright 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
- * Modifications copyright (C) 2017 Uber Technologies, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"). You may not
- * use this file except in compliance with the License. A copy of the License is
- * located at
- *
- * http://aws.amazon.com/apache2.0
- *
- * or in the "license" file accompanying this file. This file is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
package io.temporal.samples.terminateworkflow;
import io.temporal.workflow.WorkflowInterface;
diff --git a/core/src/main/java/io/temporal/samples/terminateworkflow/MyWorkflowImpl.java b/core/src/main/java/io/temporal/samples/terminateworkflow/MyWorkflowImpl.java
index a254f1e34..82e6159e8 100644
--- a/core/src/main/java/io/temporal/samples/terminateworkflow/MyWorkflowImpl.java
+++ b/core/src/main/java/io/temporal/samples/terminateworkflow/MyWorkflowImpl.java
@@ -1,22 +1,3 @@
-/*
- * Copyright (c) 2020 Temporal Technologies, Inc. All Rights Reserved
- *
- * Copyright 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
- * Modifications copyright (C) 2017 Uber Technologies, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"). You may not
- * use this file except in compliance with the License. A copy of the License is
- * located at
- *
- * http://aws.amazon.com/apache2.0
- *
- * or in the "license" file accompanying this file. This file is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
package io.temporal.samples.terminateworkflow;
import io.temporal.workflow.Workflow;
diff --git a/core/src/main/java/io/temporal/samples/terminateworkflow/Starter.java b/core/src/main/java/io/temporal/samples/terminateworkflow/Starter.java
index 3b9d17fed..e36a407c7 100644
--- a/core/src/main/java/io/temporal/samples/terminateworkflow/Starter.java
+++ b/core/src/main/java/io/temporal/samples/terminateworkflow/Starter.java
@@ -1,22 +1,3 @@
-/*
- * Copyright (c) 2020 Temporal Technologies, Inc. All Rights Reserved
- *
- * Copyright 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
- * Modifications copyright (C) 2017 Uber Technologies, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"). You may not
- * use this file except in compliance with the License. A copy of the License is
- * located at
- *
- * http://aws.amazon.com/apache2.0
- *
- * or in the "license" file accompanying this file. This file is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
package io.temporal.samples.terminateworkflow;
import io.temporal.api.common.v1.WorkflowExecution;
@@ -26,21 +7,33 @@
import io.temporal.client.WorkflowClient;
import io.temporal.client.WorkflowOptions;
import io.temporal.client.WorkflowStub;
+import io.temporal.envconfig.ClientConfigProfile;
import io.temporal.serviceclient.WorkflowServiceStubs;
import io.temporal.worker.Worker;
import io.temporal.worker.WorkerFactory;
+import java.io.IOException;
import java.util.concurrent.TimeUnit;
public class Starter {
public static final String TASK_QUEUE = "terminateQueue";
- private static final WorkflowServiceStubs service = WorkflowServiceStubs.newLocalServiceStubs();
- private static final WorkflowClient client = WorkflowClient.newInstance(service);
- private static final WorkerFactory factory = WorkerFactory.newInstance(client);
public static void main(String[] args) {
+ // Load configuration from environment and files
+ ClientConfigProfile profile;
+ try {
+ profile = ClientConfigProfile.load();
+ } catch (IOException e) {
+ throw new RuntimeException("Failed to load client configuration", e);
+ }
+
+ WorkflowServiceStubs service =
+ WorkflowServiceStubs.newServiceStubs(profile.toWorkflowServiceStubsOptions());
+ WorkflowClient client = WorkflowClient.newInstance(service, profile.toWorkflowClientOptions());
+ WorkerFactory factory = WorkerFactory.newInstance(client);
+
// Create Worker
- createWorker();
+ createWorker(factory);
// Create Workflow options
WorkflowOptions workflowOptions =
@@ -63,13 +56,13 @@ public static void main(String[] args) {
untyped.terminate("Sample reason");
// Check workflow status, should be WORKFLOW_EXECUTION_STATUS_TERMINATED
- System.out.println("Status: " + getStatusAsString(execution));
+ System.out.println("Status: " + getStatusAsString(execution, client, service));
System.exit(0);
}
/** This method creates a Worker from the factory. */
- private static void createWorker() {
+ private static void createWorker(WorkerFactory factory) {
Worker worker = factory.newWorker(TASK_QUEUE);
worker.registerWorkflowImplementationTypes(MyWorkflowImpl.class);
@@ -97,7 +90,8 @@ private static void sleepSeconds(int seconds) {
* @param execution workflow execution
* @return Workflow status
*/
- private static String getStatusAsString(WorkflowExecution execution) {
+ private static String getStatusAsString(
+ WorkflowExecution execution, WorkflowClient client, WorkflowServiceStubs service) {
DescribeWorkflowExecutionRequest describeWorkflowExecutionRequest =
DescribeWorkflowExecutionRequest.newBuilder()
.setNamespace(client.getOptions().getNamespace())
diff --git a/core/src/main/java/io/temporal/samples/tracing/JaegerUtils.java b/core/src/main/java/io/temporal/samples/tracing/JaegerUtils.java
index 862c4d0c1..0b64b604c 100644
--- a/core/src/main/java/io/temporal/samples/tracing/JaegerUtils.java
+++ b/core/src/main/java/io/temporal/samples/tracing/JaegerUtils.java
@@ -1,22 +1,3 @@
-/*
- * Copyright (c) 2020 Temporal Technologies, Inc. All Rights Reserved
- *
- * Copyright 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
- * Modifications copyright (C) 2017 Uber Technologies, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"). You may not
- * use this file except in compliance with the License. A copy of the License is
- * located at
- *
- * http://aws.amazon.com/apache2.0
- *
- * or in the "license" file accompanying this file. This file is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
package io.temporal.samples.tracing;
import io.jaegertracing.internal.JaegerTracer;
diff --git a/core/src/main/java/io/temporal/samples/tracing/Starter.java b/core/src/main/java/io/temporal/samples/tracing/Starter.java
index 62b251d00..bb1eaaae3 100644
--- a/core/src/main/java/io/temporal/samples/tracing/Starter.java
+++ b/core/src/main/java/io/temporal/samples/tracing/Starter.java
@@ -1,34 +1,16 @@
-/*
- * Copyright (c) 2020 Temporal Technologies, Inc. All Rights Reserved
- *
- * Copyright 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
- * Modifications copyright (C) 2017 Uber Technologies, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"). You may not
- * use this file except in compliance with the License. A copy of the License is
- * located at
- *
- * http://aws.amazon.com/apache2.0
- *
- * or in the "license" file accompanying this file. This file is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
package io.temporal.samples.tracing;
import io.temporal.client.WorkflowClient;
import io.temporal.client.WorkflowClientOptions;
import io.temporal.client.WorkflowOptions;
import io.temporal.client.WorkflowStub;
+import io.temporal.envconfig.ClientConfigProfile;
import io.temporal.opentracing.OpenTracingClientInterceptor;
import io.temporal.samples.tracing.workflow.TracingWorkflow;
import io.temporal.serviceclient.WorkflowServiceStubs;
+import java.io.IOException;
public class Starter {
- public static final WorkflowServiceStubs service = WorkflowServiceStubs.newLocalServiceStubs();
public static final String TASK_QUEUE_NAME = "tracingTaskQueue";
public static void main(String[] args) {
@@ -37,9 +19,20 @@ public static void main(String[] args) {
type = args[0];
}
- // Set the OpenTracing client interceptor
+ // Load configuration from environment and files
+ ClientConfigProfile profile;
+ try {
+ profile = ClientConfigProfile.load();
+ } catch (IOException e) {
+ throw new RuntimeException("Failed to load client configuration", e);
+ }
+
+ WorkflowServiceStubs service =
+ WorkflowServiceStubs.newServiceStubs(profile.toWorkflowServiceStubsOptions());
+
+ // Set the OpenTracing client interceptor, preserving env config
WorkflowClientOptions clientOptions =
- WorkflowClientOptions.newBuilder()
+ profile.toWorkflowClientOptions().toBuilder()
.setInterceptors(new OpenTracingClientInterceptor(JaegerUtils.getJaegerOptions(type)))
.build();
WorkflowClient client = WorkflowClient.newInstance(service, clientOptions);
diff --git a/core/src/main/java/io/temporal/samples/tracing/TracingWorker.java b/core/src/main/java/io/temporal/samples/tracing/TracingWorker.java
index 26cbfe8b3..b726bcaae 100644
--- a/core/src/main/java/io/temporal/samples/tracing/TracingWorker.java
+++ b/core/src/main/java/io/temporal/samples/tracing/TracingWorker.java
@@ -1,25 +1,7 @@
-/*
- * Copyright (c) 2020 Temporal Technologies, Inc. All Rights Reserved
- *
- * Copyright 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
- * Modifications copyright (C) 2017 Uber Technologies, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"). You may not
- * use this file except in compliance with the License. A copy of the License is
- * located at
- *
- * http://aws.amazon.com/apache2.0
- *
- * or in the "license" file accompanying this file. This file is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
package io.temporal.samples.tracing;
import io.temporal.client.WorkflowClient;
+import io.temporal.envconfig.ClientConfigProfile;
import io.temporal.opentracing.OpenTracingWorkerInterceptor;
import io.temporal.samples.tracing.workflow.TracingActivitiesImpl;
import io.temporal.samples.tracing.workflow.TracingChildWorkflowImpl;
@@ -28,10 +10,9 @@
import io.temporal.worker.Worker;
import io.temporal.worker.WorkerFactory;
import io.temporal.worker.WorkerFactoryOptions;
+import java.io.IOException;
public class TracingWorker {
- private static final WorkflowServiceStubs service = WorkflowServiceStubs.newLocalServiceStubs();
- private static final WorkflowClient client = WorkflowClient.newInstance(service);
public static final String TASK_QUEUE_NAME = "tracingTaskQueue";
public static void main(String[] args) {
@@ -40,6 +21,18 @@ public static void main(String[] args) {
type = args[0];
}
+ // Load configuration from environment and files
+ ClientConfigProfile profile;
+ try {
+ profile = ClientConfigProfile.load();
+ } catch (IOException e) {
+ throw new RuntimeException("Failed to load client configuration", e);
+ }
+
+ WorkflowServiceStubs service =
+ WorkflowServiceStubs.newServiceStubs(profile.toWorkflowServiceStubsOptions());
+ WorkflowClient client = WorkflowClient.newInstance(service, profile.toWorkflowClientOptions());
+
// Set the OpenTracing client interceptor
WorkerFactoryOptions factoryOptions =
WorkerFactoryOptions.newBuilder()
diff --git a/core/src/main/java/io/temporal/samples/tracing/workflow/TracingActivities.java b/core/src/main/java/io/temporal/samples/tracing/workflow/TracingActivities.java
index a0a59c746..af9f8d9ba 100644
--- a/core/src/main/java/io/temporal/samples/tracing/workflow/TracingActivities.java
+++ b/core/src/main/java/io/temporal/samples/tracing/workflow/TracingActivities.java
@@ -1,22 +1,3 @@
-/*
- * Copyright (c) 2020 Temporal Technologies, Inc. All Rights Reserved
- *
- * Copyright 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
- * Modifications copyright (C) 2017 Uber Technologies, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"). You may not
- * use this file except in compliance with the License. A copy of the License is
- * located at
- *
- * http://aws.amazon.com/apache2.0
- *
- * or in the "license" file accompanying this file. This file is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
package io.temporal.samples.tracing.workflow;
import io.temporal.activity.ActivityInterface;
diff --git a/core/src/main/java/io/temporal/samples/tracing/workflow/TracingActivitiesImpl.java b/core/src/main/java/io/temporal/samples/tracing/workflow/TracingActivitiesImpl.java
index a72763370..83af9d490 100644
--- a/core/src/main/java/io/temporal/samples/tracing/workflow/TracingActivitiesImpl.java
+++ b/core/src/main/java/io/temporal/samples/tracing/workflow/TracingActivitiesImpl.java
@@ -1,22 +1,3 @@
-/*
- * Copyright (c) 2020 Temporal Technologies, Inc. All Rights Reserved
- *
- * Copyright 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
- * Modifications copyright (C) 2017 Uber Technologies, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"). You may not
- * use this file except in compliance with the License. A copy of the License is
- * located at
- *
- * http://aws.amazon.com/apache2.0
- *
- * or in the "license" file accompanying this file. This file is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
package io.temporal.samples.tracing.workflow;
public class TracingActivitiesImpl implements TracingActivities {
diff --git a/core/src/main/java/io/temporal/samples/tracing/workflow/TracingChildWorkflow.java b/core/src/main/java/io/temporal/samples/tracing/workflow/TracingChildWorkflow.java
index bb5ef68b4..a02448957 100644
--- a/core/src/main/java/io/temporal/samples/tracing/workflow/TracingChildWorkflow.java
+++ b/core/src/main/java/io/temporal/samples/tracing/workflow/TracingChildWorkflow.java
@@ -1,22 +1,3 @@
-/*
- * Copyright (c) 2020 Temporal Technologies, Inc. All Rights Reserved
- *
- * Copyright 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
- * Modifications copyright (C) 2017 Uber Technologies, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"). You may not
- * use this file except in compliance with the License. A copy of the License is
- * located at
- *
- * http://aws.amazon.com/apache2.0
- *
- * or in the "license" file accompanying this file. This file is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
package io.temporal.samples.tracing.workflow;
import io.temporal.workflow.WorkflowInterface;
diff --git a/core/src/main/java/io/temporal/samples/tracing/workflow/TracingChildWorkflowImpl.java b/core/src/main/java/io/temporal/samples/tracing/workflow/TracingChildWorkflowImpl.java
index a6f49c6d3..e170b4e84 100644
--- a/core/src/main/java/io/temporal/samples/tracing/workflow/TracingChildWorkflowImpl.java
+++ b/core/src/main/java/io/temporal/samples/tracing/workflow/TracingChildWorkflowImpl.java
@@ -1,22 +1,3 @@
-/*
- * Copyright (c) 2020 Temporal Technologies, Inc. All Rights Reserved
- *
- * Copyright 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
- * Modifications copyright (C) 2017 Uber Technologies, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"). You may not
- * use this file except in compliance with the License. A copy of the License is
- * located at
- *
- * http://aws.amazon.com/apache2.0
- *
- * or in the "license" file accompanying this file. This file is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
package io.temporal.samples.tracing.workflow;
import io.temporal.activity.ActivityOptions;
diff --git a/core/src/main/java/io/temporal/samples/tracing/workflow/TracingWorkflow.java b/core/src/main/java/io/temporal/samples/tracing/workflow/TracingWorkflow.java
index f6d983f99..69a50f3b1 100644
--- a/core/src/main/java/io/temporal/samples/tracing/workflow/TracingWorkflow.java
+++ b/core/src/main/java/io/temporal/samples/tracing/workflow/TracingWorkflow.java
@@ -1,22 +1,3 @@
-/*
- * Copyright (c) 2020 Temporal Technologies, Inc. All Rights Reserved
- *
- * Copyright 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
- * Modifications copyright (C) 2017 Uber Technologies, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"). You may not
- * use this file except in compliance with the License. A copy of the License is
- * located at
- *
- * http://aws.amazon.com/apache2.0
- *
- * or in the "license" file accompanying this file. This file is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
package io.temporal.samples.tracing.workflow;
import io.temporal.workflow.QueryMethod;
diff --git a/core/src/main/java/io/temporal/samples/tracing/workflow/TracingWorkflowImpl.java b/core/src/main/java/io/temporal/samples/tracing/workflow/TracingWorkflowImpl.java
index a02886013..86d440ab6 100644
--- a/core/src/main/java/io/temporal/samples/tracing/workflow/TracingWorkflowImpl.java
+++ b/core/src/main/java/io/temporal/samples/tracing/workflow/TracingWorkflowImpl.java
@@ -1,22 +1,3 @@
-/*
- * Copyright (c) 2020 Temporal Technologies, Inc. All Rights Reserved
- *
- * Copyright 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
- * Modifications copyright (C) 2017 Uber Technologies, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"). You may not
- * use this file except in compliance with the License. A copy of the License is
- * located at
- *
- * http://aws.amazon.com/apache2.0
- *
- * or in the "license" file accompanying this file. This file is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
package io.temporal.samples.tracing.workflow;
import io.temporal.workflow.ChildWorkflowOptions;
diff --git a/core/src/main/java/io/temporal/samples/updatabletimer/DynamicSleepWorkflow.java b/core/src/main/java/io/temporal/samples/updatabletimer/DynamicSleepWorkflow.java
index b296a9e2b..9fa4a947f 100644
--- a/core/src/main/java/io/temporal/samples/updatabletimer/DynamicSleepWorkflow.java
+++ b/core/src/main/java/io/temporal/samples/updatabletimer/DynamicSleepWorkflow.java
@@ -1,22 +1,3 @@
-/*
- * Copyright (c) 2020 Temporal Technologies, Inc. All Rights Reserved
- *
- * Copyright 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
- * Modifications copyright (C) 2017 Uber Technologies, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"). You may not
- * use this file except in compliance with the License. A copy of the License is
- * located at
- *
- * http://aws.amazon.com/apache2.0
- *
- * or in the "license" file accompanying this file. This file is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
package io.temporal.samples.updatabletimer;
import io.temporal.workflow.QueryMethod;
diff --git a/core/src/main/java/io/temporal/samples/updatabletimer/DynamicSleepWorkflowImpl.java b/core/src/main/java/io/temporal/samples/updatabletimer/DynamicSleepWorkflowImpl.java
index ad47eb88f..487f99640 100644
--- a/core/src/main/java/io/temporal/samples/updatabletimer/DynamicSleepWorkflowImpl.java
+++ b/core/src/main/java/io/temporal/samples/updatabletimer/DynamicSleepWorkflowImpl.java
@@ -1,22 +1,3 @@
-/*
- * Copyright (c) 2020 Temporal Technologies, Inc. All Rights Reserved
- *
- * Copyright 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
- * Modifications copyright (C) 2017 Uber Technologies, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"). You may not
- * use this file except in compliance with the License. A copy of the License is
- * located at
- *
- * http://aws.amazon.com/apache2.0
- *
- * or in the "license" file accompanying this file. This file is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
package io.temporal.samples.updatabletimer;
public class DynamicSleepWorkflowImpl implements DynamicSleepWorkflow {
diff --git a/core/src/main/java/io/temporal/samples/updatabletimer/DynamicSleepWorkflowStarter.java b/core/src/main/java/io/temporal/samples/updatabletimer/DynamicSleepWorkflowStarter.java
index 5f0897051..0cd1bb14c 100644
--- a/core/src/main/java/io/temporal/samples/updatabletimer/DynamicSleepWorkflowStarter.java
+++ b/core/src/main/java/io/temporal/samples/updatabletimer/DynamicSleepWorkflowStarter.java
@@ -1,22 +1,3 @@
-/*
- * Copyright (c) 2020 Temporal Technologies, Inc. All Rights Reserved
- *
- * Copyright 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
- * Modifications copyright (C) 2017 Uber Technologies, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"). You may not
- * use this file except in compliance with the License. A copy of the License is
- * located at
- *
- * http://aws.amazon.com/apache2.0
- *
- * or in the "license" file accompanying this file. This file is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
package io.temporal.samples.updatabletimer;
import static io.temporal.samples.updatabletimer.DynamicSleepWorkflowWorker.DYNAMIC_SLEEP_WORKFLOW_ID;
@@ -27,7 +8,9 @@
import io.temporal.client.WorkflowClient;
import io.temporal.client.WorkflowExecutionAlreadyStarted;
import io.temporal.client.WorkflowOptions;
+import io.temporal.envconfig.ClientConfigProfile;
import io.temporal.serviceclient.WorkflowServiceStubs;
+import java.io.IOException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -36,8 +19,17 @@ public class DynamicSleepWorkflowStarter {
private static final Logger logger = LoggerFactory.getLogger(DynamicSleepWorkflowStarter.class);
public static void main(String[] args) {
- WorkflowServiceStubs service = WorkflowServiceStubs.newLocalServiceStubs();
- WorkflowClient client = WorkflowClient.newInstance(service);
+ // Load configuration from environment and files
+ ClientConfigProfile profile;
+ try {
+ profile = ClientConfigProfile.load();
+ } catch (IOException e) {
+ throw new RuntimeException("Failed to load client configuration", e);
+ }
+
+ WorkflowServiceStubs service =
+ WorkflowServiceStubs.newServiceStubs(profile.toWorkflowServiceStubsOptions());
+ WorkflowClient client = WorkflowClient.newInstance(service, profile.toWorkflowClientOptions());
DynamicSleepWorkflow workflow =
client.newWorkflowStub(
diff --git a/core/src/main/java/io/temporal/samples/updatabletimer/DynamicSleepWorkflowWorker.java b/core/src/main/java/io/temporal/samples/updatabletimer/DynamicSleepWorkflowWorker.java
index 14429ea0e..a7db34126 100644
--- a/core/src/main/java/io/temporal/samples/updatabletimer/DynamicSleepWorkflowWorker.java
+++ b/core/src/main/java/io/temporal/samples/updatabletimer/DynamicSleepWorkflowWorker.java
@@ -1,28 +1,11 @@
-/*
- * Copyright (c) 2020 Temporal Technologies, Inc. All Rights Reserved
- *
- * Copyright 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
- * Modifications copyright (C) 2017 Uber Technologies, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"). You may not
- * use this file except in compliance with the License. A copy of the License is
- * located at
- *
- * http://aws.amazon.com/apache2.0
- *
- * or in the "license" file accompanying this file. This file is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
package io.temporal.samples.updatabletimer;
import io.temporal.client.WorkflowClient;
+import io.temporal.envconfig.ClientConfigProfile;
import io.temporal.serviceclient.WorkflowServiceStubs;
import io.temporal.worker.Worker;
import io.temporal.worker.WorkerFactory;
+import java.io.IOException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -36,8 +19,17 @@ public class DynamicSleepWorkflowWorker {
static final String DYNAMIC_SLEEP_WORKFLOW_ID = "DynamicSleepWorkflow";
public static void main(String[] args) {
- WorkflowServiceStubs service = WorkflowServiceStubs.newLocalServiceStubs();
- WorkflowClient client = WorkflowClient.newInstance(service);
+ // Load configuration from environment and files
+ ClientConfigProfile profile;
+ try {
+ profile = ClientConfigProfile.load();
+ } catch (IOException e) {
+ throw new RuntimeException("Failed to load client configuration", e);
+ }
+
+ WorkflowServiceStubs service =
+ WorkflowServiceStubs.newServiceStubs(profile.toWorkflowServiceStubsOptions());
+ WorkflowClient client = WorkflowClient.newInstance(service, profile.toWorkflowClientOptions());
WorkerFactory factory = WorkerFactory.newInstance(client);
final Worker worker = factory.newWorker(TASK_QUEUE);
worker.registerWorkflowImplementationTypes(DynamicSleepWorkflowImpl.class);
diff --git a/core/src/main/java/io/temporal/samples/updatabletimer/UpdatableTimer.java b/core/src/main/java/io/temporal/samples/updatabletimer/UpdatableTimer.java
index 0a81c7c9d..3a117d2e0 100644
--- a/core/src/main/java/io/temporal/samples/updatabletimer/UpdatableTimer.java
+++ b/core/src/main/java/io/temporal/samples/updatabletimer/UpdatableTimer.java
@@ -1,22 +1,3 @@
-/*
- * Copyright (c) 2020 Temporal Technologies, Inc. All Rights Reserved
- *
- * Copyright 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
- * Modifications copyright (C) 2017 Uber Technologies, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"). You may not
- * use this file except in compliance with the License. A copy of the License is
- * located at
- *
- * http://aws.amazon.com/apache2.0
- *
- * or in the "license" file accompanying this file. This file is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
package io.temporal.samples.updatabletimer;
import io.temporal.workflow.Workflow;
diff --git a/core/src/main/java/io/temporal/samples/updatabletimer/WakeUpTimeUpdater.java b/core/src/main/java/io/temporal/samples/updatabletimer/WakeUpTimeUpdater.java
index 5f612aaf1..3a8f935a2 100644
--- a/core/src/main/java/io/temporal/samples/updatabletimer/WakeUpTimeUpdater.java
+++ b/core/src/main/java/io/temporal/samples/updatabletimer/WakeUpTimeUpdater.java
@@ -1,28 +1,11 @@
-/*
- * Copyright (c) 2020 Temporal Technologies, Inc. All Rights Reserved
- *
- * Copyright 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
- * Modifications copyright (C) 2017 Uber Technologies, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"). You may not
- * use this file except in compliance with the License. A copy of the License is
- * located at
- *
- * http://aws.amazon.com/apache2.0
- *
- * or in the "license" file accompanying this file. This file is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
package io.temporal.samples.updatabletimer;
import static io.temporal.samples.updatabletimer.DynamicSleepWorkflowWorker.DYNAMIC_SLEEP_WORKFLOW_ID;
import io.temporal.client.WorkflowClient;
+import io.temporal.envconfig.ClientConfigProfile;
import io.temporal.serviceclient.WorkflowServiceStubs;
+import java.io.IOException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -31,8 +14,17 @@ public class WakeUpTimeUpdater {
private static final Logger logger = LoggerFactory.getLogger(WakeUpTimeUpdater.class);
public static void main(String[] args) {
- WorkflowServiceStubs service = WorkflowServiceStubs.newLocalServiceStubs();
- WorkflowClient client = WorkflowClient.newInstance(service);
+ // Load configuration from environment and files
+ ClientConfigProfile profile;
+ try {
+ profile = ClientConfigProfile.load();
+ } catch (IOException e) {
+ throw new RuntimeException("Failed to load client configuration", e);
+ }
+
+ WorkflowServiceStubs service =
+ WorkflowServiceStubs.newServiceStubs(profile.toWorkflowServiceStubsOptions());
+ WorkflowClient client = WorkflowClient.newInstance(service, profile.toWorkflowClientOptions());
// Create a stub that points to an existing workflow with the given ID
DynamicSleepWorkflow workflow =
diff --git a/core/src/main/java/io/temporal/samples/workerversioning/Activities.java b/core/src/main/java/io/temporal/samples/workerversioning/Activities.java
new file mode 100644
index 000000000..b41189d2a
--- /dev/null
+++ b/core/src/main/java/io/temporal/samples/workerversioning/Activities.java
@@ -0,0 +1,38 @@
+package io.temporal.samples.workerversioning;
+
+import com.fasterxml.jackson.annotation.JsonCreator;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import io.temporal.activity.ActivityInterface;
+import io.temporal.activity.ActivityMethod;
+
+@ActivityInterface
+public interface Activities {
+
+ @ActivityMethod
+ String someActivity(String calledBy);
+
+ @ActivityMethod
+ String someIncompatibleActivity(IncompatibleActivityInput input);
+
+ class IncompatibleActivityInput {
+ private final String calledBy;
+ private final String moreData;
+
+ @JsonCreator(mode = JsonCreator.Mode.PROPERTIES)
+ public IncompatibleActivityInput(
+ @JsonProperty("calledBy") String calledBy, @JsonProperty("moreData") String moreData) {
+ this.calledBy = calledBy;
+ this.moreData = moreData;
+ }
+
+ @JsonProperty("calledBy")
+ public String getCalledBy() {
+ return calledBy;
+ }
+
+ @JsonProperty("moreData")
+ public String getMoreData() {
+ return moreData;
+ }
+ }
+}
diff --git a/core/src/main/java/io/temporal/samples/workerversioning/ActivitiesImpl.java b/core/src/main/java/io/temporal/samples/workerversioning/ActivitiesImpl.java
new file mode 100644
index 000000000..b3e4e2c28
--- /dev/null
+++ b/core/src/main/java/io/temporal/samples/workerversioning/ActivitiesImpl.java
@@ -0,0 +1,25 @@
+package io.temporal.samples.workerversioning;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class ActivitiesImpl implements Activities {
+
+ private static final Logger logger = LoggerFactory.getLogger(ActivitiesImpl.class);
+
+ @Override
+ public String someActivity(String calledBy) {
+ logger.info("SomeActivity called by {}", calledBy);
+ return "SomeActivity called by " + calledBy;
+ }
+
+ @Override
+ public String someIncompatibleActivity(IncompatibleActivityInput input) {
+ logger.info(
+ "SomeIncompatibleActivity called by {} with {}", input.getCalledBy(), input.getMoreData());
+ return "SomeIncompatibleActivity called by "
+ + input.getCalledBy()
+ + " with "
+ + input.getMoreData();
+ }
+}
diff --git a/core/src/main/java/io/temporal/samples/workerversioning/AutoUpgradingWorkflow.java b/core/src/main/java/io/temporal/samples/workerversioning/AutoUpgradingWorkflow.java
new file mode 100644
index 000000000..8dff5f7cd
--- /dev/null
+++ b/core/src/main/java/io/temporal/samples/workerversioning/AutoUpgradingWorkflow.java
@@ -0,0 +1,15 @@
+package io.temporal.samples.workerversioning;
+
+import io.temporal.workflow.SignalMethod;
+import io.temporal.workflow.WorkflowInterface;
+import io.temporal.workflow.WorkflowMethod;
+
+@WorkflowInterface
+public interface AutoUpgradingWorkflow {
+
+ @WorkflowMethod
+ void run();
+
+ @SignalMethod
+ void doNextSignal(String signal);
+}
diff --git a/core/src/main/java/io/temporal/samples/workerversioning/AutoUpgradingWorkflowV1Impl.java b/core/src/main/java/io/temporal/samples/workerversioning/AutoUpgradingWorkflowV1Impl.java
new file mode 100644
index 000000000..645f0f70d
--- /dev/null
+++ b/core/src/main/java/io/temporal/samples/workerversioning/AutoUpgradingWorkflowV1Impl.java
@@ -0,0 +1,52 @@
+package io.temporal.samples.workerversioning;
+
+import io.temporal.activity.ActivityOptions;
+import io.temporal.common.VersioningBehavior;
+import io.temporal.workflow.Workflow;
+import io.temporal.workflow.WorkflowVersioningBehavior;
+import java.time.Duration;
+import java.util.ArrayList;
+import java.util.List;
+import org.slf4j.Logger;
+
+/**
+ * This workflow will automatically move to the latest worker version. We'll be making changes to
+ * it, which must be replay safe. Note that generally you won't want or need to include a version
+ * number in your workflow name if you're using the worker versioning feature. This sample does it
+ * to illustrate changes to the same code over time - but really what we're demonstrating here is
+ * the evolution of what would have been one workflow definition.
+ */
+public class AutoUpgradingWorkflowV1Impl implements AutoUpgradingWorkflow {
+
+ private static final Logger logger = Workflow.getLogger(AutoUpgradingWorkflowV1Impl.class);
+
+ private final List signals = new ArrayList<>();
+ private final Activities activities =
+ Workflow.newActivityStub(
+ Activities.class,
+ ActivityOptions.newBuilder().setStartToCloseTimeout(Duration.ofSeconds(10)).build());
+
+ @Override
+ @WorkflowVersioningBehavior(VersioningBehavior.AUTO_UPGRADE)
+ public void run() {
+ logger.info("Changing workflow v1 started. StartTime: {}", Workflow.currentTimeMillis());
+
+ while (true) {
+ Workflow.await(() -> !signals.isEmpty());
+ String signal = signals.remove(0);
+
+ if ("do-activity".equals(signal)) {
+ logger.info("Changing workflow v1 running activity");
+ activities.someActivity("v1");
+ } else {
+ logger.info("Concluding workflow v1");
+ return;
+ }
+ }
+ }
+
+ @Override
+ public void doNextSignal(String signal) {
+ signals.add(signal);
+ }
+}
diff --git a/core/src/main/java/io/temporal/samples/workerversioning/AutoUpgradingWorkflowV1bImpl.java b/core/src/main/java/io/temporal/samples/workerversioning/AutoUpgradingWorkflowV1bImpl.java
new file mode 100644
index 000000000..abedf8517
--- /dev/null
+++ b/core/src/main/java/io/temporal/samples/workerversioning/AutoUpgradingWorkflowV1bImpl.java
@@ -0,0 +1,65 @@
+package io.temporal.samples.workerversioning;
+
+import io.temporal.activity.ActivityOptions;
+import io.temporal.common.VersioningBehavior;
+import io.temporal.workflow.Workflow;
+import io.temporal.workflow.WorkflowVersioningBehavior;
+import java.time.Duration;
+import java.util.ArrayList;
+import java.util.List;
+import org.slf4j.Logger;
+
+/**
+ * This represents us having made *compatible* changes to AutoUpgradingWorkflowV1Impl.
+ *
+ * The compatible changes we've made are:
+ *
+ *
+ * - Altering the log lines
+ *
- Using the `Workflow.getVersion` API to properly introduce branching behavior while
+ * maintaining compatibility
+ *
+ */
+public class AutoUpgradingWorkflowV1bImpl implements AutoUpgradingWorkflow {
+
+ private static final Logger logger = Workflow.getLogger(AutoUpgradingWorkflowV1bImpl.class);
+
+ private final List signals = new ArrayList<>();
+ private final Activities activities =
+ Workflow.newActivityStub(
+ Activities.class,
+ ActivityOptions.newBuilder().setStartToCloseTimeout(Duration.ofSeconds(10)).build());
+
+ @Override
+ @WorkflowVersioningBehavior(VersioningBehavior.AUTO_UPGRADE)
+ public void run() {
+ logger.info("Changing workflow v1b started. StartTime: {}", Workflow.currentTimeMillis());
+
+ while (true) {
+ Workflow.await(() -> !signals.isEmpty());
+ String signal = signals.remove(0);
+
+ if ("do-activity".equals(signal)) {
+ logger.info("Changing workflow v1b running activity");
+ int version = Workflow.getVersion("DifferentActivity", Workflow.DEFAULT_VERSION, 1);
+ if (version == 1) {
+ activities.someIncompatibleActivity(
+ new Activities.IncompatibleActivityInput("v1b", "hello!"));
+ } else {
+ // Note it is a valid compatible change to alter the input to an activity.
+ // However, because we're using the getVersion API, this branch will never be
+ // taken.
+ activities.someActivity("v1b");
+ }
+ } else {
+ logger.info("Concluding workflow v1b");
+ break;
+ }
+ }
+ }
+
+ @Override
+ public void doNextSignal(String signal) {
+ signals.add(signal);
+ }
+}
diff --git a/core/src/main/java/io/temporal/samples/workerversioning/PinnedWorkflow.java b/core/src/main/java/io/temporal/samples/workerversioning/PinnedWorkflow.java
new file mode 100644
index 000000000..1d930a40e
--- /dev/null
+++ b/core/src/main/java/io/temporal/samples/workerversioning/PinnedWorkflow.java
@@ -0,0 +1,15 @@
+package io.temporal.samples.workerversioning;
+
+import io.temporal.workflow.SignalMethod;
+import io.temporal.workflow.WorkflowInterface;
+import io.temporal.workflow.WorkflowMethod;
+
+@WorkflowInterface
+public interface PinnedWorkflow {
+
+ @WorkflowMethod
+ void run();
+
+ @SignalMethod
+ void doNextSignal(String signal);
+}
diff --git a/core/src/main/java/io/temporal/samples/workerversioning/PinnedWorkflowV1Impl.java b/core/src/main/java/io/temporal/samples/workerversioning/PinnedWorkflowV1Impl.java
new file mode 100644
index 000000000..4826f715c
--- /dev/null
+++ b/core/src/main/java/io/temporal/samples/workerversioning/PinnedWorkflowV1Impl.java
@@ -0,0 +1,49 @@
+package io.temporal.samples.workerversioning;
+
+import io.temporal.activity.ActivityOptions;
+import io.temporal.common.VersioningBehavior;
+import io.temporal.workflow.Workflow;
+import io.temporal.workflow.WorkflowVersioningBehavior;
+import java.time.Duration;
+import java.util.ArrayList;
+import java.util.List;
+import org.slf4j.Logger;
+
+/**
+ * This workflow represents one that likely has a short lifetime, and we want to always stay pinned
+ * to the same version it began on. Note that generally you won't want or need to include a version
+ * number in your workflow name if you're using the worker versioning feature. This sample does it
+ * to illustrate changes to the same code over time - but really what we're demonstrating here is
+ * the evolution of what would have been one workflow definition.
+ */
+public class PinnedWorkflowV1Impl implements PinnedWorkflow {
+
+ private static final Logger logger = Workflow.getLogger(PinnedWorkflowV1Impl.class);
+
+ private final List signals = new ArrayList<>();
+ private final Activities activities =
+ Workflow.newActivityStub(
+ Activities.class,
+ ActivityOptions.newBuilder().setStartToCloseTimeout(Duration.ofSeconds(10)).build());
+
+ @Override
+ @WorkflowVersioningBehavior(VersioningBehavior.PINNED)
+ public void run() {
+ logger.info("Pinned Workflow v1 started. StartTime: {}", Workflow.currentTimeMillis());
+
+ while (true) {
+ Workflow.await(() -> !signals.isEmpty());
+ String signal = signals.remove(0);
+ if ("conclude".equals(signal)) {
+ break;
+ }
+ }
+
+ activities.someActivity("Pinned-v1");
+ }
+
+ @Override
+ public void doNextSignal(String signal) {
+ signals.add(signal);
+ }
+}
diff --git a/core/src/main/java/io/temporal/samples/workerversioning/PinnedWorkflowV2Impl.java b/core/src/main/java/io/temporal/samples/workerversioning/PinnedWorkflowV2Impl.java
new file mode 100644
index 000000000..a880b2dc1
--- /dev/null
+++ b/core/src/main/java/io/temporal/samples/workerversioning/PinnedWorkflowV2Impl.java
@@ -0,0 +1,51 @@
+package io.temporal.samples.workerversioning;
+
+import io.temporal.activity.ActivityOptions;
+import io.temporal.common.VersioningBehavior;
+import io.temporal.workflow.Workflow;
+import io.temporal.workflow.WorkflowVersioningBehavior;
+import java.time.Duration;
+import java.util.ArrayList;
+import java.util.List;
+import org.slf4j.Logger;
+
+/**
+ * This workflow has changes that would make it incompatible with v1, and aren't protected by a
+ * patch.
+ */
+public class PinnedWorkflowV2Impl implements PinnedWorkflow {
+
+ private static final Logger logger = Workflow.getLogger(PinnedWorkflowV2Impl.class);
+
+ private final List signals = new ArrayList<>();
+ private final Activities activities =
+ Workflow.newActivityStub(
+ Activities.class,
+ ActivityOptions.newBuilder().setStartToCloseTimeout(Duration.ofSeconds(10)).build());
+
+ @Override
+ @WorkflowVersioningBehavior(VersioningBehavior.PINNED)
+ public void run() {
+ logger.info("Pinned Workflow v2 started. StartTime: {}", Workflow.currentTimeMillis());
+
+ // Here we call an activity where we didn't before, which is an incompatible change.
+ activities.someActivity("Pinned-v2");
+
+ while (true) {
+ Workflow.await(() -> !signals.isEmpty());
+ String signal = signals.remove(0);
+ if ("conclude".equals(signal)) {
+ break;
+ }
+ }
+
+ // We've also changed the activity type here, another incompatible change
+ activities.someIncompatibleActivity(
+ new Activities.IncompatibleActivityInput("Pinned-v2", "hi"));
+ }
+
+ @Override
+ public void doNextSignal(String signal) {
+ signals.add(signal);
+ }
+}
diff --git a/core/src/main/java/io/temporal/samples/workerversioning/README.md b/core/src/main/java/io/temporal/samples/workerversioning/README.md
new file mode 100644
index 000000000..c74b10488
--- /dev/null
+++ b/core/src/main/java/io/temporal/samples/workerversioning/README.md
@@ -0,0 +1,26 @@
+# Worker Versioning
+
+This sample demonstrates how to use Temporal's Worker Versioning feature to safely deploy updates to workflow and activity code. It shows the difference between auto-upgrading and pinned workflows, and how to manage worker deployments with different build IDs.
+
+The sample creates multiple worker versions (1.0, 1.1, and 2.0) within one deployment and demonstrates:
+- **Auto-upgrading workflows**: Automatically and controllably migrate to newer worker versions
+- **Pinned workflows**: Stay on the original worker version throughout their lifecycle
+- **Compatible vs incompatible changes**: How to make safe updates using `Workflow.getVersion`
+
+## Steps to run this sample:
+
+1) Run a [Temporal service](https://github.com/temporalio/samples-java/tree/main/#how-to-use). And
+ ensure that you're using at least Server version 1.28.0 (CLI version 1.4.0).
+
+2) Start the main application (this will guide you through the sample):
+ ```bash
+ ./gradlew -q execute -PmainClass=io.temporal.samples.workerversioning.Starter
+ ```
+3) Follow the prompts to start workers in separate terminals:
+ - When prompted, run: `./gradlew -q execute -PmainClass=io.temporal.samples.workerversioning.WorkerV1`
+ - When prompted, run: `./gradlew -q execute -PmainClass=io.temporal.samples.workerversioning.WorkerV1_1`
+ - When prompted, run: `./gradlew -q execute -PmainClass=io.temporal.samples.workerversioning.WorkerV2`
+
+Follow the prompts in the example to observe auto-upgrading workflows migrating to newer workers
+while pinned workflows remain on their original versions.
+
diff --git a/core/src/main/java/io/temporal/samples/workerversioning/Starter.java b/core/src/main/java/io/temporal/samples/workerversioning/Starter.java
new file mode 100644
index 000000000..b743cf821
--- /dev/null
+++ b/core/src/main/java/io/temporal/samples/workerversioning/Starter.java
@@ -0,0 +1,175 @@
+package io.temporal.samples.workerversioning;
+
+import io.temporal.api.workflowservice.v1.DescribeWorkerDeploymentRequest;
+import io.temporal.api.workflowservice.v1.DescribeWorkerDeploymentResponse;
+import io.temporal.api.workflowservice.v1.SetWorkerDeploymentCurrentVersionRequest;
+import io.temporal.client.WorkflowClient;
+import io.temporal.client.WorkflowOptions;
+import io.temporal.client.WorkflowStub;
+import io.temporal.common.WorkerDeploymentVersion;
+import io.temporal.envconfig.ClientConfigProfile;
+import io.temporal.serviceclient.WorkflowServiceStubs;
+import java.io.IOException;
+import java.util.UUID;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class Starter {
+ public static final String TASK_QUEUE = "worker-versioning";
+ public static final String DEPLOYMENT_NAME = "my-deployment";
+
+ private static final Logger logger = LoggerFactory.getLogger(Starter.class);
+
+ public static void main(String[] args) throws Exception {
+ // Load configuration from environment and files
+ ClientConfigProfile profile;
+ try {
+ profile = ClientConfigProfile.load();
+ } catch (IOException e) {
+ throw new RuntimeException("Failed to load client configuration", e);
+ }
+
+ WorkflowServiceStubs service =
+ WorkflowServiceStubs.newServiceStubs(profile.toWorkflowServiceStubsOptions());
+ WorkflowClient client = WorkflowClient.newInstance(service, profile.toWorkflowClientOptions());
+
+ // Wait for v1 worker and set as current version
+ logger.info(
+ "Waiting for v1 worker to appear. Run `./gradlew -q execute -PmainClass=io.temporal.samples.workerversioning.WorkerV1` in another terminal");
+ waitForWorkerAndMakeCurrent(client, service, "1.0");
+
+ // Start auto-upgrading and pinned workflows. Importantly, note that when we start the
+ // workflows,
+ // we are using a workflow type name which does *not* include the version number. We defined
+ // them
+ // with versioned names so we could show changes to the code, but here when the client invokes
+ // them, we're demonstrating that the client remains version-agnostic.
+ String autoUpgradeWorkflowId = "worker-versioning-versioning-autoupgrade_" + UUID.randomUUID();
+ WorkflowStub autoUpgradeExecution =
+ client.newUntypedWorkflowStub(
+ "AutoUpgradingWorkflow",
+ WorkflowOptions.newBuilder()
+ .setWorkflowId(autoUpgradeWorkflowId)
+ .setTaskQueue(TASK_QUEUE)
+ .build());
+
+ String pinnedWorkflowId = "worker-versioning-versioning-pinned_" + UUID.randomUUID();
+ WorkflowStub pinnedExecution =
+ client.newUntypedWorkflowStub(
+ "PinnedWorkflow",
+ WorkflowOptions.newBuilder()
+ .setWorkflowId(pinnedWorkflowId)
+ .setTaskQueue(TASK_QUEUE)
+ .build());
+
+ // Start workflows asynchronously
+ autoUpgradeExecution.start();
+ pinnedExecution.start();
+
+ logger.info(
+ "Started auto-upgrading workflow: {}", autoUpgradeExecution.getExecution().getWorkflowId());
+ logger.info("Started pinned workflow: {}", pinnedExecution.getExecution().getWorkflowId());
+
+ // Signal both workflows a few times to drive them
+ advanceWorkflows(autoUpgradeExecution, pinnedExecution);
+
+ // Now wait for the v1.1 worker to appear and become current
+ logger.info(
+ "Waiting for v1.1 worker to appear. Run `./gradlew -q execute -PmainClass=io.temporal.samples.workerversioning.WorkerV1_1` in another terminal");
+ waitForWorkerAndMakeCurrent(client, service, "1.1");
+
+ // Once it has, we will continue to advance the workflows.
+ // The auto-upgrade workflow will now make progress on the new worker, while the pinned one will
+ // keep progressing on the old worker.
+ advanceWorkflows(autoUpgradeExecution, pinnedExecution);
+
+ // Finally we'll start the v2 worker, and again it'll become the new current version
+ logger.info(
+ "Waiting for v2 worker to appear. Run `./gradlew -q execute -PmainClass=io.temporal.samples.workerversioning.WorkerV2` in another terminal");
+ waitForWorkerAndMakeCurrent(client, service, "2.0");
+
+ // Once it has we'll start one more new workflow, another pinned one, to demonstrate that new
+ // pinned workflows start on the current version.
+ String pinnedWorkflow2Id = "worker-versioning-versioning-pinned-2_" + UUID.randomUUID();
+ WorkflowStub pinnedExecution2 =
+ client.newUntypedWorkflowStub(
+ "PinnedWorkflow",
+ WorkflowOptions.newBuilder()
+ .setWorkflowId(pinnedWorkflow2Id)
+ .setTaskQueue(TASK_QUEUE)
+ .build());
+ pinnedExecution2.start();
+ logger.info("Started pinned workflow v2: {}", pinnedExecution2.getExecution().getWorkflowId());
+
+ // Now we'll conclude all workflows. You should be able to see in your server UI that the pinned
+ // workflow always stayed on 1.0, while the auto-upgrading workflow migrated.
+ autoUpgradeExecution.signal("doNextSignal", "conclude");
+ pinnedExecution.signal("doNextSignal", "conclude");
+ pinnedExecution2.signal("doNextSignal", "conclude");
+
+ // Wait for all workflows to complete
+ autoUpgradeExecution.getResult(Void.class);
+ pinnedExecution.getResult(Void.class);
+ pinnedExecution2.getResult(Void.class);
+
+ logger.info("All workflows completed");
+ }
+
+ private static void advanceWorkflows(
+ WorkflowStub autoUpgradeExecution, WorkflowStub pinnedExecution) {
+ // Signal both workflows a few times to drive them
+ for (int i = 0; i < 3; i++) {
+ autoUpgradeExecution.signal("doNextSignal", "do-activity");
+ pinnedExecution.signal("doNextSignal", "some-signal");
+ }
+ }
+
+ private static void waitForWorkerAndMakeCurrent(
+ WorkflowClient client, WorkflowServiceStubs service, String buildId)
+ throws InterruptedException {
+ WorkerDeploymentVersion targetVersion = new WorkerDeploymentVersion(DEPLOYMENT_NAME, buildId);
+
+ // Wait for the worker to appear
+ while (true) {
+ try {
+ DescribeWorkerDeploymentRequest describeRequest =
+ DescribeWorkerDeploymentRequest.newBuilder()
+ .setNamespace(client.getOptions().getNamespace())
+ .setDeploymentName(DEPLOYMENT_NAME)
+ .build();
+
+ DescribeWorkerDeploymentResponse response =
+ service.blockingStub().describeWorkerDeployment(describeRequest);
+
+ // Check if our version is present in the version summaries
+ boolean found =
+ response.getWorkerDeploymentInfo().getVersionSummariesList().stream()
+ .anyMatch(
+ versionSummary ->
+ targetVersion
+ .getDeploymentName()
+ .equals(versionSummary.getDeploymentVersion().getDeploymentName())
+ && targetVersion
+ .getBuildId()
+ .equals(versionSummary.getDeploymentVersion().getBuildId()));
+
+ if (found) {
+ break;
+ }
+ } catch (Exception ignored) {
+ System.out.println();
+ }
+ Thread.sleep(1000);
+ }
+
+ // Once the version is available, set it as current
+ SetWorkerDeploymentCurrentVersionRequest setRequest =
+ SetWorkerDeploymentCurrentVersionRequest.newBuilder()
+ .setNamespace(client.getOptions().getNamespace())
+ .setDeploymentName(DEPLOYMENT_NAME)
+ .setBuildId(targetVersion.getBuildId())
+ .build();
+
+ service.blockingStub().setWorkerDeploymentCurrentVersion(setRequest);
+ }
+}
diff --git a/core/src/main/java/io/temporal/samples/workerversioning/WorkerV1.java b/core/src/main/java/io/temporal/samples/workerversioning/WorkerV1.java
new file mode 100644
index 000000000..42ff216e0
--- /dev/null
+++ b/core/src/main/java/io/temporal/samples/workerversioning/WorkerV1.java
@@ -0,0 +1,49 @@
+package io.temporal.samples.workerversioning;
+
+import io.temporal.client.WorkflowClient;
+import io.temporal.common.WorkerDeploymentVersion;
+import io.temporal.envconfig.ClientConfigProfile;
+import io.temporal.serviceclient.WorkflowServiceStubs;
+import io.temporal.worker.Worker;
+import io.temporal.worker.WorkerDeploymentOptions;
+import io.temporal.worker.WorkerFactory;
+import io.temporal.worker.WorkerOptions;
+import java.io.IOException;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class WorkerV1 {
+
+ private static final Logger logger = LoggerFactory.getLogger(WorkerV1.class);
+
+ public static void main(String[] args) {
+ // Load configuration from environment and files
+ ClientConfigProfile profile;
+ try {
+ profile = ClientConfigProfile.load();
+ } catch (IOException e) {
+ throw new RuntimeException("Failed to load client configuration", e);
+ }
+
+ WorkflowServiceStubs service =
+ WorkflowServiceStubs.newServiceStubs(profile.toWorkflowServiceStubsOptions());
+ WorkflowClient client = WorkflowClient.newInstance(service, profile.toWorkflowClientOptions());
+
+ WorkerDeploymentVersion version = new WorkerDeploymentVersion(Starter.DEPLOYMENT_NAME, "1.0");
+ WorkerDeploymentOptions deploymentOptions =
+ WorkerDeploymentOptions.newBuilder().setUseVersioning(true).setVersion(version).build();
+
+ WorkerOptions workerOptions =
+ WorkerOptions.newBuilder().setDeploymentOptions(deploymentOptions).build();
+
+ WorkerFactory factory = WorkerFactory.newInstance(client);
+ Worker worker = factory.newWorker(Starter.TASK_QUEUE, workerOptions);
+
+ worker.registerWorkflowImplementationTypes(
+ AutoUpgradingWorkflowV1Impl.class, PinnedWorkflowV1Impl.class);
+ worker.registerActivitiesImplementations(new ActivitiesImpl());
+
+ logger.info("Starting worker v1 (build 1.0)");
+ factory.start();
+ }
+}
diff --git a/core/src/main/java/io/temporal/samples/workerversioning/WorkerV1_1.java b/core/src/main/java/io/temporal/samples/workerversioning/WorkerV1_1.java
new file mode 100644
index 000000000..76ec8e278
--- /dev/null
+++ b/core/src/main/java/io/temporal/samples/workerversioning/WorkerV1_1.java
@@ -0,0 +1,49 @@
+package io.temporal.samples.workerversioning;
+
+import io.temporal.client.WorkflowClient;
+import io.temporal.common.WorkerDeploymentVersion;
+import io.temporal.envconfig.ClientConfigProfile;
+import io.temporal.serviceclient.WorkflowServiceStubs;
+import io.temporal.worker.Worker;
+import io.temporal.worker.WorkerDeploymentOptions;
+import io.temporal.worker.WorkerFactory;
+import io.temporal.worker.WorkerOptions;
+import java.io.IOException;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class WorkerV1_1 {
+
+ private static final Logger logger = LoggerFactory.getLogger(WorkerV1_1.class);
+
+ public static void main(String[] args) {
+ // Load configuration from environment and files
+ ClientConfigProfile profile;
+ try {
+ profile = ClientConfigProfile.load();
+ } catch (IOException e) {
+ throw new RuntimeException("Failed to load client configuration", e);
+ }
+
+ WorkflowServiceStubs service =
+ WorkflowServiceStubs.newServiceStubs(profile.toWorkflowServiceStubsOptions());
+ WorkflowClient client = WorkflowClient.newInstance(service, profile.toWorkflowClientOptions());
+
+ WorkerDeploymentVersion version = new WorkerDeploymentVersion(Starter.DEPLOYMENT_NAME, "1.1");
+ WorkerDeploymentOptions deploymentOptions =
+ WorkerDeploymentOptions.newBuilder().setUseVersioning(true).setVersion(version).build();
+
+ WorkerOptions workerOptions =
+ WorkerOptions.newBuilder().setDeploymentOptions(deploymentOptions).build();
+
+ WorkerFactory factory = WorkerFactory.newInstance(client);
+ Worker worker = factory.newWorker(Starter.TASK_QUEUE, workerOptions);
+
+ worker.registerWorkflowImplementationTypes(
+ AutoUpgradingWorkflowV1bImpl.class, PinnedWorkflowV1Impl.class);
+ worker.registerActivitiesImplementations(new ActivitiesImpl());
+
+ logger.info("Starting worker v1.1 (build 1.1)");
+ factory.start();
+ }
+}
diff --git a/core/src/main/java/io/temporal/samples/workerversioning/WorkerV2.java b/core/src/main/java/io/temporal/samples/workerversioning/WorkerV2.java
new file mode 100644
index 000000000..2c436a2dd
--- /dev/null
+++ b/core/src/main/java/io/temporal/samples/workerversioning/WorkerV2.java
@@ -0,0 +1,49 @@
+package io.temporal.samples.workerversioning;
+
+import io.temporal.client.WorkflowClient;
+import io.temporal.common.WorkerDeploymentVersion;
+import io.temporal.envconfig.ClientConfigProfile;
+import io.temporal.serviceclient.WorkflowServiceStubs;
+import io.temporal.worker.Worker;
+import io.temporal.worker.WorkerDeploymentOptions;
+import io.temporal.worker.WorkerFactory;
+import io.temporal.worker.WorkerOptions;
+import java.io.IOException;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class WorkerV2 {
+
+ private static final Logger logger = LoggerFactory.getLogger(WorkerV2.class);
+
+ public static void main(String[] args) {
+ // Load configuration from environment and files
+ ClientConfigProfile profile;
+ try {
+ profile = ClientConfigProfile.load();
+ } catch (IOException e) {
+ throw new RuntimeException("Failed to load client configuration", e);
+ }
+
+ WorkflowServiceStubs service =
+ WorkflowServiceStubs.newServiceStubs(profile.toWorkflowServiceStubsOptions());
+ WorkflowClient client = WorkflowClient.newInstance(service, profile.toWorkflowClientOptions());
+
+ WorkerDeploymentVersion version = new WorkerDeploymentVersion(Starter.DEPLOYMENT_NAME, "2.0");
+ WorkerDeploymentOptions deploymentOptions =
+ WorkerDeploymentOptions.newBuilder().setUseVersioning(true).setVersion(version).build();
+
+ WorkerOptions workerOptions =
+ WorkerOptions.newBuilder().setDeploymentOptions(deploymentOptions).build();
+
+ WorkerFactory factory = WorkerFactory.newInstance(client);
+ Worker worker = factory.newWorker(Starter.TASK_QUEUE, workerOptions);
+
+ worker.registerWorkflowImplementationTypes(
+ AutoUpgradingWorkflowV1bImpl.class, PinnedWorkflowV2Impl.class);
+ worker.registerActivitiesImplementations(new ActivitiesImpl());
+
+ logger.info("Starting worker v2 (build 2.0)");
+ factory.start();
+ }
+}
diff --git a/core/src/main/resources/config.toml b/core/src/main/resources/config.toml
new file mode 100644
index 000000000..81f07f786
--- /dev/null
+++ b/core/src/main/resources/config.toml
@@ -0,0 +1,40 @@
+# This is a sample configuration file for demonstrating Temporal's environment
+# configuration feature. It defines multiple profiles for different environments,
+# such as local development, production, and staging.
+
+# Default profile for local development
+[profile.default]
+address = "localhost:7233"
+namespace = "default"
+
+# Optional: Add custom gRPC headers
+[profile.default.grpc_meta]
+my-custom-header = "development-value"
+trace-id = "dev-trace-123"
+
+# Staging profile with inline certificate data
+[profile.staging]
+address = "localhost:9999"
+namespace = "staging"
+
+# An example production profile for Temporal Cloud
+[profile.prod]
+address = "your-namespace.a1b2c.tmprl.cloud:7233"
+namespace = "your-namespace"
+# Replace with your actual Temporal Cloud API key
+api_key = "your-api-key-here"
+
+# TLS configuration for production
+[profile.prod.tls]
+# TLS is auto-enabled when an API key is present, but you can configure it
+# explicitly.
+# disabled = false
+
+# Use certificate files for mTLS. Replace with actual paths.
+client_cert_path = "/etc/temporal/certs/client.pem"
+client_key_path = "/etc/temporal/certs/client.key"
+
+# Custom headers for production
+[profile.prod.grpc_meta]
+environment = "production"
+service-version = "v1.2.3"
\ No newline at end of file
diff --git a/core/src/test/java/io/temporal/samples/asyncchild/AsyncChildTest.java b/core/src/test/java/io/temporal/samples/asyncchild/AsyncChildTest.java
index ef899fa20..f827cec9d 100644
--- a/core/src/test/java/io/temporal/samples/asyncchild/AsyncChildTest.java
+++ b/core/src/test/java/io/temporal/samples/asyncchild/AsyncChildTest.java
@@ -1,22 +1,3 @@
-/*
- * Copyright (c) 2020 Temporal Technologies, Inc. All Rights Reserved
- *
- * Copyright 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
- * Modifications copyright (C) 2017 Uber Technologies, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"). You may not
- * use this file except in compliance with the License. A copy of the License is
- * located at
- *
- * http://aws.amazon.com/apache2.0
- *
- * or in the "license" file accompanying this file. This file is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
package io.temporal.samples.asyncchild;
import static org.junit.Assert.assertNotNull;
diff --git a/core/src/test/java/io/temporal/samples/asyncuntypedchild/AsyncUntypedChildTest.java b/core/src/test/java/io/temporal/samples/asyncuntypedchild/AsyncUntypedChildTest.java
index 12281dbcf..8740d23a1 100644
--- a/core/src/test/java/io/temporal/samples/asyncuntypedchild/AsyncUntypedChildTest.java
+++ b/core/src/test/java/io/temporal/samples/asyncuntypedchild/AsyncUntypedChildTest.java
@@ -1,22 +1,3 @@
-/*
- * Copyright (c) 2020 Temporal Technologies, Inc. All Rights Reserved
- *
- * Copyright 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
- * Modifications copyright (C) 2017 Uber Technologies, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"). You may not
- * use this file except in compliance with the License. A copy of the License is
- * located at
- *
- * http://aws.amazon.com/apache2.0
- *
- * or in the "license" file accompanying this file. This file is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
package io.temporal.samples.asyncuntypedchild;
import static io.temporal.api.enums.v1.WorkflowExecutionStatus.WORKFLOW_EXECUTION_STATUS_RUNNING;
diff --git a/core/src/test/java/io/temporal/samples/batch/heartbeatingactivity/HeartbeatingActivityBatchWorkflowTest.java b/core/src/test/java/io/temporal/samples/batch/heartbeatingactivity/HeartbeatingActivityBatchWorkflowTest.java
index 1de5d5360..f9a7fa309 100644
--- a/core/src/test/java/io/temporal/samples/batch/heartbeatingactivity/HeartbeatingActivityBatchWorkflowTest.java
+++ b/core/src/test/java/io/temporal/samples/batch/heartbeatingactivity/HeartbeatingActivityBatchWorkflowTest.java
@@ -1,22 +1,3 @@
-/*
- * Copyright (c) 2020 Temporal Technologies, Inc. All Rights Reserved
- *
- * Copyright 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
- * Modifications copyright (C) 2017 Uber Technologies, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"). You may not
- * use this file except in compliance with the License. A copy of the License is
- * located at
- *
- * http://aws.amazon.com/apache2.0
- *
- * or in the "license" file accompanying this file. This file is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
package io.temporal.samples.batch.heartbeatingactivity;
import static io.temporal.samples.batch.heartbeatingactivity.RecordLoaderImpl.RECORD_COUNT;
diff --git a/core/src/test/java/io/temporal/samples/batch/iterator/IteratorIteratorBatchWorkflowTest.java b/core/src/test/java/io/temporal/samples/batch/iterator/IteratorIteratorBatchWorkflowTest.java
index 91cae65b7..12ff30b3b 100644
--- a/core/src/test/java/io/temporal/samples/batch/iterator/IteratorIteratorBatchWorkflowTest.java
+++ b/core/src/test/java/io/temporal/samples/batch/iterator/IteratorIteratorBatchWorkflowTest.java
@@ -1,22 +1,3 @@
-/*
- * Copyright (c) 2020 Temporal Technologies, Inc. All Rights Reserved
- *
- * Copyright 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
- * Modifications copyright (C) 2017 Uber Technologies, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"). You may not
- * use this file except in compliance with the License. A copy of the License is
- * located at
- *
- * http://aws.amazon.com/apache2.0
- *
- * or in the "license" file accompanying this file. This file is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
package io.temporal.samples.batch.iterator;
import static io.temporal.samples.batch.iterator.RecordLoaderImpl.PAGE_COUNT;
diff --git a/core/src/test/java/io/temporal/samples/batch/slidingwindow/SlidingWindowBatchWorkflowTest.java b/core/src/test/java/io/temporal/samples/batch/slidingwindow/SlidingWindowBatchWorkflowTest.java
index ae48290e2..5104d3739 100644
--- a/core/src/test/java/io/temporal/samples/batch/slidingwindow/SlidingWindowBatchWorkflowTest.java
+++ b/core/src/test/java/io/temporal/samples/batch/slidingwindow/SlidingWindowBatchWorkflowTest.java
@@ -1,22 +1,3 @@
-/*
- * Copyright (c) 2020 Temporal Technologies, Inc. All Rights Reserved
- *
- * Copyright 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
- * Modifications copyright (C) 2017 Uber Technologies, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"). You may not
- * use this file except in compliance with the License. A copy of the License is
- * located at
- *
- * http://aws.amazon.com/apache2.0
- *
- * or in the "license" file accompanying this file. This file is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
package io.temporal.samples.batch.slidingwindow;
import static org.junit.Assert.assertTrue;
diff --git a/core/src/test/java/io/temporal/samples/bookingsaga/TripBookingWorkflowTest.java b/core/src/test/java/io/temporal/samples/bookingsaga/TripBookingWorkflowTest.java
index 7a2d2cca6..a15f3de6e 100644
--- a/core/src/test/java/io/temporal/samples/bookingsaga/TripBookingWorkflowTest.java
+++ b/core/src/test/java/io/temporal/samples/bookingsaga/TripBookingWorkflowTest.java
@@ -1,22 +1,3 @@
-/*
- * Copyright (c) 2020 Temporal Technologies, Inc. All Rights Reserved
- *
- * Copyright 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
- * Modifications copyright (C) 2017 Uber Technologies, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"). You may not
- * use this file except in compliance with the License. A copy of the License is
- * located at
- *
- * http://aws.amazon.com/apache2.0
- *
- * or in the "license" file accompanying this file. This file is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
package io.temporal.samples.bookingsaga;
import static org.junit.jupiter.api.Assertions.assertEquals;
diff --git a/core/src/test/java/io/temporal/samples/bookingsyncsaga/TripBookingWorkflowTest.java b/core/src/test/java/io/temporal/samples/bookingsyncsaga/TripBookingWorkflowTest.java
index 8a170c169..5f2431e2c 100644
--- a/core/src/test/java/io/temporal/samples/bookingsyncsaga/TripBookingWorkflowTest.java
+++ b/core/src/test/java/io/temporal/samples/bookingsyncsaga/TripBookingWorkflowTest.java
@@ -1,22 +1,3 @@
-/*
- * Copyright (c) 2020 Temporal Technologies, Inc. All Rights Reserved
- *
- * Copyright 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
- * Modifications copyright (C) 2017 Uber Technologies, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"). You may not
- * use this file except in compliance with the License. A copy of the License is
- * located at
- *
- * http://aws.amazon.com/apache2.0
- *
- * or in the "license" file accompanying this file. This file is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
package io.temporal.samples.bookingsyncsaga;
import static org.junit.jupiter.api.Assertions.assertThrows;
diff --git a/core/src/test/java/io/temporal/samples/countinterceptor/ClientCountInterceptorTest.java b/core/src/test/java/io/temporal/samples/countinterceptor/ClientCountInterceptorTest.java
index 4ec530a4c..28369109d 100644
--- a/core/src/test/java/io/temporal/samples/countinterceptor/ClientCountInterceptorTest.java
+++ b/core/src/test/java/io/temporal/samples/countinterceptor/ClientCountInterceptorTest.java
@@ -1,22 +1,3 @@
-/*
- * Copyright (c) 2020 Temporal Technologies, Inc. All Rights Reserved
- *
- * Copyright 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
- * Modifications copyright (C) 2017 Uber Technologies, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"). You may not
- * use this file except in compliance with the License. A copy of the License is
- * located at
- *
- * http://aws.amazon.com/apache2.0
- *
- * or in the "license" file accompanying this file. This file is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
package io.temporal.samples.countinterceptor;
import static org.junit.Assert.assertEquals;
diff --git a/core/src/test/java/io/temporal/samples/countinterceptor/WorkerCountInterceptorTest.java b/core/src/test/java/io/temporal/samples/countinterceptor/WorkerCountInterceptorTest.java
index 4ec0f90d4..80a3184d2 100644
--- a/core/src/test/java/io/temporal/samples/countinterceptor/WorkerCountInterceptorTest.java
+++ b/core/src/test/java/io/temporal/samples/countinterceptor/WorkerCountInterceptorTest.java
@@ -1,22 +1,3 @@
-/*
- * Copyright (c) 2020 Temporal Technologies, Inc. All Rights Reserved
- *
- * Copyright 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
- * Modifications copyright (C) 2017 Uber Technologies, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"). You may not
- * use this file except in compliance with the License. A copy of the License is
- * located at
- *
- * http://aws.amazon.com/apache2.0
- *
- * or in the "license" file accompanying this file. This file is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
package io.temporal.samples.countinterceptor;
import static org.junit.Assert.*;
diff --git a/core/src/test/java/io/temporal/samples/dsl/DslWorkflowTest.java b/core/src/test/java/io/temporal/samples/dsl/DslWorkflowTest.java
index 808504a3f..1affc9bdb 100644
--- a/core/src/test/java/io/temporal/samples/dsl/DslWorkflowTest.java
+++ b/core/src/test/java/io/temporal/samples/dsl/DslWorkflowTest.java
@@ -1,22 +1,3 @@
-/*
- * Copyright (c) 2020 Temporal Technologies, Inc. All Rights Reserved
- *
- * Copyright 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
- * Modifications copyright (C) 2017 Uber Technologies, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"). You may not
- * use this file except in compliance with the License. A copy of the License is
- * located at
- *
- * http://aws.amazon.com/apache2.0
- *
- * or in the "license" file accompanying this file. This file is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
package io.temporal.samples.dsl;
import static org.junit.Assert.*;
diff --git a/core/src/test/java/io/temporal/samples/earlyreturn/TransactionWorkflowTest.java b/core/src/test/java/io/temporal/samples/earlyreturn/TransactionWorkflowTest.java
index 97cda3583..fe4a27964 100644
--- a/core/src/test/java/io/temporal/samples/earlyreturn/TransactionWorkflowTest.java
+++ b/core/src/test/java/io/temporal/samples/earlyreturn/TransactionWorkflowTest.java
@@ -1,22 +1,3 @@
-/*
- * Copyright (c) 2020 Temporal Technologies, Inc. All Rights Reserved
- *
- * Copyright 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
- * Modifications copyright (C) 2017 Uber Technologies, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"). You may not
- * use this file except in compliance with the License. A copy of the License is
- * located at
- *
- * http://aws.amazon.com/apache2.0
- *
- * or in the "license" file accompanying this file. This file is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
package io.temporal.samples.earlyreturn;
import static org.junit.Assert.*;
diff --git a/core/src/test/java/io/temporal/samples/encodefailures/EncodeFailuresTest.java b/core/src/test/java/io/temporal/samples/encodefailures/EncodeFailuresTest.java
index cb0514134..9c365decf 100644
--- a/core/src/test/java/io/temporal/samples/encodefailures/EncodeFailuresTest.java
+++ b/core/src/test/java/io/temporal/samples/encodefailures/EncodeFailuresTest.java
@@ -1,22 +1,3 @@
-/*
- * Copyright (c) 2020 Temporal Technologies, Inc. All Rights Reserved
- *
- * Copyright 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
- * Modifications copyright (C) 2017 Uber Technologies, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"). You may not
- * use this file except in compliance with the License. A copy of the License is
- * located at
- *
- * http://aws.amazon.com/apache2.0
- *
- * or in the "license" file accompanying this file. This file is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
package io.temporal.samples.encodefailures;
import static org.junit.Assert.assertThrows;
diff --git a/core/src/test/java/io/temporal/samples/excludefrominterceptor/ExcludeFromInterceptorTest.java b/core/src/test/java/io/temporal/samples/excludefrominterceptor/ExcludeFromInterceptorTest.java
index d77b6e41c..3405fb9fc 100644
--- a/core/src/test/java/io/temporal/samples/excludefrominterceptor/ExcludeFromInterceptorTest.java
+++ b/core/src/test/java/io/temporal/samples/excludefrominterceptor/ExcludeFromInterceptorTest.java
@@ -1,22 +1,3 @@
-/*
- * Copyright (c) 2020 Temporal Technologies, Inc. All Rights Reserved
- *
- * Copyright 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
- * Modifications copyright (C) 2017 Uber Technologies, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"). You may not
- * use this file except in compliance with the License. A copy of the License is
- * located at
- *
- * http://aws.amazon.com/apache2.0
- *
- * or in the "license" file accompanying this file. This file is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
package io.temporal.samples.excludefrominterceptor;
import io.temporal.api.enums.v1.EventType;
diff --git a/core/src/test/java/io/temporal/samples/fileprocessing/FileProcessingTest.java b/core/src/test/java/io/temporal/samples/fileprocessing/FileProcessingTest.java
index 1166bf875..16f3cb0f2 100644
--- a/core/src/test/java/io/temporal/samples/fileprocessing/FileProcessingTest.java
+++ b/core/src/test/java/io/temporal/samples/fileprocessing/FileProcessingTest.java
@@ -1,22 +1,3 @@
-/*
- * Copyright (c) 2020 Temporal Technologies, Inc. All Rights Reserved
- *
- * Copyright 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
- * Modifications copyright (C) 2017 Uber Technologies, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"). You may not
- * use this file except in compliance with the License. A copy of the License is
- * located at
- *
- * http://aws.amazon.com/apache2.0
- *
- * or in the "license" file accompanying this file. This file is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
package io.temporal.samples.fileprocessing;
import static org.mockito.ArgumentMatchers.any;
diff --git a/core/src/test/java/io/temporal/samples/getresultsasync/GetResultsAsyncTest.java b/core/src/test/java/io/temporal/samples/getresultsasync/GetResultsAsyncTest.java
index fe54b1884..b03a84df8 100644
--- a/core/src/test/java/io/temporal/samples/getresultsasync/GetResultsAsyncTest.java
+++ b/core/src/test/java/io/temporal/samples/getresultsasync/GetResultsAsyncTest.java
@@ -1,22 +1,3 @@
-/*
- * Copyright (c) 2020 Temporal Technologies, Inc. All Rights Reserved
- *
- * Copyright 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
- * Modifications copyright (C) 2017 Uber Technologies, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"). You may not
- * use this file except in compliance with the License. A copy of the License is
- * located at
- *
- * http://aws.amazon.com/apache2.0
- *
- * or in the "license" file accompanying this file. This file is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
package io.temporal.samples.getresultsasync;
import static org.junit.Assert.assertEquals;
diff --git a/core/src/test/java/io/temporal/samples/hello/HelloAccumulatorTest.java b/core/src/test/java/io/temporal/samples/hello/HelloAccumulatorTest.java
index 53477bbd7..1ae96970f 100644
--- a/core/src/test/java/io/temporal/samples/hello/HelloAccumulatorTest.java
+++ b/core/src/test/java/io/temporal/samples/hello/HelloAccumulatorTest.java
@@ -1,22 +1,3 @@
-/*
- * Copyright (c) 2020 Temporal Technologies, Inc. All Rights Reserved
- *
- * Copyright 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
- * Modifications copyright (C) 2017 Uber Technologies, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"). You may not
- * use this file except in compliance with the License. A copy of the License is
- * located at
- *
- * http://aws.amazon.com/apache2.0
- *
- * or in the "license" file accompanying this file. This file is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
package io.temporal.samples.hello;
import static io.temporal.samples.hello.HelloAccumulator.MAX_AWAIT_TIME;
diff --git a/core/src/test/java/io/temporal/samples/hello/HelloActivityExclusiveChoiceJUnit5Test.java b/core/src/test/java/io/temporal/samples/hello/HelloActivityExclusiveChoiceJUnit5Test.java
index 0a25cd7fc..59395ddf4 100644
--- a/core/src/test/java/io/temporal/samples/hello/HelloActivityExclusiveChoiceJUnit5Test.java
+++ b/core/src/test/java/io/temporal/samples/hello/HelloActivityExclusiveChoiceJUnit5Test.java
@@ -1,22 +1,3 @@
-/*
- * Copyright (c) 2020 Temporal Technologies, Inc. All Rights Reserved
- *
- * Copyright 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
- * Modifications copyright (C) 2017 Uber Technologies, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"). You may not
- * use this file except in compliance with the License. A copy of the License is
- * located at
- *
- * http://aws.amazon.com/apache2.0
- *
- * or in the "license" file accompanying this file. This file is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
package io.temporal.samples.hello;
import static org.junit.jupiter.api.Assertions.assertEquals;
diff --git a/core/src/test/java/io/temporal/samples/hello/HelloActivityExclusiveChoiceTest.java b/core/src/test/java/io/temporal/samples/hello/HelloActivityExclusiveChoiceTest.java
index 1549fd6e4..b57bca885 100644
--- a/core/src/test/java/io/temporal/samples/hello/HelloActivityExclusiveChoiceTest.java
+++ b/core/src/test/java/io/temporal/samples/hello/HelloActivityExclusiveChoiceTest.java
@@ -1,22 +1,3 @@
-/*
- * Copyright (c) 2020 Temporal Technologies, Inc. All Rights Reserved
- *
- * Copyright 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
- * Modifications copyright (C) 2017 Uber Technologies, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"). You may not
- * use this file except in compliance with the License. A copy of the License is
- * located at
- *
- * http://aws.amazon.com/apache2.0
- *
- * or in the "license" file accompanying this file. This file is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
package io.temporal.samples.hello;
import static io.temporal.samples.hello.HelloActivityExclusiveChoice.WORKFLOW_ID;
diff --git a/core/src/test/java/io/temporal/samples/hello/HelloActivityJUnit5Test.java b/core/src/test/java/io/temporal/samples/hello/HelloActivityJUnit5Test.java
index 88dcc3a5e..4efd978db 100644
--- a/core/src/test/java/io/temporal/samples/hello/HelloActivityJUnit5Test.java
+++ b/core/src/test/java/io/temporal/samples/hello/HelloActivityJUnit5Test.java
@@ -1,22 +1,3 @@
-/*
- * Copyright (c) 2020 Temporal Technologies, Inc. All Rights Reserved
- *
- * Copyright 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
- * Modifications copyright (C) 2017 Uber Technologies, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"). You may not
- * use this file except in compliance with the License. A copy of the License is
- * located at
- *
- * http://aws.amazon.com/apache2.0
- *
- * or in the "license" file accompanying this file. This file is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
package io.temporal.samples.hello;
import static org.junit.jupiter.api.Assertions.assertEquals;
diff --git a/core/src/test/java/io/temporal/samples/hello/HelloActivityReplayTest.java b/core/src/test/java/io/temporal/samples/hello/HelloActivityReplayTest.java
index 977d41708..0b859d217 100644
--- a/core/src/test/java/io/temporal/samples/hello/HelloActivityReplayTest.java
+++ b/core/src/test/java/io/temporal/samples/hello/HelloActivityReplayTest.java
@@ -1,22 +1,3 @@
-/*
- * Copyright (c) 2020 Temporal Technologies, Inc. All Rights Reserved
- *
- * Copyright 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
- * Modifications copyright (C) 2017 Uber Technologies, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"). You may not
- * use this file except in compliance with the License. A copy of the License is
- * located at
- *
- * http://aws.amazon.com/apache2.0
- *
- * or in the "license" file accompanying this file. This file is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
package io.temporal.samples.hello;
import static org.hamcrest.MatcherAssert.assertThat;
diff --git a/core/src/test/java/io/temporal/samples/hello/HelloActivityRetryTest.java b/core/src/test/java/io/temporal/samples/hello/HelloActivityRetryTest.java
index bd7645899..434ec41fa 100644
--- a/core/src/test/java/io/temporal/samples/hello/HelloActivityRetryTest.java
+++ b/core/src/test/java/io/temporal/samples/hello/HelloActivityRetryTest.java
@@ -1,22 +1,3 @@
-/*
- * Copyright (c) 2020 Temporal Technologies, Inc. All Rights Reserved
- *
- * Copyright 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
- * Modifications copyright (C) 2017 Uber Technologies, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"). You may not
- * use this file except in compliance with the License. A copy of the License is
- * located at
- *
- * http://aws.amazon.com/apache2.0
- *
- * or in the "license" file accompanying this file. This file is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
package io.temporal.samples.hello;
import static org.junit.Assert.assertEquals;
diff --git a/core/src/test/java/io/temporal/samples/hello/HelloActivityTest.java b/core/src/test/java/io/temporal/samples/hello/HelloActivityTest.java
index 506f2d75e..93f20e9d0 100644
--- a/core/src/test/java/io/temporal/samples/hello/HelloActivityTest.java
+++ b/core/src/test/java/io/temporal/samples/hello/HelloActivityTest.java
@@ -1,22 +1,3 @@
-/*
- * Copyright (c) 2020 Temporal Technologies, Inc. All Rights Reserved
- *
- * Copyright 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
- * Modifications copyright (C) 2017 Uber Technologies, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"). You may not
- * use this file except in compliance with the License. A copy of the License is
- * located at
- *
- * http://aws.amazon.com/apache2.0
- *
- * or in the "license" file accompanying this file. This file is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
package io.temporal.samples.hello;
import static org.junit.Assert.assertEquals;
diff --git a/core/src/test/java/io/temporal/samples/hello/HelloAsyncActivityCompletionTest.java b/core/src/test/java/io/temporal/samples/hello/HelloAsyncActivityCompletionTest.java
index 314cf0647..bdb90e2dd 100644
--- a/core/src/test/java/io/temporal/samples/hello/HelloAsyncActivityCompletionTest.java
+++ b/core/src/test/java/io/temporal/samples/hello/HelloAsyncActivityCompletionTest.java
@@ -1,22 +1,3 @@
-/*
- * Copyright (c) 2020 Temporal Technologies, Inc. All Rights Reserved
- *
- * Copyright 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
- * Modifications copyright (C) 2017 Uber Technologies, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"). You may not
- * use this file except in compliance with the License. A copy of the License is
- * located at
- *
- * http://aws.amazon.com/apache2.0
- *
- * or in the "license" file accompanying this file. This file is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
package io.temporal.samples.hello;
import static org.junit.Assert.assertEquals;
diff --git a/core/src/test/java/io/temporal/samples/hello/HelloAsyncLambdaTest.java b/core/src/test/java/io/temporal/samples/hello/HelloAsyncLambdaTest.java
index 48ec3142d..455a014ec 100644
--- a/core/src/test/java/io/temporal/samples/hello/HelloAsyncLambdaTest.java
+++ b/core/src/test/java/io/temporal/samples/hello/HelloAsyncLambdaTest.java
@@ -1,22 +1,3 @@
-/*
- * Copyright (c) 2020 Temporal Technologies, Inc. All Rights Reserved
- *
- * Copyright 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
- * Modifications copyright (C) 2017 Uber Technologies, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"). You may not
- * use this file except in compliance with the License. A copy of the License is
- * located at
- *
- * http://aws.amazon.com/apache2.0
- *
- * or in the "license" file accompanying this file. This file is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
package io.temporal.samples.hello;
import static org.junit.Assert.assertEquals;
diff --git a/core/src/test/java/io/temporal/samples/hello/HelloAsyncTest.java b/core/src/test/java/io/temporal/samples/hello/HelloAsyncTest.java
index 892e4c58f..1c6c13239 100644
--- a/core/src/test/java/io/temporal/samples/hello/HelloAsyncTest.java
+++ b/core/src/test/java/io/temporal/samples/hello/HelloAsyncTest.java
@@ -1,22 +1,3 @@
-/*
- * Copyright (c) 2020 Temporal Technologies, Inc. All Rights Reserved
- *
- * Copyright 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
- * Modifications copyright (C) 2017 Uber Technologies, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"). You may not
- * use this file except in compliance with the License. A copy of the License is
- * located at
- *
- * http://aws.amazon.com/apache2.0
- *
- * or in the "license" file accompanying this file. This file is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
package io.temporal.samples.hello;
import static org.junit.Assert.assertEquals;
diff --git a/core/src/test/java/io/temporal/samples/hello/HelloAwaitTest.java b/core/src/test/java/io/temporal/samples/hello/HelloAwaitTest.java
index 1912a942d..9e319eaaf 100644
--- a/core/src/test/java/io/temporal/samples/hello/HelloAwaitTest.java
+++ b/core/src/test/java/io/temporal/samples/hello/HelloAwaitTest.java
@@ -1,22 +1,3 @@
-/*
- * Copyright (c) 2020 Temporal Technologies, Inc. All Rights Reserved
- *
- * Copyright 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
- * Modifications copyright (C) 2017 Uber Technologies, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"). You may not
- * use this file except in compliance with the License. A copy of the License is
- * located at
- *
- * http://aws.amazon.com/apache2.0
- *
- * or in the "license" file accompanying this file. This file is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
package io.temporal.samples.hello;
import static org.junit.Assert.assertEquals;
diff --git a/core/src/test/java/io/temporal/samples/hello/HelloCancellationScopeTest.java b/core/src/test/java/io/temporal/samples/hello/HelloCancellationScopeTest.java
index 1af296fa8..c77e69b28 100644
--- a/core/src/test/java/io/temporal/samples/hello/HelloCancellationScopeTest.java
+++ b/core/src/test/java/io/temporal/samples/hello/HelloCancellationScopeTest.java
@@ -1,22 +1,3 @@
-/*
- * Copyright (c) 2020 Temporal Technologies, Inc. All Rights Reserved
- *
- * Copyright 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
- * Modifications copyright (C) 2017 Uber Technologies, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"). You may not
- * use this file except in compliance with the License. A copy of the License is
- * located at
- *
- * http://aws.amazon.com/apache2.0
- *
- * or in the "license" file accompanying this file. This file is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
package io.temporal.samples.hello;
import static org.junit.Assert.assertTrue;
diff --git a/core/src/test/java/io/temporal/samples/hello/HelloCancellationScopeWithTimerTest.java b/core/src/test/java/io/temporal/samples/hello/HelloCancellationScopeWithTimerTest.java
index 4c6e2bd79..73600c785 100644
--- a/core/src/test/java/io/temporal/samples/hello/HelloCancellationScopeWithTimerTest.java
+++ b/core/src/test/java/io/temporal/samples/hello/HelloCancellationScopeWithTimerTest.java
@@ -1,22 +1,3 @@
-/*
- * Copyright (c) 2020 Temporal Technologies, Inc. All Rights Reserved
- *
- * Copyright 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
- * Modifications copyright (C) 2017 Uber Technologies, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"). You may not
- * use this file except in compliance with the License. A copy of the License is
- * located at
- *
- * http://aws.amazon.com/apache2.0
- *
- * or in the "license" file accompanying this file. This file is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
package io.temporal.samples.hello;
import static org.junit.Assert.assertTrue;
diff --git a/core/src/test/java/io/temporal/samples/hello/HelloChildJUnit5Test.java b/core/src/test/java/io/temporal/samples/hello/HelloChildJUnit5Test.java
index 7330120e5..63f87a7d0 100644
--- a/core/src/test/java/io/temporal/samples/hello/HelloChildJUnit5Test.java
+++ b/core/src/test/java/io/temporal/samples/hello/HelloChildJUnit5Test.java
@@ -1,22 +1,3 @@
-/*
- * Copyright (c) 2020 Temporal Technologies, Inc. All Rights Reserved
- *
- * Copyright 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
- * Modifications copyright (C) 2017 Uber Technologies, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"). You may not
- * use this file except in compliance with the License. A copy of the License is
- * located at
- *
- * http://aws.amazon.com/apache2.0
- *
- * or in the "license" file accompanying this file. This file is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
package io.temporal.samples.hello;
import static org.mockito.Mockito.*;
diff --git a/core/src/test/java/io/temporal/samples/hello/HelloChildTest.java b/core/src/test/java/io/temporal/samples/hello/HelloChildTest.java
index 829f4aa10..1603fc7bb 100644
--- a/core/src/test/java/io/temporal/samples/hello/HelloChildTest.java
+++ b/core/src/test/java/io/temporal/samples/hello/HelloChildTest.java
@@ -1,22 +1,3 @@
-/*
- * Copyright (c) 2020 Temporal Technologies, Inc. All Rights Reserved
- *
- * Copyright 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
- * Modifications copyright (C) 2017 Uber Technologies, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"). You may not
- * use this file except in compliance with the License. A copy of the License is
- * located at
- *
- * http://aws.amazon.com/apache2.0
- *
- * or in the "license" file accompanying this file. This file is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
package io.temporal.samples.hello;
import static org.junit.Assert.assertEquals;
diff --git a/core/src/test/java/io/temporal/samples/hello/HelloCronTest.java b/core/src/test/java/io/temporal/samples/hello/HelloCronTest.java
index 26e69a570..02ebd266a 100644
--- a/core/src/test/java/io/temporal/samples/hello/HelloCronTest.java
+++ b/core/src/test/java/io/temporal/samples/hello/HelloCronTest.java
@@ -1,22 +1,3 @@
-/*
- * Copyright (c) 2020 Temporal Technologies, Inc. All Rights Reserved
- *
- * Copyright 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
- * Modifications copyright (C) 2017 Uber Technologies, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"). You may not
- * use this file except in compliance with the License. A copy of the License is
- * located at
- *
- * http://aws.amazon.com/apache2.0
- *
- * or in the "license" file accompanying this file. This file is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
package io.temporal.samples.hello;
import static io.temporal.samples.hello.HelloCron.WORKFLOW_ID;
diff --git a/core/src/test/java/io/temporal/samples/hello/HelloDelayedStartTest.java b/core/src/test/java/io/temporal/samples/hello/HelloDelayedStartTest.java
index 273b351e8..c9f552af1 100644
--- a/core/src/test/java/io/temporal/samples/hello/HelloDelayedStartTest.java
+++ b/core/src/test/java/io/temporal/samples/hello/HelloDelayedStartTest.java
@@ -1,22 +1,3 @@
-/*
- * Copyright (c) 2020 Temporal Technologies, Inc. All Rights Reserved
- *
- * Copyright 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
- * Modifications copyright (C) 2017 Uber Technologies, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"). You may not
- * use this file except in compliance with the License. A copy of the License is
- * located at
- *
- * http://aws.amazon.com/apache2.0
- *
- * or in the "license" file accompanying this file. This file is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
package io.temporal.samples.hello;
import static org.junit.Assert.assertEquals;
diff --git a/core/src/test/java/io/temporal/samples/hello/HelloDetachedCancellationScopeTest.java b/core/src/test/java/io/temporal/samples/hello/HelloDetachedCancellationScopeTest.java
index 3c1395afb..5ce8acc4b 100644
--- a/core/src/test/java/io/temporal/samples/hello/HelloDetachedCancellationScopeTest.java
+++ b/core/src/test/java/io/temporal/samples/hello/HelloDetachedCancellationScopeTest.java
@@ -1,22 +1,3 @@
-/*
- * Copyright (c) 2020 Temporal Technologies, Inc. All Rights Reserved
- *
- * Copyright 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
- * Modifications copyright (C) 2017 Uber Technologies, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"). You may not
- * use this file except in compliance with the License. A copy of the License is
- * located at
- *
- * http://aws.amazon.com/apache2.0
- *
- * or in the "license" file accompanying this file. This file is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
package io.temporal.samples.hello;
import static org.junit.Assert.assertEquals;
diff --git a/core/src/test/java/io/temporal/samples/hello/HelloDynamicActivityJUnit5Test.java b/core/src/test/java/io/temporal/samples/hello/HelloDynamicActivityJUnit5Test.java
index afae8a43d..f3639116c 100644
--- a/core/src/test/java/io/temporal/samples/hello/HelloDynamicActivityJUnit5Test.java
+++ b/core/src/test/java/io/temporal/samples/hello/HelloDynamicActivityJUnit5Test.java
@@ -1,22 +1,3 @@
-/*
- * Copyright (c) 2020 Temporal Technologies, Inc. All Rights Reserved
- *
- * Copyright 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
- * Modifications copyright (C) 2017 Uber Technologies, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"). You may not
- * use this file except in compliance with the License. A copy of the License is
- * located at
- *
- * http://aws.amazon.com/apache2.0
- *
- * or in the "license" file accompanying this file. This file is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
package io.temporal.samples.hello;
import static org.junit.jupiter.api.Assertions.assertEquals;
diff --git a/core/src/test/java/io/temporal/samples/hello/HelloDynamicTest.java b/core/src/test/java/io/temporal/samples/hello/HelloDynamicTest.java
index 96e3513b9..4ec529ed0 100644
--- a/core/src/test/java/io/temporal/samples/hello/HelloDynamicTest.java
+++ b/core/src/test/java/io/temporal/samples/hello/HelloDynamicTest.java
@@ -1,22 +1,3 @@
-/*
- * Copyright (c) 2020 Temporal Technologies, Inc. All Rights Reserved
- *
- * Copyright 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
- * Modifications copyright (C) 2017 Uber Technologies, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"). You may not
- * use this file except in compliance with the License. A copy of the License is
- * located at
- *
- * http://aws.amazon.com/apache2.0
- *
- * or in the "license" file accompanying this file. This file is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
package io.temporal.samples.hello;
import static org.junit.Assert.*;
diff --git a/core/src/test/java/io/temporal/samples/hello/HelloEagerWorkflowStartTest.java b/core/src/test/java/io/temporal/samples/hello/HelloEagerWorkflowStartTest.java
index 563d23824..da20545ae 100644
--- a/core/src/test/java/io/temporal/samples/hello/HelloEagerWorkflowStartTest.java
+++ b/core/src/test/java/io/temporal/samples/hello/HelloEagerWorkflowStartTest.java
@@ -1,22 +1,3 @@
-/*
- * Copyright (c) 2020 Temporal Technologies, Inc. All Rights Reserved
- *
- * Copyright 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
- * Modifications copyright (C) 2017 Uber Technologies, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"). You may not
- * use this file except in compliance with the License. A copy of the License is
- * located at
- *
- * http://aws.amazon.com/apache2.0
- *
- * or in the "license" file accompanying this file. This file is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
package io.temporal.samples.hello;
import static org.junit.Assert.assertEquals;
diff --git a/core/src/test/java/io/temporal/samples/hello/HelloExceptionTest.java b/core/src/test/java/io/temporal/samples/hello/HelloExceptionTest.java
index 7fef3c8b1..2a8108a66 100644
--- a/core/src/test/java/io/temporal/samples/hello/HelloExceptionTest.java
+++ b/core/src/test/java/io/temporal/samples/hello/HelloExceptionTest.java
@@ -1,22 +1,3 @@
-/*
- * Copyright (c) 2020 Temporal Technologies, Inc. All Rights Reserved
- *
- * Copyright 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
- * Modifications copyright (C) 2017 Uber Technologies, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"). You may not
- * use this file except in compliance with the License. A copy of the License is
- * located at
- *
- * http://aws.amazon.com/apache2.0
- *
- * or in the "license" file accompanying this file. This file is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
package io.temporal.samples.hello;
import static org.junit.Assert.assertEquals;
diff --git a/core/src/test/java/io/temporal/samples/hello/HelloLocalActivityTest.java b/core/src/test/java/io/temporal/samples/hello/HelloLocalActivityTest.java
index a2a756117..4e15ad296 100644
--- a/core/src/test/java/io/temporal/samples/hello/HelloLocalActivityTest.java
+++ b/core/src/test/java/io/temporal/samples/hello/HelloLocalActivityTest.java
@@ -1,22 +1,3 @@
-/*
- * Copyright (c) 2020 Temporal Technologies, Inc. All Rights Reserved
- *
- * Copyright 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
- * Modifications copyright (C) 2017 Uber Technologies, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"). You may not
- * use this file except in compliance with the License. A copy of the License is
- * located at
- *
- * http://aws.amazon.com/apache2.0
- *
- * or in the "license" file accompanying this file. This file is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
package io.temporal.samples.hello;
import static org.junit.Assert.assertEquals;
diff --git a/core/src/test/java/io/temporal/samples/hello/HelloParallelActivityTest.java b/core/src/test/java/io/temporal/samples/hello/HelloParallelActivityTest.java
index 52656f0e8..7ee1d5703 100644
--- a/core/src/test/java/io/temporal/samples/hello/HelloParallelActivityTest.java
+++ b/core/src/test/java/io/temporal/samples/hello/HelloParallelActivityTest.java
@@ -1,22 +1,3 @@
-/*
- * Copyright (c) 2020 Temporal Technologies, Inc. All Rights Reserved
- *
- * Copyright 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
- * Modifications copyright (C) 2017 Uber Technologies, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"). You may not
- * use this file except in compliance with the License. A copy of the License is
- * located at
- *
- * http://aws.amazon.com/apache2.0
- *
- * or in the "license" file accompanying this file. This file is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
package io.temporal.samples.hello;
import static org.junit.Assert.assertEquals;
diff --git a/core/src/test/java/io/temporal/samples/hello/HelloPeriodicTest.java b/core/src/test/java/io/temporal/samples/hello/HelloPeriodicTest.java
index 7d6cc1144..ed9eeeecc 100644
--- a/core/src/test/java/io/temporal/samples/hello/HelloPeriodicTest.java
+++ b/core/src/test/java/io/temporal/samples/hello/HelloPeriodicTest.java
@@ -1,22 +1,3 @@
-/*
- * Copyright (c) 2020 Temporal Technologies, Inc. All Rights Reserved
- *
- * Copyright 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
- * Modifications copyright (C) 2017 Uber Technologies, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"). You may not
- * use this file except in compliance with the License. A copy of the License is
- * located at
- *
- * http://aws.amazon.com/apache2.0
- *
- * or in the "license" file accompanying this file. This file is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
package io.temporal.samples.hello;
import static io.temporal.samples.hello.HelloPeriodic.*;
diff --git a/core/src/test/java/io/temporal/samples/hello/HelloPolymorphicActivityTest.java b/core/src/test/java/io/temporal/samples/hello/HelloPolymorphicActivityTest.java
index 250fd8528..ecedb9172 100644
--- a/core/src/test/java/io/temporal/samples/hello/HelloPolymorphicActivityTest.java
+++ b/core/src/test/java/io/temporal/samples/hello/HelloPolymorphicActivityTest.java
@@ -1,22 +1,3 @@
-/*
- * Copyright (c) 2020 Temporal Technologies, Inc. All Rights Reserved
- *
- * Copyright 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
- * Modifications copyright (C) 2017 Uber Technologies, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"). You may not
- * use this file except in compliance with the License. A copy of the License is
- * located at
- *
- * http://aws.amazon.com/apache2.0
- *
- * or in the "license" file accompanying this file. This file is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
package io.temporal.samples.hello;
import static org.junit.Assert.assertEquals;
diff --git a/core/src/test/java/io/temporal/samples/hello/HelloQueryTest.java b/core/src/test/java/io/temporal/samples/hello/HelloQueryTest.java
index e226bc4d0..2c7980326 100644
--- a/core/src/test/java/io/temporal/samples/hello/HelloQueryTest.java
+++ b/core/src/test/java/io/temporal/samples/hello/HelloQueryTest.java
@@ -1,22 +1,3 @@
-/*
- * Copyright (c) 2020 Temporal Technologies, Inc. All Rights Reserved
- *
- * Copyright 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
- * Modifications copyright (C) 2017 Uber Technologies, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"). You may not
- * use this file except in compliance with the License. A copy of the License is
- * located at
- *
- * http://aws.amazon.com/apache2.0
- *
- * or in the "license" file accompanying this file. This file is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
package io.temporal.samples.hello;
import static org.junit.Assert.assertEquals;
diff --git a/core/src/test/java/io/temporal/samples/hello/HelloSearchAttributesTest.java b/core/src/test/java/io/temporal/samples/hello/HelloSearchAttributesTest.java
index 40fd62264..b1bacd2c6 100644
--- a/core/src/test/java/io/temporal/samples/hello/HelloSearchAttributesTest.java
+++ b/core/src/test/java/io/temporal/samples/hello/HelloSearchAttributesTest.java
@@ -1,22 +1,3 @@
-/*
- * Copyright (c) 2020 Temporal Technologies, Inc. All Rights Reserved
- *
- * Copyright 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
- * Modifications copyright (C) 2017 Uber Technologies, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"). You may not
- * use this file except in compliance with the License. A copy of the License is
- * located at
- *
- * http://aws.amazon.com/apache2.0
- *
- * or in the "license" file accompanying this file. This file is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
package io.temporal.samples.hello;
import static io.temporal.samples.hello.HelloSearchAttributes.getKeywordFromSearchAttribute;
diff --git a/core/src/test/java/io/temporal/samples/hello/HelloSideEffectTest.java b/core/src/test/java/io/temporal/samples/hello/HelloSideEffectTest.java
index 4672492e2..59ac0d396 100644
--- a/core/src/test/java/io/temporal/samples/hello/HelloSideEffectTest.java
+++ b/core/src/test/java/io/temporal/samples/hello/HelloSideEffectTest.java
@@ -1,22 +1,3 @@
-/*
- * Copyright (c) 2020 Temporal Technologies, Inc. All Rights Reserved
- *
- * Copyright 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
- * Modifications copyright (C) 2017 Uber Technologies, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"). You may not
- * use this file except in compliance with the License. A copy of the License is
- * located at
- *
- * http://aws.amazon.com/apache2.0
- *
- * or in the "license" file accompanying this file. This file is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
package io.temporal.samples.hello;
import static org.junit.Assert.assertEquals;
diff --git a/core/src/test/java/io/temporal/samples/hello/HelloSignalTest.java b/core/src/test/java/io/temporal/samples/hello/HelloSignalTest.java
index 89676c024..de674fcae 100644
--- a/core/src/test/java/io/temporal/samples/hello/HelloSignalTest.java
+++ b/core/src/test/java/io/temporal/samples/hello/HelloSignalTest.java
@@ -1,22 +1,3 @@
-/*
- * Copyright (c) 2020 Temporal Technologies, Inc. All Rights Reserved
- *
- * Copyright 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
- * Modifications copyright (C) 2017 Uber Technologies, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"). You may not
- * use this file except in compliance with the License. A copy of the License is
- * located at
- *
- * http://aws.amazon.com/apache2.0
- *
- * or in the "license" file accompanying this file. This file is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
package io.temporal.samples.hello;
import static org.junit.Assert.assertEquals;
diff --git a/core/src/test/java/io/temporal/samples/hello/HelloSignalWithStartAndWorkflowInitTest.java b/core/src/test/java/io/temporal/samples/hello/HelloSignalWithStartAndWorkflowInitTest.java
new file mode 100644
index 000000000..210967b28
--- /dev/null
+++ b/core/src/test/java/io/temporal/samples/hello/HelloSignalWithStartAndWorkflowInitTest.java
@@ -0,0 +1,76 @@
+package io.temporal.samples.hello;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.fail;
+
+import io.temporal.client.WorkflowFailedException;
+import io.temporal.client.WorkflowOptions;
+import io.temporal.client.WorkflowStub;
+import io.temporal.testing.TestWorkflowEnvironment;
+import io.temporal.testing.TestWorkflowExtension;
+import io.temporal.worker.Worker;
+import io.temporal.worker.WorkflowImplementationOptions;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.RegisterExtension;
+
+public class HelloSignalWithStartAndWorkflowInitTest {
+ @RegisterExtension
+ public static final TestWorkflowExtension testWorkflowExtension =
+ TestWorkflowExtension.newBuilder()
+ .registerWorkflowImplementationTypes(
+ HelloSignalWithStartAndWorkflowInit.WithInitMyWorkflowImpl.class)
+ .registerWorkflowImplementationTypes(
+ WorkflowImplementationOptions.newBuilder()
+ .setFailWorkflowExceptionTypes(NullPointerException.class)
+ .build(),
+ HelloSignalWithStartAndWorkflowInit.WithoutInitMyWorkflowImpl.class)
+ .setActivityImplementations(
+ new HelloSignalWithStartAndWorkflowInit.MyGreetingActivitiesImpl())
+ .build();
+
+ @Test
+ public void testWithInit(TestWorkflowEnvironment testEnv, Worker worker) {
+ HelloSignalWithStartAndWorkflowInit.MyWorkflowWithInit withInitStub =
+ testEnv
+ .getWorkflowClient()
+ .newWorkflowStub(
+ HelloSignalWithStartAndWorkflowInit.MyWorkflowWithInit.class,
+ WorkflowOptions.newBuilder()
+ .setWorkflowId("with-init")
+ .setTaskQueue(worker.getTaskQueue())
+ .build());
+ WorkflowStub.fromTyped(withInitStub)
+ .signalWithStart(
+ "addGreeting",
+ new Object[] {new HelloSignalWithStartAndWorkflowInit.Person("Michael", "Jordan", 55)},
+ new Object[] {new HelloSignalWithStartAndWorkflowInit.Person("John", "Stockton", 57)});
+ String result = WorkflowStub.fromTyped(withInitStub).getResult(String.class);
+ assertEquals("Hello Michael Jordan,Hello John Stockton", result);
+ }
+
+ @Test
+ public void testWithoutInit(TestWorkflowEnvironment testEnv, Worker worker) {
+ HelloSignalWithStartAndWorkflowInit.MyWorkflowNoInit noInitStub =
+ testEnv
+ .getWorkflowClient()
+ .newWorkflowStub(
+ HelloSignalWithStartAndWorkflowInit.MyWorkflowNoInit.class,
+ WorkflowOptions.newBuilder()
+ .setWorkflowId("without-init")
+ .setTaskQueue(worker.getTaskQueue())
+ .build());
+ WorkflowStub.fromTyped(noInitStub)
+ .signalWithStart(
+ "addGreeting",
+ new Object[] {new HelloSignalWithStartAndWorkflowInit.Person("Michael", "Jordan", 55)},
+ new Object[] {new HelloSignalWithStartAndWorkflowInit.Person("John", "Stockton", 57)});
+ try {
+ WorkflowStub.fromTyped(noInitStub).getResult(String.class);
+ fail("Workflow execution should have failed");
+ } catch (Exception e) {
+ if (!(e instanceof WorkflowFailedException)) {
+ fail("Workflow execution should have failed with WorkflowFailedException");
+ }
+ }
+ }
+}
diff --git a/core/src/test/java/io/temporal/samples/hello/HelloSignalWithTimerTest.java b/core/src/test/java/io/temporal/samples/hello/HelloSignalWithTimerTest.java
index c65fec165..dbf0578a0 100644
--- a/core/src/test/java/io/temporal/samples/hello/HelloSignalWithTimerTest.java
+++ b/core/src/test/java/io/temporal/samples/hello/HelloSignalWithTimerTest.java
@@ -1,22 +1,3 @@
-/*
- * Copyright (c) 2020 Temporal Technologies, Inc. All Rights Reserved
- *
- * Copyright 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
- * Modifications copyright (C) 2017 Uber Technologies, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"). You may not
- * use this file except in compliance with the License. A copy of the License is
- * located at
- *
- * http://aws.amazon.com/apache2.0
- *
- * or in the "license" file accompanying this file. This file is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
package io.temporal.samples.hello;
import io.temporal.api.common.v1.WorkflowExecution;
diff --git a/core/src/test/java/io/temporal/samples/hello/HelloUpdateAndCancellationTest.java b/core/src/test/java/io/temporal/samples/hello/HelloUpdateAndCancellationTest.java
new file mode 100644
index 000000000..b6eec1fec
--- /dev/null
+++ b/core/src/test/java/io/temporal/samples/hello/HelloUpdateAndCancellationTest.java
@@ -0,0 +1,210 @@
+package io.temporal.samples.hello;
+
+import io.temporal.activity.*;
+import io.temporal.api.enums.v1.WorkflowIdConflictPolicy;
+import io.temporal.client.*;
+import io.temporal.failure.ActivityFailure;
+import io.temporal.failure.CanceledFailure;
+import io.temporal.testing.TestWorkflowRule;
+import io.temporal.workflow.*;
+import java.time.Duration;
+import java.util.concurrent.TimeUnit;
+import org.junit.Assert;
+import org.junit.Rule;
+import org.junit.Test;
+
+public class HelloUpdateAndCancellationTest {
+ @Rule
+ public TestWorkflowRule testWorkflowRule =
+ TestWorkflowRule.newBuilder()
+ .setWorkflowTypes(TestWorkflowImpl.class)
+ .setActivityImplementations(new TestActivitiesImpl())
+ .build();
+
+ @Test
+ public void testUpdateAndWorkflowCancellation() {
+ // Start workflow with UpdateWithStart then cancel workflow before activity completes
+ TestWorkflow workflow =
+ testWorkflowRule
+ .getWorkflowClient()
+ .newWorkflowStub(
+ TestWorkflow.class,
+ WorkflowOptions.newBuilder()
+ .setWorkflowId("test-workflow-cancel")
+ .setTaskQueue(testWorkflowRule.getTaskQueue())
+ .setWorkflowIdConflictPolicy(
+ WorkflowIdConflictPolicy.WORKFLOW_ID_CONFLICT_POLICY_USE_EXISTING)
+ .build());
+
+ WorkflowUpdateHandle updateHandle =
+ WorkflowClient.startUpdateWithStart(
+ workflow::mileStoneCompleted,
+ UpdateOptions.newBuilder()
+ .setWaitForStage(WorkflowUpdateStage.ACCEPTED)
+ .build(),
+ new WithStartWorkflowOperation<>(workflow::execute));
+
+ testWorkflowRule
+ .getTestEnvironment()
+ .registerDelayedCallback(
+ Duration.ofSeconds(3),
+ () -> {
+ WorkflowStub.fromTyped(workflow).cancel("canceled by test");
+ });
+
+ String updateResult = updateHandle.getResult();
+ Assert.assertEquals("milestone canceled", updateResult);
+
+ try {
+ WorkflowStub.fromTyped(workflow).getResult(String.class);
+ Assert.fail("Workflow Execution should have been canceled");
+ } catch (WorkflowFailedException e) {
+ // Our workflow should have been canceled
+ Assert.assertEquals(CanceledFailure.class, e.getCause().getClass());
+ }
+ }
+
+ @Test
+ public void testUpdateAndActivityCancellation() {
+ // Start workflow with UpdateWithStart then cancel the activity only by sending signal to
+ // execution
+ TestWorkflow workflow =
+ testWorkflowRule
+ .getWorkflowClient()
+ .newWorkflowStub(
+ TestWorkflow.class,
+ WorkflowOptions.newBuilder()
+ .setWorkflowId("test-activity-cancel")
+ .setTaskQueue(testWorkflowRule.getTaskQueue())
+ .setWorkflowIdConflictPolicy(
+ WorkflowIdConflictPolicy.WORKFLOW_ID_CONFLICT_POLICY_USE_EXISTING)
+ .build());
+
+ WorkflowUpdateHandle updateHandle =
+ WorkflowClient.startUpdateWithStart(
+ workflow::mileStoneCompleted,
+ UpdateOptions.newBuilder()
+ .setWaitForStage(WorkflowUpdateStage.ACCEPTED)
+ .build(),
+ new WithStartWorkflowOperation<>(workflow::execute));
+
+ testWorkflowRule
+ .getTestEnvironment()
+ .registerDelayedCallback(
+ Duration.ofSeconds(3),
+ () -> {
+ WorkflowStub.fromTyped(workflow).signal("cancelActivity");
+ });
+
+ String updateResult = updateHandle.getResult();
+ Assert.assertEquals("milestone canceled", updateResult);
+
+ try {
+ WorkflowStub.fromTyped(workflow).getResult(String.class);
+ Assert.fail("Workflow Execution should have failed");
+ } catch (WorkflowFailedException e) {
+ // In this case we did not cancel workflow execution but we failed it by throwing
+ // ActivityFailure
+ Assert.assertEquals(ActivityFailure.class, e.getCause().getClass());
+ ActivityFailure af = (ActivityFailure) e.getCause();
+ // Since we canceled the activity still, the cause of ActivityFailure should be
+ // CanceledFailure
+ Assert.assertEquals(CanceledFailure.class, af.getCause().getClass());
+ }
+ }
+
+ @WorkflowInterface
+ public interface TestWorkflow {
+ @WorkflowMethod
+ String execute();
+
+ @UpdateMethod
+ String mileStoneCompleted();
+
+ @SignalMethod
+ void cancelActivity();
+ }
+
+ public static class TestWorkflowImpl implements TestWorkflow {
+ boolean milestoneDone, mileStoneCanceled;
+ CancellationScope scope;
+ TestActivities activities =
+ Workflow.newActivityStub(
+ TestActivities.class,
+ ActivityOptions.newBuilder()
+ .setHeartbeatTimeout(Duration.ofSeconds(3))
+ .setStartToCloseTimeout(Duration.ofSeconds(10))
+ .setCancellationType(ActivityCancellationType.WAIT_CANCELLATION_COMPLETED)
+ .build());
+
+ @Override
+ public String execute() {
+ scope =
+ Workflow.newCancellationScope(
+ () -> {
+ activities.runActivity();
+ });
+
+ try {
+ scope.run();
+ milestoneDone = true;
+ Workflow.await(Workflow::isEveryHandlerFinished);
+ return "workflow completed";
+ } catch (ActivityFailure e) {
+ if (e.getCause() instanceof CanceledFailure) {
+ CancellationScope detached =
+ Workflow.newDetachedCancellationScope(
+ () -> {
+ mileStoneCanceled = true;
+ Workflow.await(Workflow::isEveryHandlerFinished);
+ });
+ detached.run();
+ }
+ throw e;
+ }
+ }
+
+ @Override
+ public String mileStoneCompleted() {
+ Workflow.await(() -> milestoneDone || mileStoneCanceled);
+ // For sake of testing isEveryHandlerFinished block here for 2 seconds
+ Workflow.sleep(Duration.ofSeconds(2));
+ return milestoneDone ? "milestone completed" : "milestone canceled";
+ }
+
+ @Override
+ public void cancelActivity() {
+ if (scope != null) {
+ scope.cancel("test reason");
+ }
+ }
+ }
+
+ @ActivityInterface
+ public interface TestActivities {
+ void runActivity();
+ }
+
+ public static class TestActivitiesImpl implements TestActivities {
+
+ @Override
+ public void runActivity() {
+ ActivityExecutionContext context = Activity.getExecutionContext();
+ for (int i = 0; i < 9; i++) {
+ sleep(1);
+ try {
+ context.heartbeat(i);
+ } catch (ActivityCompletionException e) {
+ throw e;
+ }
+ }
+ }
+ }
+
+ private static void sleep(int seconds) {
+ try {
+ Thread.sleep(TimeUnit.SECONDS.toMillis(seconds));
+ } catch (InterruptedException e) {
+ }
+ }
+}
diff --git a/core/src/test/java/io/temporal/samples/hello/HelloUpdateTest.java b/core/src/test/java/io/temporal/samples/hello/HelloUpdateTest.java
index fb41b2dd5..6411181d5 100644
--- a/core/src/test/java/io/temporal/samples/hello/HelloUpdateTest.java
+++ b/core/src/test/java/io/temporal/samples/hello/HelloUpdateTest.java
@@ -1,22 +1,3 @@
-/*
- * Copyright (c) 2020 Temporal Technologies, Inc. All Rights Reserved
- *
- * Copyright 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
- * Modifications copyright (C) 2017 Uber Technologies, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"). You may not
- * use this file except in compliance with the License. A copy of the License is
- * located at
- *
- * http://aws.amazon.com/apache2.0
- *
- * or in the "license" file accompanying this file. This file is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
package io.temporal.samples.hello;
import static org.junit.Assert.assertEquals;
diff --git a/core/src/test/java/io/temporal/samples/hello/HelloWorkflowTimerTest.java b/core/src/test/java/io/temporal/samples/hello/HelloWorkflowTimerTest.java
index 7e0954494..77fbefcc7 100644
--- a/core/src/test/java/io/temporal/samples/hello/HelloWorkflowTimerTest.java
+++ b/core/src/test/java/io/temporal/samples/hello/HelloWorkflowTimerTest.java
@@ -1,22 +1,3 @@
-/*
- * Copyright (c) 2020 Temporal Technologies, Inc. All Rights Reserved
- *
- * Copyright 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
- * Modifications copyright (C) 2017 Uber Technologies, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"). You may not
- * use this file except in compliance with the License. A copy of the License is
- * located at
- *
- * http://aws.amazon.com/apache2.0
- *
- * or in the "license" file accompanying this file. This file is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
package io.temporal.samples.hello;
import io.temporal.client.WorkflowOptions;
diff --git a/core/src/test/java/io/temporal/samples/interceptorreplaytest/InterceptorReplayTest.java b/core/src/test/java/io/temporal/samples/interceptorreplaytest/InterceptorReplayTest.java
new file mode 100644
index 000000000..97ea42ec8
--- /dev/null
+++ b/core/src/test/java/io/temporal/samples/interceptorreplaytest/InterceptorReplayTest.java
@@ -0,0 +1,191 @@
+package io.temporal.samples.interceptorreplaytest;
+
+import static org.junit.Assert.fail;
+
+import io.temporal.activity.ActivityInterface;
+import io.temporal.activity.ActivityOptions;
+import io.temporal.client.WorkflowOptions;
+import io.temporal.common.WorkflowExecutionHistory;
+import io.temporal.common.interceptors.*;
+import io.temporal.testing.TestWorkflowEnvironment;
+import io.temporal.testing.TestWorkflowExtension;
+import io.temporal.testing.WorkflowReplayer;
+import io.temporal.worker.Worker;
+import io.temporal.worker.WorkerFactoryOptions;
+import io.temporal.workflow.Workflow;
+import io.temporal.workflow.WorkflowInterface;
+import io.temporal.workflow.WorkflowMethod;
+import java.time.Duration;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.RegisterExtension;
+
+public class InterceptorReplayTest {
+ @RegisterExtension
+ public static final TestWorkflowExtension testWorkflowExtension =
+ TestWorkflowExtension.newBuilder()
+ // Register workflow and activity impls
+ .registerWorkflowImplementationTypes(TestWorkflowImpl.class)
+ .setActivityImplementations(new TestActivitiesImpl())
+ // Register worker interceptor
+ .setWorkerFactoryOptions(
+ WorkerFactoryOptions.newBuilder()
+ .setWorkerInterceptors(new TestWorkerInterceptor())
+ .build())
+ .setDoNotStart(true)
+ .build();
+
+ @Test
+ public void testReplayWithInterceptors(TestWorkflowEnvironment testEnv, Worker worker) {
+ // Run our test workflow. We need to set workflow id so can get history after
+ testEnv.start();
+ TestWorkflow workflow =
+ testEnv
+ .getWorkflowClient()
+ .newWorkflowStub(
+ TestWorkflow.class,
+ WorkflowOptions.newBuilder()
+ .setWorkflowId("test-workflow")
+ .setTaskQueue(worker.getTaskQueue())
+ .build());
+ workflow.execute();
+
+ // Replay execution with history of just executed
+ WorkflowExecutionHistory eventHistory =
+ testEnv.getWorkflowClient().fetchHistory("test-workflow");
+
+ try {
+ WorkflowReplayer.replayWorkflowExecution(eventHistory, worker);
+ } catch (Exception e) {
+ fail(e.getMessage());
+ }
+ testEnv.shutdown();
+
+ // Try replaying execution with test env where we dont have interceptors registered
+ TestWorkflowEnvironment testEnv2 = TestWorkflowEnvironment.newInstance();
+ Worker testEnv2Worker = testEnv2.newWorker("test-taskqueue");
+ testEnv2Worker.registerWorkflowImplementationTypes(TestWorkflowImpl.class);
+ testEnv2Worker.registerActivitiesImplementations(new TestActivitiesImpl());
+
+ testEnv2.start();
+
+ // Replay should fail with worker that does not have interceptor registered
+ try {
+ WorkflowReplayer.replayWorkflowExecution(eventHistory, testEnv2Worker);
+ fail("This should have failed");
+ } catch (Exception e) {
+ System.out.println(e.getMessage());
+ }
+
+ // But it should be fine with worker that does
+ try {
+ WorkflowReplayer.replayWorkflowExecution(eventHistory, worker);
+ } catch (Exception e) {
+ fail(e.getMessage());
+ }
+
+ testEnv2.shutdown();
+ }
+
+ // Test workflow and activities
+ @WorkflowInterface
+ public interface TestWorkflow {
+ @WorkflowMethod
+ void execute();
+ }
+
+ public static class TestWorkflowImpl implements TestWorkflow {
+
+ TestActivities activities =
+ Workflow.newActivityStub(
+ TestActivities.class,
+ ActivityOptions.newBuilder().setStartToCloseTimeout(Duration.ofSeconds(2)).build());
+
+ @Override
+ public void execute() {
+ activities.activityOne();
+ }
+ }
+
+ @ActivityInterface
+ public interface TestActivities {
+ void activityOne();
+
+ void activityTwo();
+
+ void activityThree();
+ }
+
+ public static class TestActivitiesImpl implements TestActivities {
+ @Override
+ public void activityOne() {
+ System.out.println("Activities one done");
+ }
+
+ @Override
+ public void activityTwo() {
+ System.out.println("Activities two done");
+ }
+
+ @Override
+ public void activityThree() {
+ System.out.println("Activities three done");
+ }
+ }
+
+ // Test worker and workflow interceptors
+ public static class TestWorkerInterceptor extends WorkerInterceptorBase {
+ @Override
+ public WorkflowInboundCallsInterceptor interceptWorkflow(WorkflowInboundCallsInterceptor next) {
+ return new TestWorkflowInboundCallsInterceptor(next);
+ }
+ }
+
+ public static class TestWorkflowInboundCallsInterceptor
+ extends WorkflowInboundCallsInterceptorBase {
+ TestActivities activities =
+ Workflow.newActivityStub(
+ TestActivities.class,
+ ActivityOptions.newBuilder().setStartToCloseTimeout(Duration.ofSeconds(2)).build());
+
+ public TestWorkflowInboundCallsInterceptor(WorkflowInboundCallsInterceptor next) {
+ super(next);
+ }
+
+ @Override
+ public void init(WorkflowOutboundCallsInterceptor outboundCalls) {
+ super.init(new TestWorkflowOutboundCallsInterceptor(outboundCalls));
+ }
+
+ @Override
+ public WorkflowOutput execute(WorkflowInput input) {
+ WorkflowOutput output = super.execute(input);
+ // Run activity three before completing execution
+ activities.activityThree();
+ return output;
+ }
+ }
+
+ public static class TestWorkflowOutboundCallsInterceptor
+ extends WorkflowOutboundCallsInterceptorBase {
+ TestActivities activities =
+ Workflow.newActivityStub(
+ TestActivities.class,
+ ActivityOptions.newBuilder().setStartToCloseTimeout(Duration.ofSeconds(2)).build());
+
+ public TestWorkflowOutboundCallsInterceptor(WorkflowOutboundCallsInterceptor next) {
+ super(next);
+ }
+
+ @Override
+ public ActivityOutput executeActivity(ActivityInput input) {
+ ActivityOutput output = super.executeActivity(input);
+
+ // we only want to intercept ActivityOne here
+ if (input.getActivityName().equals("ActivityOne")) {
+ activities.activityTwo();
+ }
+
+ return output;
+ }
+ }
+}
diff --git a/core/src/test/java/io/temporal/samples/listworkflows/ListWorkflowsTest.java b/core/src/test/java/io/temporal/samples/listworkflows/ListWorkflowsTest.java
index f56cf3192..b7f7b66b1 100644
--- a/core/src/test/java/io/temporal/samples/listworkflows/ListWorkflowsTest.java
+++ b/core/src/test/java/io/temporal/samples/listworkflows/ListWorkflowsTest.java
@@ -1,22 +1,3 @@
-/*
- * Copyright (c) 2020 Temporal Technologies, Inc. All Rights Reserved
- *
- * Copyright 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
- * Modifications copyright (C) 2017 Uber Technologies, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"). You may not
- * use this file except in compliance with the License. A copy of the License is
- * located at
- *
- * http://aws.amazon.com/apache2.0
- *
- * or in the "license" file accompanying this file. This file is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
package io.temporal.samples.listworkflows;
import static org.junit.Assert.assertEquals;
diff --git a/core/src/test/java/io/temporal/samples/metrics/MetricsTest.java b/core/src/test/java/io/temporal/samples/metrics/MetricsTest.java
index 86b13b3b6..21a4be616 100644
--- a/core/src/test/java/io/temporal/samples/metrics/MetricsTest.java
+++ b/core/src/test/java/io/temporal/samples/metrics/MetricsTest.java
@@ -1,22 +1,3 @@
-/*
- * Copyright (c) 2020 Temporal Technologies, Inc. All Rights Reserved
- *
- * Copyright 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
- * Modifications copyright (C) 2017 Uber Technologies, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"). You may not
- * use this file except in compliance with the License. A copy of the License is
- * located at
- *
- * http://aws.amazon.com/apache2.0
- *
- * or in the "license" file accompanying this file. This file is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
package io.temporal.samples.metrics;
import static junit.framework.TestCase.assertEquals;
diff --git a/core/src/test/java/io/temporal/samples/moneybatch/TransferWorkflowTest.java b/core/src/test/java/io/temporal/samples/moneybatch/TransferWorkflowTest.java
index ffe5ca44b..282a2136e 100644
--- a/core/src/test/java/io/temporal/samples/moneybatch/TransferWorkflowTest.java
+++ b/core/src/test/java/io/temporal/samples/moneybatch/TransferWorkflowTest.java
@@ -1,22 +1,3 @@
-/*
- * Copyright (c) 2020 Temporal Technologies, Inc. All Rights Reserved
- *
- * Copyright 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
- * Modifications copyright (C) 2017 Uber Technologies, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"). You may not
- * use this file except in compliance with the License. A copy of the License is
- * located at
- *
- * http://aws.amazon.com/apache2.0
- *
- * or in the "license" file accompanying this file. This file is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
package io.temporal.samples.moneybatch;
import static org.mockito.ArgumentMatchers.any;
diff --git a/core/src/test/java/io/temporal/samples/moneytransfer/TransferWorkflowTest.java b/core/src/test/java/io/temporal/samples/moneytransfer/TransferWorkflowTest.java
index f69fea2b2..65b86daf6 100644
--- a/core/src/test/java/io/temporal/samples/moneytransfer/TransferWorkflowTest.java
+++ b/core/src/test/java/io/temporal/samples/moneytransfer/TransferWorkflowTest.java
@@ -1,22 +1,3 @@
-/*
- * Copyright (c) 2020 Temporal Technologies, Inc. All Rights Reserved
- *
- * Copyright 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
- * Modifications copyright (C) 2017 Uber Technologies, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"). You may not
- * use this file except in compliance with the License. A copy of the License is
- * located at
- *
- * http://aws.amazon.com/apache2.0
- *
- * or in the "license" file accompanying this file. This file is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
package io.temporal.samples.moneytransfer;
import static org.mockito.ArgumentMatchers.eq;
diff --git a/core/src/test/java/io/temporal/samples/nexus/caller/CallerWorkflowJunit5MockTest.java b/core/src/test/java/io/temporal/samples/nexus/caller/CallerWorkflowJunit5MockTest.java
new file mode 100644
index 000000000..2ba042308
--- /dev/null
+++ b/core/src/test/java/io/temporal/samples/nexus/caller/CallerWorkflowJunit5MockTest.java
@@ -0,0 +1,82 @@
+package io.temporal.samples.nexus.caller;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.mockito.Mockito.*;
+
+import io.temporal.samples.nexus.handler.EchoClient;
+import io.temporal.samples.nexus.handler.HelloHandlerWorkflow;
+import io.temporal.samples.nexus.handler.SampleNexusServiceImpl;
+import io.temporal.samples.nexus.service.SampleNexusService;
+import io.temporal.testing.TestWorkflowEnvironment;
+import io.temporal.testing.TestWorkflowExtension;
+import io.temporal.worker.Worker;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.RegisterExtension;
+
+// This is an example of how to unit test Nexus services in JUnit5. The handlers are mocked,
+// so that the caller classes interact with the mocks and not the handler classes themselves.
+
+// @@@SNIPSTART java-nexus-sample-junit5-mock
+public class CallerWorkflowJunit5MockTest {
+
+ // Sync Nexus operations run inline in the handler thread — there is no backing workflow to
+ // register a factory for. To mock one, inject a mock dependency into the service implementation.
+ private static final EchoClient mockEchoClient = mock(EchoClient.class);
+
+ @RegisterExtension
+ public static final TestWorkflowExtension testWorkflowExtension =
+ TestWorkflowExtension.newBuilder()
+ // If a Nexus service is registered as part of the test as in the following line of code,
+ // the TestWorkflowExtension will, by default, automatically create a Nexus service
+ // endpoint and workflows registered as part of the TestWorkflowExtension will
+ // automatically inherit the endpoint if none is set.
+ .setNexusServiceImplementation(new SampleNexusServiceImpl(mockEchoClient))
+ // The Echo Nexus handler service just makes a call to a class, so no extra setup is
+ // needed. But the Hello Nexus service needs a worker for both the caller and handler
+ // in order to run, and the Echo Nexus caller service needs a worker.
+ //
+ // registerWorkflowImplementationTypes will take the classes given and create workers for
+ // them, enabling workflows to run.
+ .registerWorkflowImplementationTypes(
+ HelloCallerWorkflowImpl.class, EchoCallerWorkflowImpl.class)
+ .setDoNotStart(true)
+ .build();
+
+ @Test
+ public void testHelloWorkflow(
+ TestWorkflowEnvironment testEnv, Worker worker, HelloCallerWorkflow workflow) {
+ // Workflows started by a Nexus service can be mocked just like any other workflow
+ worker.registerWorkflowImplementationFactory(
+ HelloHandlerWorkflow.class,
+ () -> {
+ HelloHandlerWorkflow mockHandler = mock(HelloHandlerWorkflow.class);
+ when(mockHandler.hello(any()))
+ .thenReturn(new SampleNexusService.HelloOutput("Hello Mock World 👋"));
+ return mockHandler;
+ });
+ testEnv.start();
+
+ // Execute a workflow waiting for it to complete.
+ String greeting = workflow.hello("World", SampleNexusService.Language.EN);
+ assertEquals("Hello Mock World 👋", greeting);
+
+ testEnv.shutdown();
+ }
+
+ @Test
+ public void testEchoWorkflow(
+ TestWorkflowEnvironment testEnv, Worker worker, EchoCallerWorkflow workflow) {
+ // Sync Nexus operations run inline in the handler thread — there is no backing workflow to
+ // register a factory for. Instead, stub the injected EchoClient dependency directly.
+ when(mockEchoClient.echo(any())).thenReturn(new SampleNexusService.EchoOutput("mocked echo"));
+ testEnv.start();
+
+ // Execute a workflow waiting for it to complete.
+ String greeting = workflow.echo("Hello");
+ assertEquals("mocked echo", greeting);
+
+ testEnv.shutdown();
+ }
+}
+
+// @@@SNIPEND
diff --git a/core/src/test/java/io/temporal/samples/nexus/caller/CallerWorkflowJunit5Test.java b/core/src/test/java/io/temporal/samples/nexus/caller/CallerWorkflowJunit5Test.java
new file mode 100644
index 000000000..3da730c14
--- /dev/null
+++ b/core/src/test/java/io/temporal/samples/nexus/caller/CallerWorkflowJunit5Test.java
@@ -0,0 +1,58 @@
+package io.temporal.samples.nexus.caller;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
+import io.temporal.samples.nexus.handler.HelloHandlerWorkflowImpl;
+import io.temporal.samples.nexus.handler.SampleNexusServiceImpl;
+import io.temporal.samples.nexus.service.SampleNexusService;
+import io.temporal.testing.TestWorkflowEnvironment;
+import io.temporal.testing.TestWorkflowExtension;
+import io.temporal.worker.Worker;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.RegisterExtension;
+
+// This is an example of how to unit test Nexus services in JUnit5. The handlers are not mocked,
+// but are actually called by the testing framework by the caller classes.
+
+public class CallerWorkflowJunit5Test {
+
+ @RegisterExtension
+ public static final TestWorkflowExtension testWorkflowExtension =
+ TestWorkflowExtension.newBuilder()
+ // If a Nexus service is registered as part of the test as in the following line of code,
+ // the TestWorkflowExtension will, by default, automatically create a Nexus service
+ // endpoint and workflows registered as part of the TestWorkflowExtension will
+ // automatically inherit the endpoint if none is set.
+ .setNexusServiceImplementation(new SampleNexusServiceImpl())
+ // The Echo Nexus handler service just makes a call to a class, so no extra setup is
+ // needed. But the Hello Nexus service needs a worker for both the caller and handler
+ // in order to run, and the Echo Nexus caller service needs a worker.
+ //
+ // registerWorkflowImplementationTypes will take the classes given and create workers for
+ // them, enabling workflows to run.
+ .registerWorkflowImplementationTypes(
+ HelloCallerWorkflowImpl.class,
+ HelloHandlerWorkflowImpl.class,
+ EchoCallerWorkflowImpl.class)
+ // The workflow will start before each test, and will shut down after each test.
+ // See CallerWorkflowTest for an example of how to control this differently if needed.
+ .build();
+
+ // The TestWorkflowExtension extension in the Temporal testing library creates the
+ // arguments to the test cases and initializes them from the extension setup call above.
+ @Test
+ public void testHelloWorkflow(
+ TestWorkflowEnvironment testEnv, Worker worker, HelloCallerWorkflow workflow) {
+ // Execute a workflow waiting for it to complete.
+ String greeting = workflow.hello("World", SampleNexusService.Language.EN);
+ assertEquals("Hello World 👋", greeting);
+ }
+
+ @Test
+ public void testEchoWorkflow(
+ TestWorkflowEnvironment testEnv, Worker worker, EchoCallerWorkflow workflow) {
+ // Execute a workflow waiting for it to complete.
+ String greeting = workflow.echo("Hello");
+ assertEquals("Hello", greeting);
+ }
+}
diff --git a/core/src/test/java/io/temporal/samples/nexus/caller/CallerWorkflowMockTest.java b/core/src/test/java/io/temporal/samples/nexus/caller/CallerWorkflowMockTest.java
new file mode 100644
index 000000000..d6b793ffe
--- /dev/null
+++ b/core/src/test/java/io/temporal/samples/nexus/caller/CallerWorkflowMockTest.java
@@ -0,0 +1,95 @@
+package io.temporal.samples.nexus.caller;
+
+import static org.junit.Assert.assertEquals;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+
+import io.temporal.client.WorkflowOptions;
+import io.temporal.samples.nexus.handler.EchoClient;
+import io.temporal.samples.nexus.handler.HelloHandlerWorkflow;
+import io.temporal.samples.nexus.handler.SampleNexusServiceImpl;
+import io.temporal.samples.nexus.service.SampleNexusService;
+import io.temporal.testing.TestWorkflowRule;
+import org.junit.Rule;
+import org.junit.Test;
+
+// This is an example of how to unit test Nexus services in JUnit4. The handlers are mocked,
+// so that the caller classes interact with the mocks and not the handler classes themselves.
+
+// @@@SNIPSTART java-nexus-sample-junit4-mock
+public class CallerWorkflowMockTest {
+
+ // Inject a mock EchoClient so sync Nexus operations can be stubbed per test.
+ // JUnit 4 creates a new test class instance per test method, so this mock is fresh each time.
+ private final EchoClient mockEchoClient = mock(EchoClient.class);
+
+ @Rule
+ public TestWorkflowRule testWorkflowRule =
+ TestWorkflowRule.newBuilder()
+ // If a Nexus service is registered as part of the test as in the following line of code,
+ // the TestWorkflowRule will, by default, automatically create a Nexus service endpoint
+ // and workflows registered as part of the TestWorkflowRule
+ // will automatically inherit the endpoint if none is set.
+ .setNexusServiceImplementation(new SampleNexusServiceImpl(mockEchoClient))
+ // The Echo Nexus handler service just makes a call to a class, so no extra setup is
+ // needed. But the Hello Nexus service needs a worker for both the caller and handler
+ // in order to run.
+ // setWorkflowTypes will take the classes given and create workers for them, enabling
+ // workflows to run. This creates caller workflows, the handler workflows
+ // will be mocked in the test methods.
+ .setWorkflowTypes(HelloCallerWorkflowImpl.class, EchoCallerWorkflowImpl.class)
+ // Disable automatic worker startup as we are going to register some workflows manually
+ // per test
+ .setDoNotStart(true)
+ .build();
+
+ @Test
+ public void testHelloWorkflow() {
+ testWorkflowRule
+ .getWorker()
+ // Workflows started by a Nexus service can be mocked just like any other workflow
+ .registerWorkflowImplementationFactory(
+ HelloHandlerWorkflow.class,
+ () -> {
+ HelloHandlerWorkflow wf = mock(HelloHandlerWorkflow.class);
+ when(wf.hello(any()))
+ .thenReturn(new SampleNexusService.HelloOutput("Hello Mock World 👋"));
+ return wf;
+ });
+ testWorkflowRule.getTestEnvironment().start();
+
+ // Now create the caller workflow
+ HelloCallerWorkflow workflow =
+ testWorkflowRule
+ .getWorkflowClient()
+ .newWorkflowStub(
+ HelloCallerWorkflow.class,
+ WorkflowOptions.newBuilder().setTaskQueue(testWorkflowRule.getTaskQueue()).build());
+ String greeting = workflow.hello("World", SampleNexusService.Language.EN);
+ assertEquals("Hello Mock World 👋", greeting);
+
+ testWorkflowRule.getTestEnvironment().shutdown();
+ }
+
+ @Test
+ public void testEchoWorkflow() {
+ // Sync Nexus operations run inline in the handler thread — there is no backing workflow to
+ // register a factory for. Instead, stub the injected EchoCient dependency directly.
+ when(mockEchoClient.echo(any())).thenReturn(new SampleNexusService.EchoOutput("mocked echo"));
+ testWorkflowRule.getTestEnvironment().start();
+
+ EchoCallerWorkflow workflow =
+ testWorkflowRule
+ .getWorkflowClient()
+ .newWorkflowStub(
+ EchoCallerWorkflow.class,
+ WorkflowOptions.newBuilder().setTaskQueue(testWorkflowRule.getTaskQueue()).build());
+ String greeting = workflow.echo("Hello");
+ assertEquals("mocked echo", greeting);
+
+ testWorkflowRule.getTestEnvironment().shutdown();
+ }
+}
+
+// @@@SNIPEND
diff --git a/core/src/test/java/io/temporal/samples/nexus/caller/CallerWorkflowTest.java b/core/src/test/java/io/temporal/samples/nexus/caller/CallerWorkflowTest.java
index ba1bba461..682995e61 100644
--- a/core/src/test/java/io/temporal/samples/nexus/caller/CallerWorkflowTest.java
+++ b/core/src/test/java/io/temporal/samples/nexus/caller/CallerWorkflowTest.java
@@ -1,33 +1,11 @@
-/*
- * Copyright (c) 2020 Temporal Technologies, Inc. All Rights Reserved
- *
- * Copyright 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
- * Modifications copyright (C) 2017 Uber Technologies, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"). You may not
- * use this file except in compliance with the License. A copy of the License is
- * located at
- *
- * http://aws.amazon.com/apache2.0
- *
- * or in the "license" file accompanying this file. This file is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
package io.temporal.samples.nexus.caller;
import static org.junit.Assert.assertEquals;
-import static org.mockito.ArgumentMatchers.any;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.when;
import io.temporal.client.WorkflowOptions;
-import io.temporal.samples.nexus.handler.HelloHandlerWorkflow;
-import io.temporal.samples.nexus.handler.NexusServiceImpl;
-import io.temporal.samples.nexus.service.NexusService;
+import io.temporal.samples.nexus.handler.HelloHandlerWorkflowImpl;
+import io.temporal.samples.nexus.handler.SampleNexusServiceImpl;
+import io.temporal.samples.nexus.service.SampleNexusService;
import io.temporal.testing.TestWorkflowRule;
import io.temporal.worker.WorkflowImplementationOptions;
import io.temporal.workflow.NexusServiceOptions;
@@ -35,16 +13,27 @@
import org.junit.Rule;
import org.junit.Test;
+// This is an example of how to unit test Nexus services in JUnit4. The handlers are not mocked,
+// but are actually called by the testing framework by the caller classes.
+
public class CallerWorkflowTest {
@Rule
public TestWorkflowRule testWorkflowRule =
TestWorkflowRule.newBuilder()
- // If a Nexus service is registered as part of the test, the TestWorkflowRule will ,by
- // default, automatically create a Nexus service endpoint and workflows registered as part
- // of the TestWorkflowRule will automatically inherit the endpoint if none is set.
- .setNexusServiceImplementation(new NexusServiceImpl())
- .setWorkflowTypes(HelloCallerWorkflowImpl.class)
+ // If a Nexus service is registered as part of the test as in the following line of code,
+ // the TestWorkflowRule will, by default, automatically create a Nexus service endpoint
+ // and workflows registered as part of the TestWorkflowRule
+ // will automatically inherit the endpoint if none is set.
+ .setNexusServiceImplementation(new SampleNexusServiceImpl())
+ // The Echo Nexus handler service just makes a call to a class, so no extra setup is
+ // needed. But the Hello Nexus service needs a worker for both the caller and handler
+ // in order to run.
+ // setWorkflowTypes will take the classes given and create workers for them, enabling
+ // workflows to run. This is not adding an EchoCallerWorkflow though -
+ // see the testEchoWorkflow test method below for an example of an alternate way
+ // to supply a worker that gives you more flexibility if needed.
+ .setWorkflowTypes(HelloCallerWorkflowImpl.class, HelloHandlerWorkflowImpl.class)
// Disable automatic worker startup as we are going to register some workflows manually
// per test
.setDoNotStart(true)
@@ -52,16 +41,6 @@ public class CallerWorkflowTest {
@Test
public void testHelloWorkflow() {
- testWorkflowRule
- .getWorker()
- // Workflows started by a Nexus service can be mocked just like any other workflow
- .registerWorkflowImplementationFactory(
- HelloHandlerWorkflow.class,
- () -> {
- HelloHandlerWorkflow wf = mock(HelloHandlerWorkflow.class);
- when(wf.hello(any())).thenReturn(new NexusService.HelloOutput("Hello World 👋"));
- return wf;
- });
testWorkflowRule.getTestEnvironment().start();
HelloCallerWorkflow workflow =
@@ -70,7 +49,7 @@ public void testHelloWorkflow() {
.newWorkflowStub(
HelloCallerWorkflow.class,
WorkflowOptions.newBuilder().setTaskQueue(testWorkflowRule.getTaskQueue()).build());
- String greeting = workflow.hello("World", NexusService.Language.EN);
+ String greeting = workflow.hello("World", SampleNexusService.Language.EN);
assertEquals("Hello World 👋", greeting);
testWorkflowRule.getTestEnvironment().shutdown();
@@ -80,15 +59,20 @@ public void testHelloWorkflow() {
public void testEchoWorkflow() {
// If Workflows are registered later than the endpoint can be set manually
// either by setting the endpoint in the NexusServiceOptions in the Workflow implementation or
- // by setting the NexusServiceOptions on the WorkflowImplementationOptions when registering the
- // Workflow.
+ // by setting the NexusServiceOptions on the WorkflowImplementationOptions when registering
+ // the Workflow. To demonstrate, this is creating the Nexus service for Echo,
+ // and registering a EchoCallerWorkflowImpl worker.
+ //
+ // It is much simpler to use the setWorkflowTypes in the rule definition above - and as
+ // this isn't easily do-able in JUnit5 (the nexus endpoint isn't exposed) should be
+ // used with caution.
testWorkflowRule
.getWorker()
.registerWorkflowImplementationTypes(
WorkflowImplementationOptions.newBuilder()
.setNexusServiceOptions(
Collections.singletonMap(
- "NexusService",
+ "SampleNexusService",
NexusServiceOptions.newBuilder()
.setEndpoint(testWorkflowRule.getNexusEndpoint().getSpec().getName())
.build()))
diff --git a/core/src/test/java/io/temporal/samples/nexus/caller/NexusServiceJunit5Test.java b/core/src/test/java/io/temporal/samples/nexus/caller/NexusServiceJunit5Test.java
new file mode 100644
index 000000000..0b03b2d64
--- /dev/null
+++ b/core/src/test/java/io/temporal/samples/nexus/caller/NexusServiceJunit5Test.java
@@ -0,0 +1,109 @@
+package io.temporal.samples.nexus.caller;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.Mockito.*;
+
+import io.nexusrpc.handler.OperationHandler;
+import io.nexusrpc.handler.OperationImpl;
+import io.nexusrpc.handler.ServiceImpl;
+import io.temporal.samples.nexus.service.SampleNexusService;
+import io.temporal.testing.TestWorkflowEnvironment;
+import io.temporal.testing.TestWorkflowExtension;
+import io.temporal.worker.Worker;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.RegisterExtension;
+
+// This unit test example shows how to mock the Nexus service itself in JUnit4.
+// This is the path to take when you don't have access to the service implementation so
+// cannot mock it. Since the SampleNexusService itself is mocked,
+// no handlers need to be set up or mocked.
+
+// @@@SNIPSTART java-nexus-service-sample-junit5-mock
+public class NexusServiceJunit5Test {
+
+ private final SampleNexusService mockNexusService = mock(SampleNexusService.class);
+
+ /**
+ * A test-only Nexus service implementation that delegates to the Mockito mock defined above. Both
+ * operations are implemented as synchronous handlers that forward calls to the mock, allowing
+ * full control over return values and verification of inputs.
+ */
+ @ServiceImpl(service = SampleNexusService.class)
+ public class TestNexusServiceImpl {
+ @OperationImpl
+ @SuppressWarnings("DirectInvocationOnMock")
+ public OperationHandler echo() {
+ return OperationHandler.sync((ctx, details, input) -> mockNexusService.echo(input));
+ }
+
+ @OperationImpl
+ @SuppressWarnings("DirectInvocationOnMock")
+ public OperationHandler hello() {
+ return OperationHandler.sync((ctx, details, input) -> mockNexusService.hello(input));
+ }
+ }
+
+ // Using OperationHandler.sync for both operations bypasses the need for a backing workflow,
+ // returning results inline just like a synchronous call.
+ //
+ // Note that the Mocks need to be done before the extension
+ // is defined, as creating the rule will fail if either call is still null.
+
+ @RegisterExtension
+ public final TestWorkflowExtension testWorkflowExtension =
+ TestWorkflowExtension.newBuilder()
+ // If a Nexus service is registered as part of the test as in the following line of code,
+ // the TestWorkflowExtension will, by default, automatically create a Nexus service
+ // endpoint and workflows registered as part of the TestWorkflowExtension will
+ // automatically inherit the endpoint if none is set.
+ .setNexusServiceImplementation(new TestNexusServiceImpl())
+ // The Echo Nexus handler service just makes a call to a class, so no extra setup is
+ // needed. But the Hello Nexus service needs a worker for both the caller and handler
+ // in order to run, and the Echo Nexus caller service needs a worker.
+ //
+ // registerWorkflowImplementationTypes will take the classes given and create workers for
+ // them, enabling workflows to run.
+ // Since both operations are mocked with OperationHandler.sync, no backing workflow is
+ // needed for hello — only the caller workflow types need to be registered.
+ .registerWorkflowImplementationTypes(
+ HelloCallerWorkflowImpl.class, EchoCallerWorkflowImpl.class)
+ // The workflow will start before each test, and will shut down after each test.
+ // See CallerWorkflowTest for an example of how to control this differently if needed.
+ .build();
+
+ // The TestWorkflowExtension extension in the Temporal testing library creates the
+ // arguments to the test cases and initializes them from the extension setup call above.
+ @Test
+ public void testHelloWorkflow(
+ TestWorkflowEnvironment testEnv, Worker worker, HelloCallerWorkflow workflow) {
+
+ // Set the mock value to return
+ when(mockNexusService.hello(any()))
+ .thenReturn(new SampleNexusService.HelloOutput("Hello Mock World 👋"));
+
+ // Execute a workflow waiting for it to complete.
+ String greeting = workflow.hello("World", SampleNexusService.Language.EN);
+ assertEquals("Hello Mock World 👋", greeting);
+ }
+
+ @Test
+ public void testEchoWorkflow(
+ TestWorkflowEnvironment testEnv, Worker worker, EchoCallerWorkflow workflow) {
+ when(mockNexusService.echo(any()))
+ .thenReturn(new SampleNexusService.EchoOutput("echo response"));
+
+ // Execute a workflow waiting for it to complete.
+ String greeting = workflow.echo("echo input");
+ assertEquals("echo response", greeting);
+
+ // Verify the echo operation was called exactly once and no other operations were invoked
+ verify(mockNexusService, times(1)).echo(any());
+ // Verify the Nexus service was called with the correct input
+ verify(mockNexusService).echo(argThat(input -> "echo input".equals(input.getMessage())));
+
+ verifyNoMoreInteractions(mockNexusService);
+ }
+}
+
+// @@@SNIPEND
diff --git a/core/src/test/java/io/temporal/samples/nexus/caller/NexusServiceMockTest.java b/core/src/test/java/io/temporal/samples/nexus/caller/NexusServiceMockTest.java
new file mode 100644
index 000000000..8dafc6388
--- /dev/null
+++ b/core/src/test/java/io/temporal/samples/nexus/caller/NexusServiceMockTest.java
@@ -0,0 +1,108 @@
+package io.temporal.samples.nexus.caller;
+
+import static org.junit.Assert.assertEquals;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.Mockito.*;
+
+import io.nexusrpc.handler.OperationHandler;
+import io.nexusrpc.handler.OperationImpl;
+import io.nexusrpc.handler.ServiceImpl;
+import io.temporal.client.WorkflowOptions;
+import io.temporal.samples.nexus.service.SampleNexusService;
+import io.temporal.testing.TestWorkflowRule;
+import org.junit.Rule;
+import org.junit.Test;
+
+// This unit test example shows how to mock the Nexus service itself in JUnit4.
+// This is the path to take when you don't have access to the service implementation so
+// cannot mock it. Since the SampleNexusService itself is mocked,
+// no handlers need to be set up or mocked.
+
+// @@@SNIPSTART java-nexus-service-sample-junit4-mock
+public class NexusServiceMockTest {
+
+ private final SampleNexusService mockNexusService = mock(SampleNexusService.class);
+
+ /**
+ * A test-only Nexus service implementation that delegates to the Mockito mock defined above. Both
+ * operations are implemented as synchronous handlers that forward calls to the mock, allowing
+ * full control over return values and verification of inputs.
+ */
+ @ServiceImpl(service = SampleNexusService.class)
+ public class TestNexusServiceImpl {
+ @OperationImpl
+ @SuppressWarnings("DirectInvocationOnMock")
+ public OperationHandler echo() {
+ return OperationHandler.sync((ctx, details, input) -> mockNexusService.echo(input));
+ }
+
+ @OperationImpl
+ @SuppressWarnings("DirectInvocationOnMock")
+ public OperationHandler hello() {
+ return OperationHandler.sync((ctx, details, input) -> mockNexusService.hello(input));
+ }
+ }
+
+ // Using OperationHandler.sync for both operations bypasses the need for a backing workflow,
+ // returning results inline just like a synchronous call.
+ //
+ // Note that the Mocks need to be done before the rule
+ // is defined, as creating the rule will fail if either call is still null.
+
+ @Rule
+ public TestWorkflowRule testWorkflowRule =
+ TestWorkflowRule.newBuilder()
+ .setNexusServiceImplementation(new TestNexusServiceImpl())
+ .setWorkflowTypes(EchoCallerWorkflowImpl.class, HelloCallerWorkflowImpl.class)
+ .build();
+
+ @Test
+ public void testHelloCallerWithMockedService() {
+ when(mockNexusService.hello(any()))
+ .thenReturn(new SampleNexusService.HelloOutput("Bonjour World"));
+
+ HelloCallerWorkflow workflow =
+ testWorkflowRule
+ .getWorkflowClient()
+ .newWorkflowStub(
+ HelloCallerWorkflow.class,
+ WorkflowOptions.newBuilder().setTaskQueue(testWorkflowRule.getTaskQueue()).build());
+
+ String result = workflow.hello("World", SampleNexusService.Language.FR);
+ assertEquals("Bonjour World", result);
+
+ // Verify the Nexus service was called with the correct name and language
+ verify(mockNexusService)
+ .hello(
+ argThat(
+ input ->
+ "World".equals(input.getName())
+ && SampleNexusService.Language.FR == input.getLanguage()));
+ }
+
+ @Test
+ public void testEchoCallerWithMockedService() {
+ when(mockNexusService.echo(any()))
+ .thenReturn(new SampleNexusService.EchoOutput("echo response"));
+
+ EchoCallerWorkflow workflow =
+ testWorkflowRule
+ .getWorkflowClient()
+ .newWorkflowStub(
+ EchoCallerWorkflow.class,
+ WorkflowOptions.newBuilder().setTaskQueue(testWorkflowRule.getTaskQueue()).build());
+
+ String echoOutput = workflow.echo("echo input");
+
+ assertEquals("echo response", echoOutput);
+
+ // Verify the echo operation was called exactly once and no other operations were invoked
+ verify(mockNexusService, times(1)).echo(any());
+ // Verify the Nexus service was called with the correct input
+ verify(mockNexusService).echo(argThat(input -> "echo input".equals(input.getMessage())));
+
+ verifyNoMoreInteractions(mockNexusService);
+ }
+}
+
+// @@@SNIPEND
diff --git a/core/src/test/java/io/temporal/samples/payloadconverter/CloudEventsPayloadConverterTest.java b/core/src/test/java/io/temporal/samples/payloadconverter/CloudEventsPayloadConverterTest.java
index 391f23ec4..cc78ba75e 100644
--- a/core/src/test/java/io/temporal/samples/payloadconverter/CloudEventsPayloadConverterTest.java
+++ b/core/src/test/java/io/temporal/samples/payloadconverter/CloudEventsPayloadConverterTest.java
@@ -1,22 +1,3 @@
-/*
- * Copyright (c) 2020 Temporal Technologies, Inc. All Rights Reserved
- *
- * Copyright 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
- * Modifications copyright (C) 2017 Uber Technologies, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"). You may not
- * use this file except in compliance with the License. A copy of the License is
- * located at
- *
- * http://aws.amazon.com/apache2.0
- *
- * or in the "license" file accompanying this file. This file is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
package io.temporal.samples.payloadconverter;
import static org.junit.Assert.assertEquals;
diff --git a/core/src/test/java/io/temporal/samples/payloadconverter/CryptoPayloadConverterTest.java b/core/src/test/java/io/temporal/samples/payloadconverter/CryptoPayloadConverterTest.java
index 0693fa269..d8e765d1f 100644
--- a/core/src/test/java/io/temporal/samples/payloadconverter/CryptoPayloadConverterTest.java
+++ b/core/src/test/java/io/temporal/samples/payloadconverter/CryptoPayloadConverterTest.java
@@ -1,22 +1,3 @@
-/*
- * Copyright (c) 2020 Temporal Technologies, Inc. All Rights Reserved
- *
- * Copyright 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
- * Modifications copyright (C) 2017 Uber Technologies, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"). You may not
- * use this file except in compliance with the License. A copy of the License is
- * located at
- *
- * http://aws.amazon.com/apache2.0
- *
- * or in the "license" file accompanying this file. This file is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
package io.temporal.samples.payloadconverter;
import static org.junit.Assert.*;
diff --git a/core/src/test/java/io/temporal/samples/peractivityoptions/PerActivityOptionsTest.java b/core/src/test/java/io/temporal/samples/peractivityoptions/PerActivityOptionsTest.java
index 1b2c4953f..fda95f010 100644
--- a/core/src/test/java/io/temporal/samples/peractivityoptions/PerActivityOptionsTest.java
+++ b/core/src/test/java/io/temporal/samples/peractivityoptions/PerActivityOptionsTest.java
@@ -1,22 +1,3 @@
-/*
- * Copyright (c) 2020 Temporal Technologies, Inc. All Rights Reserved
- *
- * Copyright 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
- * Modifications copyright (C) 2017 Uber Technologies, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"). You may not
- * use this file except in compliance with the License. A copy of the License is
- * located at
- *
- * http://aws.amazon.com/apache2.0
- *
- * or in the "license" file accompanying this file. This file is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
package io.temporal.samples.peractivityoptions;
import static org.junit.Assert.*;
diff --git a/core/src/test/java/io/temporal/samples/polling/FrequentPollingTest.java b/core/src/test/java/io/temporal/samples/polling/FrequentPollingTest.java
index aeb2f27fb..b6de36d26 100644
--- a/core/src/test/java/io/temporal/samples/polling/FrequentPollingTest.java
+++ b/core/src/test/java/io/temporal/samples/polling/FrequentPollingTest.java
@@ -1,22 +1,3 @@
-/*
- * Copyright (c) 2020 Temporal Technologies, Inc. All Rights Reserved
- *
- * Copyright 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
- * Modifications copyright (C) 2017 Uber Technologies, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"). You may not
- * use this file except in compliance with the License. A copy of the License is
- * located at
- *
- * http://aws.amazon.com/apache2.0
- *
- * or in the "license" file accompanying this file. This file is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
package io.temporal.samples.polling;
import static org.junit.Assert.assertEquals;
diff --git a/core/src/test/java/io/temporal/samples/polling/InfrequentPollingTest.java b/core/src/test/java/io/temporal/samples/polling/InfrequentPollingTest.java
index a06de964d..2839d75a4 100644
--- a/core/src/test/java/io/temporal/samples/polling/InfrequentPollingTest.java
+++ b/core/src/test/java/io/temporal/samples/polling/InfrequentPollingTest.java
@@ -1,22 +1,3 @@
-/*
- * Copyright (c) 2020 Temporal Technologies, Inc. All Rights Reserved
- *
- * Copyright 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
- * Modifications copyright (C) 2017 Uber Technologies, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"). You may not
- * use this file except in compliance with the License. A copy of the License is
- * located at
- *
- * http://aws.amazon.com/apache2.0
- *
- * or in the "license" file accompanying this file. This file is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
package io.temporal.samples.polling;
import static org.junit.Assert.*;
diff --git a/core/src/test/java/io/temporal/samples/polling/PeriodicPollingTest.java b/core/src/test/java/io/temporal/samples/polling/PeriodicPollingTest.java
index 959984a27..c9599ba56 100644
--- a/core/src/test/java/io/temporal/samples/polling/PeriodicPollingTest.java
+++ b/core/src/test/java/io/temporal/samples/polling/PeriodicPollingTest.java
@@ -1,22 +1,3 @@
-/*
- * Copyright (c) 2020 Temporal Technologies, Inc. All Rights Reserved
- *
- * Copyright 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
- * Modifications copyright (C) 2017 Uber Technologies, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"). You may not
- * use this file except in compliance with the License. A copy of the License is
- * located at
- *
- * http://aws.amazon.com/apache2.0
- *
- * or in the "license" file accompanying this file. This file is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
package io.temporal.samples.polling;
import static org.junit.Assert.assertEquals;
diff --git a/core/src/test/java/io/temporal/samples/retryonsignalinterceptor/RetryOnSignalInterceptorTest.java b/core/src/test/java/io/temporal/samples/retryonsignalinterceptor/RetryOnSignalInterceptorTest.java
index 1e7696194..b65e0658f 100644
--- a/core/src/test/java/io/temporal/samples/retryonsignalinterceptor/RetryOnSignalInterceptorTest.java
+++ b/core/src/test/java/io/temporal/samples/retryonsignalinterceptor/RetryOnSignalInterceptorTest.java
@@ -1,22 +1,3 @@
-/*
- * Copyright (c) 2020 Temporal Technologies, Inc. All Rights Reserved
- *
- * Copyright 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
- * Modifications copyright (C) 2017 Uber Technologies, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"). You may not
- * use this file except in compliance with the License. A copy of the License is
- * located at
- *
- * http://aws.amazon.com/apache2.0
- *
- * or in the "license" file accompanying this file. This file is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
package io.temporal.samples.retryonsignalinterceptor;
import static org.junit.Assert.*;
diff --git a/core/src/test/java/io/temporal/samples/safemessagepassing/ClusterManagerWorkflowWorkerTest.java b/core/src/test/java/io/temporal/samples/safemessagepassing/ClusterManagerWorkflowWorkerTest.java
index 55ea41fd9..be7219524 100644
--- a/core/src/test/java/io/temporal/samples/safemessagepassing/ClusterManagerWorkflowWorkerTest.java
+++ b/core/src/test/java/io/temporal/samples/safemessagepassing/ClusterManagerWorkflowWorkerTest.java
@@ -1,22 +1,3 @@
-/*
- * Copyright (c) 2020 Temporal Technologies, Inc. All Rights Reserved
- *
- * Copyright 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
- * Modifications copyright (C) 2017 Uber Technologies, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"). You may not
- * use this file except in compliance with the License. A copy of the License is
- * located at
- *
- * http://aws.amazon.com/apache2.0
- *
- * or in the "license" file accompanying this file. This file is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
package io.temporal.samples.safemessagepassing;
import io.temporal.client.*;
diff --git a/core/src/test/java/io/temporal/samples/sleepfordays/SleepForDaysJUnit5Test.java b/core/src/test/java/io/temporal/samples/sleepfordays/SleepForDaysJUnit5Test.java
new file mode 100644
index 000000000..304eab6f3
--- /dev/null
+++ b/core/src/test/java/io/temporal/samples/sleepfordays/SleepForDaysJUnit5Test.java
@@ -0,0 +1,55 @@
+package io.temporal.samples.sleepfordays;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.mockito.Mockito.*;
+
+import io.temporal.client.WorkflowClient;
+import io.temporal.testing.TestWorkflowEnvironment;
+import io.temporal.testing.TestWorkflowExtension;
+import io.temporal.worker.Worker;
+import java.time.Duration;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.Timeout;
+import org.junit.jupiter.api.extension.RegisterExtension;
+
+public class SleepForDaysJUnit5Test {
+
+ @RegisterExtension
+ public TestWorkflowExtension testWorkflowRule =
+ TestWorkflowExtension.newBuilder()
+ .registerWorkflowImplementationTypes(SleepForDaysImpl.class)
+ .setDoNotStart(true)
+ .build();
+
+ @Test
+ @Timeout(8)
+ public void testSleepForDays(
+ TestWorkflowEnvironment testEnv, Worker worker, SleepForDaysWorkflow workflow) {
+ // Mock activity
+ SendEmailActivity activities = mock(SendEmailActivity.class);
+ worker.registerActivitiesImplementations(activities);
+ // Start environment
+ testEnv.start();
+
+ // Start workflow
+ WorkflowClient.start(workflow::sleepForDays);
+
+ long startTime = testEnv.currentTimeMillis();
+ // Time-skip 5 minutes.
+ testEnv.sleep(Duration.ofMinutes(5));
+ // Check that the activity has been called, we're now waiting for the sleep to finish.
+ verify(activities, times(1)).sendEmail(anyString());
+ // Time-skip 3 days.
+ testEnv.sleep(Duration.ofDays(90));
+ // Expect 3 more activity calls.
+ verify(activities, times(4)).sendEmail(anyString());
+ // Send the signal to complete the workflow.
+ workflow.complete();
+ // Expect no more activity calls to have been made - workflow is complete.
+ workflow.sleepForDays();
+ verify(activities, times(4)).sendEmail(anyString());
+ // Expect more than 90 days to have passed.
+ long endTime = testEnv.currentTimeMillis();
+ assertEquals(true, endTime - startTime > Duration.ofDays(90).toMillis());
+ }
+}
diff --git a/core/src/test/java/io/temporal/samples/sleepfordays/SleepForDaysTest.java b/core/src/test/java/io/temporal/samples/sleepfordays/SleepForDaysTest.java
index c79ee0400..e6decbd27 100644
--- a/core/src/test/java/io/temporal/samples/sleepfordays/SleepForDaysTest.java
+++ b/core/src/test/java/io/temporal/samples/sleepfordays/SleepForDaysTest.java
@@ -1,22 +1,3 @@
-/*
- * Copyright (c) 2020 Temporal Technologies, Inc. All Rights Reserved
- *
- * Copyright 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
- * Modifications copyright (C) 2017 Uber Technologies, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"). You may not
- * use this file except in compliance with the License. A copy of the License is
- * located at
- *
- * http://aws.amazon.com/apache2.0
- *
- * or in the "license" file accompanying this file. This file is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
package io.temporal.samples.sleepfordays;
import static org.junit.jupiter.api.Assertions.assertEquals;
diff --git a/core/src/test/java/io/temporal/samples/terminateworkflow/TerminateWorkflowTest.java b/core/src/test/java/io/temporal/samples/terminateworkflow/TerminateWorkflowTest.java
index e6b3f9320..ab1c01cf0 100644
--- a/core/src/test/java/io/temporal/samples/terminateworkflow/TerminateWorkflowTest.java
+++ b/core/src/test/java/io/temporal/samples/terminateworkflow/TerminateWorkflowTest.java
@@ -1,22 +1,3 @@
-/*
- * Copyright (c) 2020 Temporal Technologies, Inc. All Rights Reserved
- *
- * Copyright 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
- * Modifications copyright (C) 2017 Uber Technologies, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"). You may not
- * use this file except in compliance with the License. A copy of the License is
- * located at
- *
- * http://aws.amazon.com/apache2.0
- *
- * or in the "license" file accompanying this file. This file is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
package io.temporal.samples.terminateworkflow;
import static org.junit.Assert.*;
diff --git a/core/src/test/java/io/temporal/samples/tracing/TracingTest.java b/core/src/test/java/io/temporal/samples/tracing/TracingTest.java
index e0baa2b94..303462daa 100644
--- a/core/src/test/java/io/temporal/samples/tracing/TracingTest.java
+++ b/core/src/test/java/io/temporal/samples/tracing/TracingTest.java
@@ -1,22 +1,3 @@
-/*
- * Copyright (c) 2020 Temporal Technologies, Inc. All Rights Reserved
- *
- * Copyright 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
- * Modifications copyright (C) 2017 Uber Technologies, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"). You may not
- * use this file except in compliance with the License. A copy of the License is
- * located at
- *
- * http://aws.amazon.com/apache2.0
- *
- * or in the "license" file accompanying this file. This file is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
package io.temporal.samples.tracing;
import static org.junit.Assert.*;
diff --git a/license-header.txt b/license-header.txt
deleted file mode 100644
index cc53a25f9..000000000
--- a/license-header.txt
+++ /dev/null
@@ -1,16 +0,0 @@
- Copyright (c) 2020 Temporal Technologies, Inc. All Rights Reserved
-
- Copyright 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
-
- Modifications copyright (C) 2017 Uber Technologies, Inc.
-
- Licensed under the Apache License, Version 2.0 (the "License"). You may not
- use this file except in compliance with the License. A copy of the License is
- located at
-
- http://aws.amazon.com/apache2.0
-
- or in the "license" file accompanying this file. This file is distributed on
- an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- express or implied. See the License for the specific language governing
- permissions and limitations under the License.
diff --git a/springboot-basic/src/main/java/io/temporal/samples/springboot/SamplesController.java b/springboot-basic/src/main/java/io/temporal/samples/springboot/SamplesController.java
index 79185cd67..bd3b2eb50 100644
--- a/springboot-basic/src/main/java/io/temporal/samples/springboot/SamplesController.java
+++ b/springboot-basic/src/main/java/io/temporal/samples/springboot/SamplesController.java
@@ -1,22 +1,3 @@
-/*
- * Copyright (c) 2020 Temporal Technologies, Inc. All Rights Reserved
- *
- * Copyright 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
- * Modifications copyright (C) 2017 Uber Technologies, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"). You may not
- * use this file except in compliance with the License. A copy of the License is
- * located at
- *
- * http://aws.amazon.com/apache2.0
- *
- * or in the "license" file accompanying this file. This file is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
package io.temporal.samples.springboot;
import io.temporal.client.WorkflowClient;
diff --git a/springboot-basic/src/main/java/io/temporal/samples/springboot/TemporalSpringbootSamplesApplication.java b/springboot-basic/src/main/java/io/temporal/samples/springboot/TemporalSpringbootSamplesApplication.java
index 88ca068a1..8edec517f 100644
--- a/springboot-basic/src/main/java/io/temporal/samples/springboot/TemporalSpringbootSamplesApplication.java
+++ b/springboot-basic/src/main/java/io/temporal/samples/springboot/TemporalSpringbootSamplesApplication.java
@@ -1,22 +1,3 @@
-/*
- * Copyright (c) 2020 Temporal Technologies, Inc. All Rights Reserved
- *
- * Copyright 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
- * Modifications copyright (C) 2017 Uber Technologies, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"). You may not
- * use this file except in compliance with the License. A copy of the License is
- * located at
- *
- * http://aws.amazon.com/apache2.0
- *
- * or in the "license" file accompanying this file. This file is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
package io.temporal.samples.springboot;
import org.springframework.boot.SpringApplication;
diff --git a/springboot-basic/src/main/java/io/temporal/samples/springboot/hello/HelloActivity.java b/springboot-basic/src/main/java/io/temporal/samples/springboot/hello/HelloActivity.java
index d727696f0..1e1e027be 100644
--- a/springboot-basic/src/main/java/io/temporal/samples/springboot/hello/HelloActivity.java
+++ b/springboot-basic/src/main/java/io/temporal/samples/springboot/hello/HelloActivity.java
@@ -1,22 +1,3 @@
-/*
- * Copyright (c) 2020 Temporal Technologies, Inc. All Rights Reserved
- *
- * Copyright 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
- * Modifications copyright (C) 2017 Uber Technologies, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"). You may not
- * use this file except in compliance with the License. A copy of the License is
- * located at
- *
- * http://aws.amazon.com/apache2.0
- *
- * or in the "license" file accompanying this file. This file is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
package io.temporal.samples.springboot.hello;
import io.temporal.activity.ActivityInterface;
diff --git a/springboot-basic/src/main/java/io/temporal/samples/springboot/hello/HelloActivityImpl.java b/springboot-basic/src/main/java/io/temporal/samples/springboot/hello/HelloActivityImpl.java
index 6dd3a39fe..924d3f237 100644
--- a/springboot-basic/src/main/java/io/temporal/samples/springboot/hello/HelloActivityImpl.java
+++ b/springboot-basic/src/main/java/io/temporal/samples/springboot/hello/HelloActivityImpl.java
@@ -1,22 +1,3 @@
-/*
- * Copyright (c) 2020 Temporal Technologies, Inc. All Rights Reserved
- *
- * Copyright 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
- * Modifications copyright (C) 2017 Uber Technologies, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"). You may not
- * use this file except in compliance with the License. A copy of the License is
- * located at
- *
- * http://aws.amazon.com/apache2.0
- *
- * or in the "license" file accompanying this file. This file is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
package io.temporal.samples.springboot.hello;
import io.temporal.samples.springboot.hello.model.Person;
diff --git a/springboot-basic/src/main/java/io/temporal/samples/springboot/hello/HelloWorkflow.java b/springboot-basic/src/main/java/io/temporal/samples/springboot/hello/HelloWorkflow.java
index fd1675623..25c0bab87 100644
--- a/springboot-basic/src/main/java/io/temporal/samples/springboot/hello/HelloWorkflow.java
+++ b/springboot-basic/src/main/java/io/temporal/samples/springboot/hello/HelloWorkflow.java
@@ -1,22 +1,3 @@
-/*
- * Copyright (c) 2020 Temporal Technologies, Inc. All Rights Reserved
- *
- * Copyright 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
- * Modifications copyright (C) 2017 Uber Technologies, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"). You may not
- * use this file except in compliance with the License. A copy of the License is
- * located at
- *
- * http://aws.amazon.com/apache2.0
- *
- * or in the "license" file accompanying this file. This file is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
package io.temporal.samples.springboot.hello;
import io.temporal.samples.springboot.hello.model.Person;
diff --git a/springboot-basic/src/main/java/io/temporal/samples/springboot/hello/HelloWorkflowImpl.java b/springboot-basic/src/main/java/io/temporal/samples/springboot/hello/HelloWorkflowImpl.java
index 05336a9f3..2b3a897a4 100644
--- a/springboot-basic/src/main/java/io/temporal/samples/springboot/hello/HelloWorkflowImpl.java
+++ b/springboot-basic/src/main/java/io/temporal/samples/springboot/hello/HelloWorkflowImpl.java
@@ -1,22 +1,3 @@
-/*
- * Copyright (c) 2020 Temporal Technologies, Inc. All Rights Reserved
- *
- * Copyright 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
- * Modifications copyright (C) 2017 Uber Technologies, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"). You may not
- * use this file except in compliance with the License. A copy of the License is
- * located at
- *
- * http://aws.amazon.com/apache2.0
- *
- * or in the "license" file accompanying this file. This file is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
package io.temporal.samples.springboot.hello;
import io.temporal.activity.ActivityOptions;
diff --git a/springboot-basic/src/main/java/io/temporal/samples/springboot/hello/model/Person.java b/springboot-basic/src/main/java/io/temporal/samples/springboot/hello/model/Person.java
index c71862b23..4472fee6b 100644
--- a/springboot-basic/src/main/java/io/temporal/samples/springboot/hello/model/Person.java
+++ b/springboot-basic/src/main/java/io/temporal/samples/springboot/hello/model/Person.java
@@ -1,22 +1,3 @@
-/*
- * Copyright (c) 2020 Temporal Technologies, Inc. All Rights Reserved
- *
- * Copyright 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
- * Modifications copyright (C) 2017 Uber Technologies, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"). You may not
- * use this file except in compliance with the License. A copy of the License is
- * located at
- *
- * http://aws.amazon.com/apache2.0
- *
- * or in the "license" file accompanying this file. This file is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
package io.temporal.samples.springboot.hello.model;
public class Person {
diff --git a/springboot-basic/src/test/java/io/temporal/samples/springboot/HelloSampleTest.java b/springboot-basic/src/test/java/io/temporal/samples/springboot/HelloSampleTest.java
index 1aab3fdc0..5efe43102 100644
--- a/springboot-basic/src/test/java/io/temporal/samples/springboot/HelloSampleTest.java
+++ b/springboot-basic/src/test/java/io/temporal/samples/springboot/HelloSampleTest.java
@@ -1,22 +1,3 @@
-/*
- * Copyright (c) 2020 Temporal Technologies, Inc. All Rights Reserved
- *
- * Copyright 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
- * Modifications copyright (C) 2017 Uber Technologies, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"). You may not
- * use this file except in compliance with the License. A copy of the License is
- * located at
- *
- * http://aws.amazon.com/apache2.0
- *
- * or in the "license" file accompanying this file. This file is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
package io.temporal.samples.springboot;
import io.temporal.client.WorkflowClient;
diff --git a/springboot/build.gradle b/springboot/build.gradle
index 7120304e9..aa632df51 100644
--- a/springboot/build.gradle
+++ b/springboot/build.gradle
@@ -9,6 +9,9 @@ dependencies {
// we set this as impl depends to use embedded kafka in samples not just tests
implementation "org.springframework.kafka:spring-kafka-test"
implementation "io.temporal:temporal-spring-boot-starter:$javaSDKVersion"
+
+ // Environment configuration
+ implementation "io.temporal:temporal-envconfig:$javaSDKVersion"
implementation "org.apache.camel.springboot:camel-spring-boot-starter:$camelVersion"
implementation "org.apache.camel.springboot:camel-servlet-starter:$camelVersion"
runtimeOnly "io.micrometer:micrometer-registry-prometheus"
diff --git a/springboot/src/main/java/io/temporal/samples/springboot/SamplesController.java b/springboot/src/main/java/io/temporal/samples/springboot/SamplesController.java
index 814236e09..3db4c8ca1 100644
--- a/springboot/src/main/java/io/temporal/samples/springboot/SamplesController.java
+++ b/springboot/src/main/java/io/temporal/samples/springboot/SamplesController.java
@@ -1,22 +1,3 @@
-/*
- * Copyright (c) 2020 Temporal Technologies, Inc. All Rights Reserved
- *
- * Copyright 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
- * Modifications copyright (C) 2017 Uber Technologies, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"). You may not
- * use this file except in compliance with the License. A copy of the License is
- * located at
- *
- * http://aws.amazon.com/apache2.0
- *
- * or in the "license" file accompanying this file. This file is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
package io.temporal.samples.springboot;
import io.grpc.StatusRuntimeException;
diff --git a/springboot/src/main/java/io/temporal/samples/springboot/TemporalSpringbootSamplesApplication.java b/springboot/src/main/java/io/temporal/samples/springboot/TemporalSpringbootSamplesApplication.java
index 132464afc..9eed45e85 100644
--- a/springboot/src/main/java/io/temporal/samples/springboot/TemporalSpringbootSamplesApplication.java
+++ b/springboot/src/main/java/io/temporal/samples/springboot/TemporalSpringbootSamplesApplication.java
@@ -1,22 +1,3 @@
-/*
- * Copyright (c) 2020 Temporal Technologies, Inc. All Rights Reserved
- *
- * Copyright 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
- * Modifications copyright (C) 2017 Uber Technologies, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"). You may not
- * use this file except in compliance with the License. A copy of the License is
- * located at
- *
- * http://aws.amazon.com/apache2.0
- *
- * or in the "license" file accompanying this file. This file is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
package io.temporal.samples.springboot;
import org.springframework.boot.SpringApplication;
diff --git a/springboot/src/main/java/io/temporal/samples/springboot/actuator/WorkerActuatorEndpoint.java b/springboot/src/main/java/io/temporal/samples/springboot/actuator/WorkerActuatorEndpoint.java
index 140bf2847..cdf6ea71c 100644
--- a/springboot/src/main/java/io/temporal/samples/springboot/actuator/WorkerActuatorEndpoint.java
+++ b/springboot/src/main/java/io/temporal/samples/springboot/actuator/WorkerActuatorEndpoint.java
@@ -1,22 +1,3 @@
-/*
- * Copyright (c) 2020 Temporal Technologies, Inc. All Rights Reserved
- *
- * Copyright 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
- * Modifications copyright (C) 2017 Uber Technologies, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"). You may not
- * use this file except in compliance with the License. A copy of the License is
- * located at
- *
- * http://aws.amazon.com/apache2.0
- *
- * or in the "license" file accompanying this file. This file is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
package io.temporal.samples.springboot.actuator;
import io.temporal.common.metadata.*;
diff --git a/springboot/src/main/java/io/temporal/samples/springboot/camel/CamelConfig.java b/springboot/src/main/java/io/temporal/samples/springboot/camel/CamelConfig.java
index febb78464..af926b1ed 100644
--- a/springboot/src/main/java/io/temporal/samples/springboot/camel/CamelConfig.java
+++ b/springboot/src/main/java/io/temporal/samples/springboot/camel/CamelConfig.java
@@ -1,22 +1,3 @@
-/*
- * Copyright (c) 2020 Temporal Technologies, Inc. All Rights Reserved
- *
- * Copyright 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
- * Modifications copyright (C) 2017 Uber Technologies, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"). You may not
- * use this file except in compliance with the License. A copy of the License is
- * located at
- *
- * http://aws.amazon.com/apache2.0
- *
- * or in the "license" file accompanying this file. This file is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
package io.temporal.samples.springboot.camel;
import org.apache.camel.CamelContext;
diff --git a/springboot/src/main/java/io/temporal/samples/springboot/camel/CamelResource.java b/springboot/src/main/java/io/temporal/samples/springboot/camel/CamelResource.java
index 43cb142e6..86ad47c65 100644
--- a/springboot/src/main/java/io/temporal/samples/springboot/camel/CamelResource.java
+++ b/springboot/src/main/java/io/temporal/samples/springboot/camel/CamelResource.java
@@ -1,22 +1,3 @@
-/*
- * Copyright (c) 2020 Temporal Technologies, Inc. All Rights Reserved
- *
- * Copyright 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
- * Modifications copyright (C) 2017 Uber Technologies, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"). You may not
- * use this file except in compliance with the License. A copy of the License is
- * located at
- *
- * http://aws.amazon.com/apache2.0
- *
- * or in the "license" file accompanying this file. This file is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
package io.temporal.samples.springboot.camel;
import java.util.List;
diff --git a/springboot/src/main/java/io/temporal/samples/springboot/camel/CamelRoutes.java b/springboot/src/main/java/io/temporal/samples/springboot/camel/CamelRoutes.java
index 9bf96dce3..5fe4c4a8f 100644
--- a/springboot/src/main/java/io/temporal/samples/springboot/camel/CamelRoutes.java
+++ b/springboot/src/main/java/io/temporal/samples/springboot/camel/CamelRoutes.java
@@ -1,22 +1,3 @@
-/*
- * Copyright (c) 2020 Temporal Technologies, Inc. All Rights Reserved
- *
- * Copyright 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
- * Modifications copyright (C) 2017 Uber Technologies, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"). You may not
- * use this file except in compliance with the License. A copy of the License is
- * located at
- *
- * http://aws.amazon.com/apache2.0
- *
- * or in the "license" file accompanying this file. This file is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
package io.temporal.samples.springboot.camel;
import io.temporal.client.WorkflowClient;
diff --git a/springboot/src/main/java/io/temporal/samples/springboot/camel/OfficeOrder.java b/springboot/src/main/java/io/temporal/samples/springboot/camel/OfficeOrder.java
index 82b998a21..bf45baae4 100644
--- a/springboot/src/main/java/io/temporal/samples/springboot/camel/OfficeOrder.java
+++ b/springboot/src/main/java/io/temporal/samples/springboot/camel/OfficeOrder.java
@@ -1,22 +1,3 @@
-/*
- * Copyright (c) 2020 Temporal Technologies, Inc. All Rights Reserved
- *
- * Copyright 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
- * Modifications copyright (C) 2017 Uber Technologies, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"). You may not
- * use this file except in compliance with the License. A copy of the License is
- * located at
- *
- * http://aws.amazon.com/apache2.0
- *
- * or in the "license" file accompanying this file. This file is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
package io.temporal.samples.springboot.camel;
import javax.persistence.*;
diff --git a/springboot/src/main/java/io/temporal/samples/springboot/camel/OrderActivity.java b/springboot/src/main/java/io/temporal/samples/springboot/camel/OrderActivity.java
index f94d6ecf1..987aa356c 100644
--- a/springboot/src/main/java/io/temporal/samples/springboot/camel/OrderActivity.java
+++ b/springboot/src/main/java/io/temporal/samples/springboot/camel/OrderActivity.java
@@ -1,22 +1,3 @@
-/*
- * Copyright (c) 2020 Temporal Technologies, Inc. All Rights Reserved
- *
- * Copyright 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
- * Modifications copyright (C) 2017 Uber Technologies, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"). You may not
- * use this file except in compliance with the License. A copy of the License is
- * located at
- *
- * http://aws.amazon.com/apache2.0
- *
- * or in the "license" file accompanying this file. This file is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
package io.temporal.samples.springboot.camel;
import io.temporal.activity.ActivityInterface;
diff --git a/springboot/src/main/java/io/temporal/samples/springboot/camel/OrderActivityImpl.java b/springboot/src/main/java/io/temporal/samples/springboot/camel/OrderActivityImpl.java
index 088fdb9f3..f05c79640 100644
--- a/springboot/src/main/java/io/temporal/samples/springboot/camel/OrderActivityImpl.java
+++ b/springboot/src/main/java/io/temporal/samples/springboot/camel/OrderActivityImpl.java
@@ -1,22 +1,3 @@
-/*
- * Copyright (c) 2020 Temporal Technologies, Inc. All Rights Reserved
- *
- * Copyright 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
- * Modifications copyright (C) 2017 Uber Technologies, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"). You may not
- * use this file except in compliance with the License. A copy of the License is
- * located at
- *
- * http://aws.amazon.com/apache2.0
- *
- * or in the "license" file accompanying this file. This file is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
package io.temporal.samples.springboot.camel;
import io.temporal.spring.boot.ActivityImpl;
diff --git a/springboot/src/main/java/io/temporal/samples/springboot/camel/OrderRepository.java b/springboot/src/main/java/io/temporal/samples/springboot/camel/OrderRepository.java
index 255955112..77bd140d8 100644
--- a/springboot/src/main/java/io/temporal/samples/springboot/camel/OrderRepository.java
+++ b/springboot/src/main/java/io/temporal/samples/springboot/camel/OrderRepository.java
@@ -1,22 +1,3 @@
-/*
- * Copyright (c) 2020 Temporal Technologies, Inc. All Rights Reserved
- *
- * Copyright 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
- * Modifications copyright (C) 2017 Uber Technologies, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"). You may not
- * use this file except in compliance with the License. A copy of the License is
- * located at
- *
- * http://aws.amazon.com/apache2.0
- *
- * or in the "license" file accompanying this file. This file is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
package io.temporal.samples.springboot.camel;
import org.springframework.data.jpa.repository.JpaRepository;
diff --git a/springboot/src/main/java/io/temporal/samples/springboot/camel/OrderWorkflow.java b/springboot/src/main/java/io/temporal/samples/springboot/camel/OrderWorkflow.java
index 067d92bcf..2ec963b6d 100644
--- a/springboot/src/main/java/io/temporal/samples/springboot/camel/OrderWorkflow.java
+++ b/springboot/src/main/java/io/temporal/samples/springboot/camel/OrderWorkflow.java
@@ -1,22 +1,3 @@
-/*
- * Copyright (c) 2020 Temporal Technologies, Inc. All Rights Reserved
- *
- * Copyright 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
- * Modifications copyright (C) 2017 Uber Technologies, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"). You may not
- * use this file except in compliance with the License. A copy of the License is
- * located at
- *
- * http://aws.amazon.com/apache2.0
- *
- * or in the "license" file accompanying this file. This file is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
package io.temporal.samples.springboot.camel;
import io.temporal.workflow.WorkflowInterface;
diff --git a/springboot/src/main/java/io/temporal/samples/springboot/camel/OrderWorkflowImpl.java b/springboot/src/main/java/io/temporal/samples/springboot/camel/OrderWorkflowImpl.java
index 60a129e3e..c8f1c458b 100644
--- a/springboot/src/main/java/io/temporal/samples/springboot/camel/OrderWorkflowImpl.java
+++ b/springboot/src/main/java/io/temporal/samples/springboot/camel/OrderWorkflowImpl.java
@@ -1,22 +1,3 @@
-/*
- * Copyright (c) 2020 Temporal Technologies, Inc. All Rights Reserved
- *
- * Copyright 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
- * Modifications copyright (C) 2017 Uber Technologies, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"). You may not
- * use this file except in compliance with the License. A copy of the License is
- * located at
- *
- * http://aws.amazon.com/apache2.0
- *
- * or in the "license" file accompanying this file. This file is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
package io.temporal.samples.springboot.camel;
import io.temporal.activity.ActivityOptions;
diff --git a/springboot/src/main/java/io/temporal/samples/springboot/customize/CustomizeActivity.java b/springboot/src/main/java/io/temporal/samples/springboot/customize/CustomizeActivity.java
index 06f9d03aa..01dddadf1 100644
--- a/springboot/src/main/java/io/temporal/samples/springboot/customize/CustomizeActivity.java
+++ b/springboot/src/main/java/io/temporal/samples/springboot/customize/CustomizeActivity.java
@@ -1,22 +1,3 @@
-/*
- * Copyright (c) 2020 Temporal Technologies, Inc. All Rights Reserved
- *
- * Copyright 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
- * Modifications copyright (C) 2017 Uber Technologies, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"). You may not
- * use this file except in compliance with the License. A copy of the License is
- * located at
- *
- * http://aws.amazon.com/apache2.0
- *
- * or in the "license" file accompanying this file. This file is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
package io.temporal.samples.springboot.customize;
import io.temporal.activity.ActivityInterface;
diff --git a/springboot/src/main/java/io/temporal/samples/springboot/customize/CustomizeActivityImpl.java b/springboot/src/main/java/io/temporal/samples/springboot/customize/CustomizeActivityImpl.java
index 9d28c8ed9..0f9c3edf6 100644
--- a/springboot/src/main/java/io/temporal/samples/springboot/customize/CustomizeActivityImpl.java
+++ b/springboot/src/main/java/io/temporal/samples/springboot/customize/CustomizeActivityImpl.java
@@ -1,22 +1,3 @@
-/*
- * Copyright (c) 2020 Temporal Technologies, Inc. All Rights Reserved
- *
- * Copyright 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
- * Modifications copyright (C) 2017 Uber Technologies, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"). You may not
- * use this file except in compliance with the License. A copy of the License is
- * located at
- *
- * http://aws.amazon.com/apache2.0
- *
- * or in the "license" file accompanying this file. This file is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
package io.temporal.samples.springboot.customize;
import io.temporal.spring.boot.ActivityImpl;
diff --git a/springboot/src/main/java/io/temporal/samples/springboot/customize/CustomizeWorkflow.java b/springboot/src/main/java/io/temporal/samples/springboot/customize/CustomizeWorkflow.java
index ffe9574eb..6bfcc4fb6 100644
--- a/springboot/src/main/java/io/temporal/samples/springboot/customize/CustomizeWorkflow.java
+++ b/springboot/src/main/java/io/temporal/samples/springboot/customize/CustomizeWorkflow.java
@@ -1,22 +1,3 @@
-/*
- * Copyright (c) 2020 Temporal Technologies, Inc. All Rights Reserved
- *
- * Copyright 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
- * Modifications copyright (C) 2017 Uber Technologies, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"). You may not
- * use this file except in compliance with the License. A copy of the License is
- * located at
- *
- * http://aws.amazon.com/apache2.0
- *
- * or in the "license" file accompanying this file. This file is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
package io.temporal.samples.springboot.customize;
import io.temporal.workflow.WorkflowInterface;
diff --git a/springboot/src/main/java/io/temporal/samples/springboot/customize/CustomizeWorkflowImpl.java b/springboot/src/main/java/io/temporal/samples/springboot/customize/CustomizeWorkflowImpl.java
index d5b845740..390de4625 100644
--- a/springboot/src/main/java/io/temporal/samples/springboot/customize/CustomizeWorkflowImpl.java
+++ b/springboot/src/main/java/io/temporal/samples/springboot/customize/CustomizeWorkflowImpl.java
@@ -1,22 +1,3 @@
-/*
- * Copyright (c) 2020 Temporal Technologies, Inc. All Rights Reserved
- *
- * Copyright 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
- * Modifications copyright (C) 2017 Uber Technologies, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"). You may not
- * use this file except in compliance with the License. A copy of the License is
- * located at
- *
- * http://aws.amazon.com/apache2.0
- *
- * or in the "license" file accompanying this file. This file is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
package io.temporal.samples.springboot.customize;
import io.temporal.activity.ActivityOptions;
diff --git a/springboot/src/main/java/io/temporal/samples/springboot/customize/TemporalOptionsConfig.java b/springboot/src/main/java/io/temporal/samples/springboot/customize/TemporalOptionsConfig.java
index 5ce82d019..f7c27f502 100644
--- a/springboot/src/main/java/io/temporal/samples/springboot/customize/TemporalOptionsConfig.java
+++ b/springboot/src/main/java/io/temporal/samples/springboot/customize/TemporalOptionsConfig.java
@@ -1,22 +1,3 @@
-/*
- * Copyright (c) 2020 Temporal Technologies, Inc. All Rights Reserved
- *
- * Copyright 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
- * Modifications copyright (C) 2017 Uber Technologies, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"). You may not
- * use this file except in compliance with the License. A copy of the License is
- * located at
- *
- * http://aws.amazon.com/apache2.0
- *
- * or in the "license" file accompanying this file. This file is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
package io.temporal.samples.springboot.customize;
import io.temporal.client.WorkflowClientOptions;
diff --git a/springboot/src/main/java/io/temporal/samples/springboot/hello/HelloActivity.java b/springboot/src/main/java/io/temporal/samples/springboot/hello/HelloActivity.java
index d727696f0..1e1e027be 100644
--- a/springboot/src/main/java/io/temporal/samples/springboot/hello/HelloActivity.java
+++ b/springboot/src/main/java/io/temporal/samples/springboot/hello/HelloActivity.java
@@ -1,22 +1,3 @@
-/*
- * Copyright (c) 2020 Temporal Technologies, Inc. All Rights Reserved
- *
- * Copyright 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
- * Modifications copyright (C) 2017 Uber Technologies, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"). You may not
- * use this file except in compliance with the License. A copy of the License is
- * located at
- *
- * http://aws.amazon.com/apache2.0
- *
- * or in the "license" file accompanying this file. This file is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
package io.temporal.samples.springboot.hello;
import io.temporal.activity.ActivityInterface;
diff --git a/springboot/src/main/java/io/temporal/samples/springboot/hello/HelloActivityImpl.java b/springboot/src/main/java/io/temporal/samples/springboot/hello/HelloActivityImpl.java
index 6dd3a39fe..924d3f237 100644
--- a/springboot/src/main/java/io/temporal/samples/springboot/hello/HelloActivityImpl.java
+++ b/springboot/src/main/java/io/temporal/samples/springboot/hello/HelloActivityImpl.java
@@ -1,22 +1,3 @@
-/*
- * Copyright (c) 2020 Temporal Technologies, Inc. All Rights Reserved
- *
- * Copyright 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
- * Modifications copyright (C) 2017 Uber Technologies, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"). You may not
- * use this file except in compliance with the License. A copy of the License is
- * located at
- *
- * http://aws.amazon.com/apache2.0
- *
- * or in the "license" file accompanying this file. This file is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
package io.temporal.samples.springboot.hello;
import io.temporal.samples.springboot.hello.model.Person;
diff --git a/springboot/src/main/java/io/temporal/samples/springboot/hello/HelloWorkflow.java b/springboot/src/main/java/io/temporal/samples/springboot/hello/HelloWorkflow.java
index fd1675623..25c0bab87 100644
--- a/springboot/src/main/java/io/temporal/samples/springboot/hello/HelloWorkflow.java
+++ b/springboot/src/main/java/io/temporal/samples/springboot/hello/HelloWorkflow.java
@@ -1,22 +1,3 @@
-/*
- * Copyright (c) 2020 Temporal Technologies, Inc. All Rights Reserved
- *
- * Copyright 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
- * Modifications copyright (C) 2017 Uber Technologies, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"). You may not
- * use this file except in compliance with the License. A copy of the License is
- * located at
- *
- * http://aws.amazon.com/apache2.0
- *
- * or in the "license" file accompanying this file. This file is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
package io.temporal.samples.springboot.hello;
import io.temporal.samples.springboot.hello.model.Person;
diff --git a/springboot/src/main/java/io/temporal/samples/springboot/hello/HelloWorkflowImpl.java b/springboot/src/main/java/io/temporal/samples/springboot/hello/HelloWorkflowImpl.java
index 05336a9f3..2b3a897a4 100644
--- a/springboot/src/main/java/io/temporal/samples/springboot/hello/HelloWorkflowImpl.java
+++ b/springboot/src/main/java/io/temporal/samples/springboot/hello/HelloWorkflowImpl.java
@@ -1,22 +1,3 @@
-/*
- * Copyright (c) 2020 Temporal Technologies, Inc. All Rights Reserved
- *
- * Copyright 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
- * Modifications copyright (C) 2017 Uber Technologies, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"). You may not
- * use this file except in compliance with the License. A copy of the License is
- * located at
- *
- * http://aws.amazon.com/apache2.0
- *
- * or in the "license" file accompanying this file. This file is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
package io.temporal.samples.springboot.hello;
import io.temporal.activity.ActivityOptions;
diff --git a/springboot/src/main/java/io/temporal/samples/springboot/hello/model/Person.java b/springboot/src/main/java/io/temporal/samples/springboot/hello/model/Person.java
index c71862b23..4472fee6b 100644
--- a/springboot/src/main/java/io/temporal/samples/springboot/hello/model/Person.java
+++ b/springboot/src/main/java/io/temporal/samples/springboot/hello/model/Person.java
@@ -1,22 +1,3 @@
-/*
- * Copyright (c) 2020 Temporal Technologies, Inc. All Rights Reserved
- *
- * Copyright 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
- * Modifications copyright (C) 2017 Uber Technologies, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"). You may not
- * use this file except in compliance with the License. A copy of the License is
- * located at
- *
- * http://aws.amazon.com/apache2.0
- *
- * or in the "license" file accompanying this file. This file is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
package io.temporal.samples.springboot.hello.model;
public class Person {
diff --git a/springboot/src/main/java/io/temporal/samples/springboot/kafka/KafkaActivity.java b/springboot/src/main/java/io/temporal/samples/springboot/kafka/KafkaActivity.java
index 9a6933497..7a8d59174 100644
--- a/springboot/src/main/java/io/temporal/samples/springboot/kafka/KafkaActivity.java
+++ b/springboot/src/main/java/io/temporal/samples/springboot/kafka/KafkaActivity.java
@@ -1,22 +1,3 @@
-/*
- * Copyright (c) 2020 Temporal Technologies, Inc. All Rights Reserved
- *
- * Copyright 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
- * Modifications copyright (C) 2017 Uber Technologies, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"). You may not
- * use this file except in compliance with the License. A copy of the License is
- * located at
- *
- * http://aws.amazon.com/apache2.0
- *
- * or in the "license" file accompanying this file. This file is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
package io.temporal.samples.springboot.kafka;
import io.temporal.activity.ActivityInterface;
diff --git a/springboot/src/main/java/io/temporal/samples/springboot/kafka/KafkaActivityImpl.java b/springboot/src/main/java/io/temporal/samples/springboot/kafka/KafkaActivityImpl.java
index 81bb6634f..360c3d263 100644
--- a/springboot/src/main/java/io/temporal/samples/springboot/kafka/KafkaActivityImpl.java
+++ b/springboot/src/main/java/io/temporal/samples/springboot/kafka/KafkaActivityImpl.java
@@ -1,22 +1,3 @@
-/*
- * Copyright (c) 2020 Temporal Technologies, Inc. All Rights Reserved
- *
- * Copyright 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
- * Modifications copyright (C) 2017 Uber Technologies, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"). You may not
- * use this file except in compliance with the License. A copy of the License is
- * located at
- *
- * http://aws.amazon.com/apache2.0
- *
- * or in the "license" file accompanying this file. This file is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
package io.temporal.samples.springboot.kafka;
import io.temporal.failure.ApplicationFailure;
diff --git a/springboot/src/main/java/io/temporal/samples/springboot/kafka/KafkaConfig.java b/springboot/src/main/java/io/temporal/samples/springboot/kafka/KafkaConfig.java
index 30b07d1bb..bfaaf3ea8 100644
--- a/springboot/src/main/java/io/temporal/samples/springboot/kafka/KafkaConfig.java
+++ b/springboot/src/main/java/io/temporal/samples/springboot/kafka/KafkaConfig.java
@@ -1,22 +1,3 @@
-/*
- * Copyright (c) 2020 Temporal Technologies, Inc. All Rights Reserved
- *
- * Copyright 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
- * Modifications copyright (C) 2017 Uber Technologies, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"). You may not
- * use this file except in compliance with the License. A copy of the License is
- * located at
- *
- * http://aws.amazon.com/apache2.0
- *
- * or in the "license" file accompanying this file. This file is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
package io.temporal.samples.springboot.kafka;
import java.io.IOException;
diff --git a/springboot/src/main/java/io/temporal/samples/springboot/kafka/MessageController.java b/springboot/src/main/java/io/temporal/samples/springboot/kafka/MessageController.java
index 6b84ebd21..4b8d7f415 100644
--- a/springboot/src/main/java/io/temporal/samples/springboot/kafka/MessageController.java
+++ b/springboot/src/main/java/io/temporal/samples/springboot/kafka/MessageController.java
@@ -1,22 +1,3 @@
-/*
- * Copyright (c) 2020 Temporal Technologies, Inc. All Rights Reserved
- *
- * Copyright 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
- * Modifications copyright (C) 2017 Uber Technologies, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"). You may not
- * use this file except in compliance with the License. A copy of the License is
- * located at
- *
- * http://aws.amazon.com/apache2.0
- *
- * or in the "license" file accompanying this file. This file is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
package io.temporal.samples.springboot.kafka;
import java.util.ArrayList;
diff --git a/springboot/src/main/java/io/temporal/samples/springboot/kafka/MessageWorkflow.java b/springboot/src/main/java/io/temporal/samples/springboot/kafka/MessageWorkflow.java
index 866482b71..bc29a15f6 100644
--- a/springboot/src/main/java/io/temporal/samples/springboot/kafka/MessageWorkflow.java
+++ b/springboot/src/main/java/io/temporal/samples/springboot/kafka/MessageWorkflow.java
@@ -1,22 +1,3 @@
-/*
- * Copyright (c) 2020 Temporal Technologies, Inc. All Rights Reserved
- *
- * Copyright 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
- * Modifications copyright (C) 2017 Uber Technologies, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"). You may not
- * use this file except in compliance with the License. A copy of the License is
- * located at
- *
- * http://aws.amazon.com/apache2.0
- *
- * or in the "license" file accompanying this file. This file is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
package io.temporal.samples.springboot.kafka;
import io.temporal.workflow.SignalMethod;
diff --git a/springboot/src/main/java/io/temporal/samples/springboot/kafka/MessageWorkflowImpl.java b/springboot/src/main/java/io/temporal/samples/springboot/kafka/MessageWorkflowImpl.java
index 8aef1a9c9..88fb0b534 100644
--- a/springboot/src/main/java/io/temporal/samples/springboot/kafka/MessageWorkflowImpl.java
+++ b/springboot/src/main/java/io/temporal/samples/springboot/kafka/MessageWorkflowImpl.java
@@ -1,22 +1,3 @@
-/*
- * Copyright (c) 2020 Temporal Technologies, Inc. All Rights Reserved
- *
- * Copyright 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
- * Modifications copyright (C) 2017 Uber Technologies, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"). You may not
- * use this file except in compliance with the License. A copy of the License is
- * located at
- *
- * http://aws.amazon.com/apache2.0
- *
- * or in the "license" file accompanying this file. This file is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
package io.temporal.samples.springboot.kafka;
import io.temporal.activity.ActivityOptions;
diff --git a/springboot/src/main/java/io/temporal/samples/springboot/update/ProductNotAvailableForAmountException.java b/springboot/src/main/java/io/temporal/samples/springboot/update/ProductNotAvailableForAmountException.java
index 56ce54e4a..602295cce 100644
--- a/springboot/src/main/java/io/temporal/samples/springboot/update/ProductNotAvailableForAmountException.java
+++ b/springboot/src/main/java/io/temporal/samples/springboot/update/ProductNotAvailableForAmountException.java
@@ -1,22 +1,3 @@
-/*
- * Copyright (c) 2020 Temporal Technologies, Inc. All Rights Reserved
- *
- * Copyright 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
- * Modifications copyright (C) 2017 Uber Technologies, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"). You may not
- * use this file except in compliance with the License. A copy of the License is
- * located at
- *
- * http://aws.amazon.com/apache2.0
- *
- * or in the "license" file accompanying this file. This file is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
package io.temporal.samples.springboot.update;
public class ProductNotAvailableForAmountException extends Exception {
diff --git a/springboot/src/main/java/io/temporal/samples/springboot/update/PurchaseActivities.java b/springboot/src/main/java/io/temporal/samples/springboot/update/PurchaseActivities.java
index 8be9aa256..27c140345 100644
--- a/springboot/src/main/java/io/temporal/samples/springboot/update/PurchaseActivities.java
+++ b/springboot/src/main/java/io/temporal/samples/springboot/update/PurchaseActivities.java
@@ -1,22 +1,3 @@
-/*
- * Copyright (c) 2020 Temporal Technologies, Inc. All Rights Reserved
- *
- * Copyright 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
- * Modifications copyright (C) 2017 Uber Technologies, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"). You may not
- * use this file except in compliance with the License. A copy of the License is
- * located at
- *
- * http://aws.amazon.com/apache2.0
- *
- * or in the "license" file accompanying this file. This file is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
package io.temporal.samples.springboot.update;
import io.temporal.activity.ActivityInterface;
diff --git a/springboot/src/main/java/io/temporal/samples/springboot/update/PurchaseActivitiesImpl.java b/springboot/src/main/java/io/temporal/samples/springboot/update/PurchaseActivitiesImpl.java
index 4f0596d59..cb868f7fe 100644
--- a/springboot/src/main/java/io/temporal/samples/springboot/update/PurchaseActivitiesImpl.java
+++ b/springboot/src/main/java/io/temporal/samples/springboot/update/PurchaseActivitiesImpl.java
@@ -1,22 +1,3 @@
-/*
- * Copyright (c) 2020 Temporal Technologies, Inc. All Rights Reserved
- *
- * Copyright 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
- * Modifications copyright (C) 2017 Uber Technologies, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"). You may not
- * use this file except in compliance with the License. A copy of the License is
- * located at
- *
- * http://aws.amazon.com/apache2.0
- *
- * or in the "license" file accompanying this file. This file is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
package io.temporal.samples.springboot.update;
import io.temporal.samples.springboot.update.model.Product;
diff --git a/springboot/src/main/java/io/temporal/samples/springboot/update/PurchaseWorkflow.java b/springboot/src/main/java/io/temporal/samples/springboot/update/PurchaseWorkflow.java
index d5f086683..92db36d0a 100644
--- a/springboot/src/main/java/io/temporal/samples/springboot/update/PurchaseWorkflow.java
+++ b/springboot/src/main/java/io/temporal/samples/springboot/update/PurchaseWorkflow.java
@@ -1,22 +1,3 @@
-/*
- * Copyright (c) 2020 Temporal Technologies, Inc. All Rights Reserved
- *
- * Copyright 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
- * Modifications copyright (C) 2017 Uber Technologies, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"). You may not
- * use this file except in compliance with the License. A copy of the License is
- * located at
- *
- * http://aws.amazon.com/apache2.0
- *
- * or in the "license" file accompanying this file. This file is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
package io.temporal.samples.springboot.update;
import io.temporal.samples.springboot.update.model.Purchase;
diff --git a/springboot/src/main/java/io/temporal/samples/springboot/update/PurchaseWorkflowImpl.java b/springboot/src/main/java/io/temporal/samples/springboot/update/PurchaseWorkflowImpl.java
index bc04b3f41..ac62b7172 100644
--- a/springboot/src/main/java/io/temporal/samples/springboot/update/PurchaseWorkflowImpl.java
+++ b/springboot/src/main/java/io/temporal/samples/springboot/update/PurchaseWorkflowImpl.java
@@ -1,22 +1,3 @@
-/*
- * Copyright (c) 2020 Temporal Technologies, Inc. All Rights Reserved
- *
- * Copyright 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
- * Modifications copyright (C) 2017 Uber Technologies, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"). You may not
- * use this file except in compliance with the License. A copy of the License is
- * located at
- *
- * http://aws.amazon.com/apache2.0
- *
- * or in the "license" file accompanying this file. This file is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
package io.temporal.samples.springboot.update;
import io.temporal.activity.LocalActivityOptions;
diff --git a/springboot/src/main/java/io/temporal/samples/springboot/update/ResourceNotFoundException.java b/springboot/src/main/java/io/temporal/samples/springboot/update/ResourceNotFoundException.java
index 21cfc71ac..448f5c0bf 100644
--- a/springboot/src/main/java/io/temporal/samples/springboot/update/ResourceNotFoundException.java
+++ b/springboot/src/main/java/io/temporal/samples/springboot/update/ResourceNotFoundException.java
@@ -1,22 +1,3 @@
-/*
- * Copyright (c) 2020 Temporal Technologies, Inc. All Rights Reserved
- *
- * Copyright 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
- * Modifications copyright (C) 2017 Uber Technologies, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"). You may not
- * use this file except in compliance with the License. A copy of the License is
- * located at
- *
- * http://aws.amazon.com/apache2.0
- *
- * or in the "license" file accompanying this file. This file is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
package io.temporal.samples.springboot.update;
import org.springframework.http.HttpStatus;
diff --git a/springboot/src/main/java/io/temporal/samples/springboot/update/model/Product.java b/springboot/src/main/java/io/temporal/samples/springboot/update/model/Product.java
index 74e39b7b3..f4e20830d 100644
--- a/springboot/src/main/java/io/temporal/samples/springboot/update/model/Product.java
+++ b/springboot/src/main/java/io/temporal/samples/springboot/update/model/Product.java
@@ -1,22 +1,3 @@
-/*
- * Copyright (c) 2020 Temporal Technologies, Inc. All Rights Reserved
- *
- * Copyright 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
- * Modifications copyright (C) 2017 Uber Technologies, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"). You may not
- * use this file except in compliance with the License. A copy of the License is
- * located at
- *
- * http://aws.amazon.com/apache2.0
- *
- * or in the "license" file accompanying this file. This file is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
package io.temporal.samples.springboot.update.model;
import javax.persistence.*;
diff --git a/springboot/src/main/java/io/temporal/samples/springboot/update/model/ProductRepository.java b/springboot/src/main/java/io/temporal/samples/springboot/update/model/ProductRepository.java
index 5d8d2dd99..fec2f75b7 100644
--- a/springboot/src/main/java/io/temporal/samples/springboot/update/model/ProductRepository.java
+++ b/springboot/src/main/java/io/temporal/samples/springboot/update/model/ProductRepository.java
@@ -1,22 +1,3 @@
-/*
- * Copyright (c) 2020 Temporal Technologies, Inc. All Rights Reserved
- *
- * Copyright 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
- * Modifications copyright (C) 2017 Uber Technologies, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"). You may not
- * use this file except in compliance with the License. A copy of the License is
- * located at
- *
- * http://aws.amazon.com/apache2.0
- *
- * or in the "license" file accompanying this file. This file is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
package io.temporal.samples.springboot.update.model;
import org.springframework.data.jpa.repository.JpaRepository;
diff --git a/springboot/src/main/java/io/temporal/samples/springboot/update/model/Purchase.java b/springboot/src/main/java/io/temporal/samples/springboot/update/model/Purchase.java
index 3457c65a4..7cc6d9bc6 100644
--- a/springboot/src/main/java/io/temporal/samples/springboot/update/model/Purchase.java
+++ b/springboot/src/main/java/io/temporal/samples/springboot/update/model/Purchase.java
@@ -1,22 +1,3 @@
-/*
- * Copyright (c) 2020 Temporal Technologies, Inc. All Rights Reserved
- *
- * Copyright 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
- * Modifications copyright (C) 2017 Uber Technologies, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"). You may not
- * use this file except in compliance with the License. A copy of the License is
- * located at
- *
- * http://aws.amazon.com/apache2.0
- *
- * or in the "license" file accompanying this file. This file is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
package io.temporal.samples.springboot.update.model;
public class Purchase {
diff --git a/springboot/src/test/java/io/temporal/samples/springboot/CamelSampleTest.java b/springboot/src/test/java/io/temporal/samples/springboot/CamelSampleTest.java
index d751bc426..06d4680ca 100644
--- a/springboot/src/test/java/io/temporal/samples/springboot/CamelSampleTest.java
+++ b/springboot/src/test/java/io/temporal/samples/springboot/CamelSampleTest.java
@@ -1,22 +1,3 @@
-/*
- * Copyright (c) 2020 Temporal Technologies, Inc. All Rights Reserved
- *
- * Copyright 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
- * Modifications copyright (C) 2017 Uber Technologies, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"). You may not
- * use this file except in compliance with the License. A copy of the License is
- * located at
- *
- * http://aws.amazon.com/apache2.0
- *
- * or in the "license" file accompanying this file. This file is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
package io.temporal.samples.springboot;
import io.temporal.client.WorkflowClient;
diff --git a/springboot/src/test/java/io/temporal/samples/springboot/CustomizeSampleTest.java b/springboot/src/test/java/io/temporal/samples/springboot/CustomizeSampleTest.java
index 5e9d82f52..9584f7b13 100644
--- a/springboot/src/test/java/io/temporal/samples/springboot/CustomizeSampleTest.java
+++ b/springboot/src/test/java/io/temporal/samples/springboot/CustomizeSampleTest.java
@@ -1,22 +1,3 @@
-/*
- * Copyright (c) 2020 Temporal Technologies, Inc. All Rights Reserved
- *
- * Copyright 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
- * Modifications copyright (C) 2017 Uber Technologies, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"). You may not
- * use this file except in compliance with the License. A copy of the License is
- * located at
- *
- * http://aws.amazon.com/apache2.0
- *
- * or in the "license" file accompanying this file. This file is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
package io.temporal.samples.springboot;
import io.temporal.client.WorkflowClient;
diff --git a/springboot/src/test/java/io/temporal/samples/springboot/HelloSampleTest.java b/springboot/src/test/java/io/temporal/samples/springboot/HelloSampleTest.java
index 0fcf65da3..f2019c878 100644
--- a/springboot/src/test/java/io/temporal/samples/springboot/HelloSampleTest.java
+++ b/springboot/src/test/java/io/temporal/samples/springboot/HelloSampleTest.java
@@ -1,22 +1,3 @@
-/*
- * Copyright (c) 2020 Temporal Technologies, Inc. All Rights Reserved
- *
- * Copyright 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
- * Modifications copyright (C) 2017 Uber Technologies, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"). You may not
- * use this file except in compliance with the License. A copy of the License is
- * located at
- *
- * http://aws.amazon.com/apache2.0
- *
- * or in the "license" file accompanying this file. This file is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
package io.temporal.samples.springboot;
import io.temporal.client.WorkflowClient;
diff --git a/springboot/src/test/java/io/temporal/samples/springboot/HelloSampleTestMockedActivity.java b/springboot/src/test/java/io/temporal/samples/springboot/HelloSampleTestMockedActivity.java
index 53f62ee0d..eab0c93e8 100644
--- a/springboot/src/test/java/io/temporal/samples/springboot/HelloSampleTestMockedActivity.java
+++ b/springboot/src/test/java/io/temporal/samples/springboot/HelloSampleTestMockedActivity.java
@@ -1,22 +1,3 @@
-/*
- * Copyright (c) 2020 Temporal Technologies, Inc. All Rights Reserved
- *
- * Copyright 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
- * Modifications copyright (C) 2017 Uber Technologies, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"). You may not
- * use this file except in compliance with the License. A copy of the License is
- * located at
- *
- * http://aws.amazon.com/apache2.0
- *
- * or in the "license" file accompanying this file. This file is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
package io.temporal.samples.springboot;
import static org.mockito.ArgumentMatchers.any;
diff --git a/springboot/src/test/java/io/temporal/samples/springboot/KafkaConsumerTestHelper.java b/springboot/src/test/java/io/temporal/samples/springboot/KafkaConsumerTestHelper.java
index 418aab421..1223982be 100644
--- a/springboot/src/test/java/io/temporal/samples/springboot/KafkaConsumerTestHelper.java
+++ b/springboot/src/test/java/io/temporal/samples/springboot/KafkaConsumerTestHelper.java
@@ -1,22 +1,3 @@
-/*
- * Copyright (c) 2020 Temporal Technologies, Inc. All Rights Reserved
- *
- * Copyright 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
- * Modifications copyright (C) 2017 Uber Technologies, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"). You may not
- * use this file except in compliance with the License. A copy of the License is
- * located at
- *
- * http://aws.amazon.com/apache2.0
- *
- * or in the "license" file accompanying this file. This file is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
package io.temporal.samples.springboot;
import java.util.concurrent.CountDownLatch;
diff --git a/springboot/src/test/java/io/temporal/samples/springboot/KafkaSampleTest.java b/springboot/src/test/java/io/temporal/samples/springboot/KafkaSampleTest.java
index 97068118e..a1c7a852a 100644
--- a/springboot/src/test/java/io/temporal/samples/springboot/KafkaSampleTest.java
+++ b/springboot/src/test/java/io/temporal/samples/springboot/KafkaSampleTest.java
@@ -1,22 +1,3 @@
-/*
- * Copyright (c) 2020 Temporal Technologies, Inc. All Rights Reserved
- *
- * Copyright 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
- * Modifications copyright (C) 2017 Uber Technologies, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"). You may not
- * use this file except in compliance with the License. A copy of the License is
- * located at
- *
- * http://aws.amazon.com/apache2.0
- *
- * or in the "license" file accompanying this file. This file is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
package io.temporal.samples.springboot;
import io.temporal.client.WorkflowClient;
diff --git a/springboot/src/test/java/io/temporal/samples/springboot/UpdateSampleTest.java b/springboot/src/test/java/io/temporal/samples/springboot/UpdateSampleTest.java
index 1552631f6..15fe83beb 100644
--- a/springboot/src/test/java/io/temporal/samples/springboot/UpdateSampleTest.java
+++ b/springboot/src/test/java/io/temporal/samples/springboot/UpdateSampleTest.java
@@ -1,22 +1,3 @@
-/*
- * Copyright (c) 2020 Temporal Technologies, Inc. All Rights Reserved
- *
- * Copyright 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
- * Modifications copyright (C) 2017 Uber Technologies, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"). You may not
- * use this file except in compliance with the License. A copy of the License is
- * located at
- *
- * http://aws.amazon.com/apache2.0
- *
- * or in the "license" file accompanying this file. This file is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
package io.temporal.samples.springboot;
import static org.junit.jupiter.api.Assertions.assertThrows;
diff --git a/springboot/src/test/resources/application.yaml b/springboot/src/test/resources/application.yaml
index b81a11934..017d28f90 100644
--- a/springboot/src/test/resources/application.yaml
+++ b/springboot/src/test/resources/application.yaml
@@ -15,6 +15,7 @@ spring:
# enable test server for testing
test-server:
enabled: true
+ ignore-duplicate-definitions: true
# data source config for tests that need it
datasource:
url: jdbc:h2:mem:test;DB_CLOSE_DELAY=-1;DATABASE_TO_UPPER=false;DB_CLOSE_ON_EXIT=FALSE;