diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 5f5ff7bcf9..4b6805df5a 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -39,7 +39,7 @@ jobs: GOPROXY: https://proxy.golang.org JDK_VER: ${{ matrix.java }} DAPR_CLI_VER: 1.15.0 - DAPR_RUNTIME_VER: 1.16.0-rc.2 + DAPR_RUNTIME_VER: 1.16.0-rc.3 DAPR_INSTALL_URL: https://raw.githubusercontent.com/dapr/cli/v1.15.0/install/install.sh DAPR_CLI_REF: DAPR_REF: diff --git a/.github/workflows/validate.yml b/.github/workflows/validate.yml index 349c61b932..dd052bbcd4 100644 --- a/.github/workflows/validate.yml +++ b/.github/workflows/validate.yml @@ -38,7 +38,7 @@ jobs: GOPROXY: https://proxy.golang.org JDK_VER: ${{ matrix.java }} DAPR_CLI_VER: 1.15.0 - DAPR_RUNTIME_VER: 1.16.0-rc.2 + DAPR_RUNTIME_VER: 1.16.0-rc.3 DAPR_INSTALL_URL: https://raw.githubusercontent.com/dapr/cli/v1.15.0/install/install.sh DAPR_CLI_REF: DAPR_REF: @@ -107,12 +107,26 @@ jobs: pip3 install mechanical-markdown - name: Verify scheduler is listening on port. run: sleep 30 && docker logs dapr_scheduler && nc -vz localhost 50006 - - name: Clean up files - run: ./mvnw clean - - name: Build sdk - run: ./mvnw compile -q - name: Install jars - run: ./mvnw install -q + run: ./mvnw clean install -DskipTests -q + env: + DOCKER_HOST: ${{steps.setup_docker.outputs.sock}} + - name: Validate workflows example + working-directory: ./examples + run: | + mm.py ./src/main/java/io/dapr/examples/workflows/README.md + env: + DOCKER_HOST: ${{steps.setup_docker.outputs.sock}} + - name: Validate Spring Boot examples + working-directory: ./spring-boot-examples + run: | + mm.py README.md + env: + DOCKER_HOST: ${{steps.setup_docker.outputs.sock}} + - name: Validate Spring Boot Workflow examples + working-directory: ./spring-boot-examples/workflows + run: | + mm.py README.md env: DOCKER_HOST: ${{steps.setup_docker.outputs.sock}} - name: Validate Jobs example @@ -199,27 +213,10 @@ jobs: mm.py ./src/main/java/io/dapr/examples/querystate/README.md env: DOCKER_HOST: ${{steps.setup_docker.outputs.sock}} - - name: Validate workflows example - working-directory: ./examples - run: | - mm.py ./src/main/java/io/dapr/examples/workflows/README.md - env: - DOCKER_HOST: ${{steps.setup_docker.outputs.sock}} - name: Validate streaming subscription example working-directory: ./examples run: | mm.py ./src/main/java/io/dapr/examples/pubsub/stream/README.md env: DOCKER_HOST: ${{steps.setup_docker.outputs.sock}} - - name: Validate Spring Boot examples - working-directory: ./spring-boot-examples - run: | - mm.py README.md - env: - DOCKER_HOST: ${{steps.setup_docker.outputs.sock}} - - name: Validate Spring Boot Workflow examples - working-directory: ./spring-boot-examples/workflows - run: | - mm.py README.md - env: - DOCKER_HOST: ${{steps.setup_docker.outputs.sock}} + diff --git a/daprdocs/content/en/java-sdk-docs/spring-boot/_index.md b/daprdocs/content/en/java-sdk-docs/spring-boot/_index.md index 25f0646d3a..e77b1671f3 100644 --- a/daprdocs/content/en/java-sdk-docs/spring-boot/_index.md +++ b/daprdocs/content/en/java-sdk-docs/spring-boot/_index.md @@ -95,7 +95,7 @@ public class DaprTestContainersConfig { @ServiceConnection public DaprContainer daprContainer(Network daprNetwork, PostgreSQLContainer postgreSQLContainer){ - return new DaprContainer("daprio/daprd:1.16.0-rc.2") + return new DaprContainer("daprio/daprd:1.16.0-rc.3") .withAppName("producer-app") .withNetwork(daprNetwork) .withComponent(new Component("kvstore", "state.postgresql", "v1", STATE_STORE_PROPERTIES)) @@ -250,7 +250,7 @@ Finally, because Dapr PubSub requires a bidirectional connection between your ap @ServiceConnection public DaprContainer daprContainer(Network daprNetwork, PostgreSQLContainer postgreSQLContainer, RabbitMQContainer rabbitMQContainer){ - return new DaprContainer("daprio/daprd:1.16.0-rc.2") + return new DaprContainer("daprio/daprd:1.16.0-rc.3") .withAppName("producer-app") .withNetwork(daprNetwork) .withComponent(new Component("kvstore", "state.postgresql", "v1", STATE_STORE_PROPERTIES)) diff --git a/examples/src/main/java/io/dapr/examples/pubsub/stream/README.md b/examples/src/main/java/io/dapr/examples/pubsub/stream/README.md index e127a6fdaa..d9d41b3759 100644 --- a/examples/src/main/java/io/dapr/examples/pubsub/stream/README.md +++ b/examples/src/main/java/io/dapr/examples/pubsub/stream/README.md @@ -93,7 +93,8 @@ expected_stdout_lines: - '== APP == Subscriber got: This is message #0' - '== APP == Subscriber got: This is message #1' background: true -sleep: 30 +sleep: 15 +timeout_seconds: 30 --> ```bash @@ -111,6 +112,7 @@ expected_stdout_lines: - '== APP == Published message: This is message #1' background: true sleep: 15 +timeout_seconds: 30 --> ```bash diff --git a/examples/src/main/java/io/dapr/examples/tracing/InvokeClient.java b/examples/src/main/java/io/dapr/examples/tracing/InvokeClient.java index ead7c25a01..62a9768746 100644 --- a/examples/src/main/java/io/dapr/examples/tracing/InvokeClient.java +++ b/examples/src/main/java/io/dapr/examples/tracing/InvokeClient.java @@ -75,6 +75,7 @@ public static void main(String[] args) throws Exception { openTelemetrySdk.getSdkTracerProvider().shutdown(); Validation.validate(); System.out.println("Done"); + System.exit(0); } } } diff --git a/examples/src/main/java/io/dapr/examples/tracing/README.md b/examples/src/main/java/io/dapr/examples/tracing/README.md index 2afc6b1ecc..707dae01a7 100644 --- a/examples/src/main/java/io/dapr/examples/tracing/README.md +++ b/examples/src/main/java/io/dapr/examples/tracing/README.md @@ -138,6 +138,7 @@ name: Run demo service expected_stdout_lines: background: true sleep: 20 +timeout_seconds: 40 --> ```bash @@ -225,6 +226,7 @@ name: Run proxy service expected_stdout_lines: background: true sleep: 20 +timeout_seconds: 40 --> ```bash @@ -284,6 +286,7 @@ expected_stdout_lines: - '== APP == Done' background: true sleep: 20 +timeout_seconds: 40 --> ```bash diff --git a/examples/src/main/java/io/dapr/examples/workflows/README.md b/examples/src/main/java/io/dapr/examples/workflows/README.md index b90726080a..109e29ced9 100644 --- a/examples/src/main/java/io/dapr/examples/workflows/README.md +++ b/examples/src/main/java/io/dapr/examples/workflows/README.md @@ -142,13 +142,12 @@ expected_stdout_lines: - 'Message Received from input: Seattle' - 'Sending message to output: SEATTLE' - 'Workflow finished with result: TOKYO, LONDON, SEATTLE' +timeout_seconds: 20 background: true -sleep: 60 -timeout_seconds: 60 --> Execute the following script in order to run DemoChainWorker: ```sh -dapr run --app-id demoworkflowworker --resources-path ./components/workflows --dapr-grpc-port 50001 -- java -jar target/dapr-java-sdk-examples-exec.jar io.dapr.examples.workflows.chain.DemoChainWorker +dapr run --app-id demoworkflowworker --resources-path ./components/workflows --dapr-grpc-port 50001 -- java -jar target/dapr-java-sdk-examples-exec.jar io.dapr.examples.workflows.chain.DemoChainWorker 50001 ``` Once running, the logs will start displaying the different steps: First, you can see workflow is starting: @@ -158,9 +157,19 @@ Once running, the logs will start displaying the different steps: First, you can == APP == INFO: Durable Task worker is connecting to sidecar at 127.0.0.1:50001. ``` + + + Then, execute the following script in order to run DemoChainClient: ```sh -java -jar target/dapr-java-sdk-examples-exec.jar io.dapr.examples.workflows.chain.DemoChainClient +sleep 10 && java -jar target/dapr-java-sdk-examples-exec.jar io.dapr.examples.workflows.chain.DemoChainClient 50001 ``` @@ -241,7 +250,7 @@ public class CountWordsActivity implements WorkflowActivity { } ``` Execute the following script in order to run DemoFanInOutWorker: ```sh -dapr run --app-id demoworkflowworker --resources-path ./components/workflows --dapr-grpc-port 50001 -- java -jar target/dapr-java-sdk-examples-exec.jar io.dapr.examples.workflows.faninout.DemoFanInOutWorker +dapr run --app-id demoworkflowworker --resources-path ./components/workflows --dapr-grpc-port 50002 -- java -jar target/dapr-java-sdk-examples-exec.jar io.dapr.examples.workflows.faninout.DemoFanInOutWorker 50002 ``` + + + Execute the following script in order to run DemoFanInOutClient: ```sh -java -jar target/dapr-java-sdk-examples-exec.jar io.dapr.examples.workflows.faninout.DemoFanInOutClient +sleep 10 && java -jar target/dapr-java-sdk-examples-exec.jar io.dapr.examples.workflows.faninout.DemoFanInOutClient 50002 ``` @@ -294,7 +312,6 @@ and the client: Started a new fan out/fan in model model workflow with instance ID: 092c1928-b5dd-4576-9468-300bf6aed986 workflow instance with ID: 092c1928-b5dd-4576-9468-300bf6aed986 completed with result: 60 ``` - ### Continue As New Pattern `ContinueAsNew` API allows you to restart the workflow with a new input. @@ -606,8 +623,6 @@ expected_stdout_lines: - "Registered Activity: CancelCarActivity" - "Successfully built dapr workflow runtime" - "Start workflow runtime" - - "Durable Task worker is connecting to sidecar at 127.0.0.1:50001." - - "Starting Workflow: io.dapr.examples.workflows.compensation.BookTripWorkflow" - "Starting Activity: io.dapr.examples.workflows.compensation.BookFlightActivity" - "Activity completed with result: Flight booked successfully" @@ -625,18 +640,27 @@ expected_stdout_lines: - "Starting Activity: io.dapr.examples.workflows.compensation.CancelFlightActivity" - "Activity completed with result: Flight canceled successfully" background: true -sleep: 60 -timeout_seconds: 60 +timeout_seconds: 30 --> Execute the following script in order to run the BookTripWorker: ```sh -dapr run --app-id book-trip-worker --resources-path ./components/workflows --dapr-grpc-port 50001 -- java -jar target/dapr-java-sdk-examples-exec.jar io.dapr.examples.workflows.compensation.BookTripWorker +dapr run --app-id book-trip-worker --resources-path ./components/workflows --dapr-grpc-port 50003 -- java -jar target/dapr-java-sdk-examples-exec.jar io.dapr.examples.workflows.compensation.BookTripWorker 50003 ``` + + + Once running, execute the following script to run the BookTripClient: ```sh -java -jar target/dapr-java-sdk-examples-exec.jar io.dapr.examples.workflows.compensation.BookTripClient +sleep 15 && java -jar target/dapr-java-sdk-examples-exec.jar io.dapr.examples.workflows.compensation.BookTripClient 50003 ``` @@ -656,7 +680,7 @@ Key Points: ### Suspend/Resume Pattern -Workflow instances can be suspended and resumed. This example shows how to use the suspend and resume commands. +Workflow instances can be suspended and resumed. This example shows how to use the suspend and resume commands. For testing the suspend and resume operations we will use the same workflow definition used by the DemoExternalEventWorkflow. @@ -669,26 +693,34 @@ match_order: none output_match_mode: substring expected_stdout_lines: - "Waiting for approval..." - - "Suspending Workflow Instance" - - "Workflow Instance Status: SUSPENDED" - - "Let's resume the Workflow Instance before sending the external event" - - "Workflow Instance Status: RUNNING" - - "Now that the instance is RUNNING again, lets send the external event." - "approval granted - do the approved action" - "Starting Activity: io.dapr.examples.workflows.externalevent.ApproveActivity" - "Running approval activity..." - "approval-activity finished" background: true -sleep: 60 -timeout_seconds: 60 +timeout_seconds: 30 --> ```sh -dapr run --app-id demoworkflowworker --resources-path ./components/workflows --dapr-grpc-port 50001 -- java -jar target/dapr-java-sdk-examples-exec.jar io.dapr.examples.workflows.suspendresume.DemoSuspendResumeWorker +dapr run --app-id demoworkflowworker --resources-path ./components/workflows --dapr-grpc-port 50004 -- java -jar target/dapr-java-sdk-examples-exec.jar io.dapr.examples.workflows.suspendresume.DemoSuspendResumeWorker 50004 ``` + + + ```sh -java -jar target/dapr-java-sdk-examples-exec.jar io.dapr.examples.workflows.suspendresume.DemoSuspendResumeClient +sleep 15 && java -jar target/dapr-java-sdk-examples-exec.jar io.dapr.examples.workflows.suspendresume.DemoSuspendResumeClient 50004 ``` diff --git a/examples/src/main/java/io/dapr/examples/workflows/chain/DemoChainClient.java b/examples/src/main/java/io/dapr/examples/workflows/chain/DemoChainClient.java index 1a190b4f84..6c9eedbdc6 100644 --- a/examples/src/main/java/io/dapr/examples/workflows/chain/DemoChainClient.java +++ b/examples/src/main/java/io/dapr/examples/workflows/chain/DemoChainClient.java @@ -13,6 +13,7 @@ package io.dapr.examples.workflows.chain; +import io.dapr.examples.workflows.utils.PropertyUtils; import io.dapr.workflows.client.DaprWorkflowClient; import io.dapr.workflows.client.WorkflowInstanceStatus; @@ -26,7 +27,7 @@ public class DemoChainClient { * @throws InterruptedException If program has been interrupted. */ public static void main(String[] args) { - try (DaprWorkflowClient client = new DaprWorkflowClient()) { + try (DaprWorkflowClient client = new DaprWorkflowClient(PropertyUtils.getProperties(args))) { String instanceId = client.scheduleNewWorkflow(DemoChainWorkflow.class); System.out.printf("Started a new chaining model workflow with instance ID: %s%n", instanceId); WorkflowInstanceStatus workflowInstanceStatus = diff --git a/examples/src/main/java/io/dapr/examples/workflows/chain/DemoChainWorker.java b/examples/src/main/java/io/dapr/examples/workflows/chain/DemoChainWorker.java index 51fb9ae6aa..12b84772aa 100644 --- a/examples/src/main/java/io/dapr/examples/workflows/chain/DemoChainWorker.java +++ b/examples/src/main/java/io/dapr/examples/workflows/chain/DemoChainWorker.java @@ -13,6 +13,7 @@ package io.dapr.examples.workflows.chain; +import io.dapr.examples.workflows.utils.PropertyUtils; import io.dapr.workflows.runtime.WorkflowRuntime; import io.dapr.workflows.runtime.WorkflowRuntimeBuilder; @@ -25,7 +26,7 @@ public class DemoChainWorker { */ public static void main(String[] args) throws Exception { // Register the Workflow with the builder. - WorkflowRuntimeBuilder builder = new WorkflowRuntimeBuilder().registerWorkflow(DemoChainWorkflow.class); + WorkflowRuntimeBuilder builder = new WorkflowRuntimeBuilder(PropertyUtils.getProperties(args)).registerWorkflow(DemoChainWorkflow.class); builder.registerActivity(ToUpperCaseActivity.class); // Build and then start the workflow runtime pulling and executing tasks diff --git a/examples/src/main/java/io/dapr/examples/workflows/childworkflow/DemoChildWorkerflowClient.java b/examples/src/main/java/io/dapr/examples/workflows/childworkflow/DemoChildWorkerflowClient.java index 139f93e414..80f647c17c 100644 --- a/examples/src/main/java/io/dapr/examples/workflows/childworkflow/DemoChildWorkerflowClient.java +++ b/examples/src/main/java/io/dapr/examples/workflows/childworkflow/DemoChildWorkerflowClient.java @@ -13,6 +13,7 @@ package io.dapr.examples.workflows.childworkflow; +import io.dapr.examples.workflows.utils.PropertyUtils; import io.dapr.workflows.client.DaprWorkflowClient; import io.dapr.workflows.client.WorkflowInstanceStatus; @@ -26,7 +27,7 @@ public class DemoChildWorkerflowClient { * @throws InterruptedException If program has been interrupted. */ public static void main(String[] args) { - try (DaprWorkflowClient client = new DaprWorkflowClient()) { + try (DaprWorkflowClient client = new DaprWorkflowClient(PropertyUtils.getProperties(args))) { String instanceId = client.scheduleNewWorkflow(DemoWorkflow.class); System.out.printf("Started a new child-workflow model workflow with instance ID: %s%n", instanceId); WorkflowInstanceStatus workflowInstanceStatus = diff --git a/examples/src/main/java/io/dapr/examples/workflows/childworkflow/DemoChildWorkflowWorker.java b/examples/src/main/java/io/dapr/examples/workflows/childworkflow/DemoChildWorkflowWorker.java index dce40e97e3..de3f490310 100644 --- a/examples/src/main/java/io/dapr/examples/workflows/childworkflow/DemoChildWorkflowWorker.java +++ b/examples/src/main/java/io/dapr/examples/workflows/childworkflow/DemoChildWorkflowWorker.java @@ -13,6 +13,7 @@ package io.dapr.examples.workflows.childworkflow; +import io.dapr.examples.workflows.utils.PropertyUtils; import io.dapr.workflows.runtime.WorkflowRuntime; import io.dapr.workflows.runtime.WorkflowRuntimeBuilder; @@ -25,7 +26,7 @@ public class DemoChildWorkflowWorker { */ public static void main(String[] args) throws Exception { // Register the Workflow with the builder. - WorkflowRuntimeBuilder builder = new WorkflowRuntimeBuilder() + WorkflowRuntimeBuilder builder = new WorkflowRuntimeBuilder(PropertyUtils.getProperties(args)) .registerWorkflow(DemoWorkflow.class) .registerWorkflow(DemoChildWorkflow.class); builder.registerActivity(ReverseActivity.class); diff --git a/examples/src/main/java/io/dapr/examples/workflows/compensation/BookTripClient.java b/examples/src/main/java/io/dapr/examples/workflows/compensation/BookTripClient.java index 212c1f0a1e..ce76d5de11 100644 --- a/examples/src/main/java/io/dapr/examples/workflows/compensation/BookTripClient.java +++ b/examples/src/main/java/io/dapr/examples/workflows/compensation/BookTripClient.java @@ -13,6 +13,7 @@ package io.dapr.examples.workflows.compensation; +import io.dapr.examples.workflows.utils.PropertyUtils; import io.dapr.workflows.client.DaprWorkflowClient; import io.dapr.workflows.client.WorkflowInstanceStatus; @@ -21,7 +22,7 @@ public class BookTripClient { public static void main(String[] args) { - try (DaprWorkflowClient client = new DaprWorkflowClient()) { + try (DaprWorkflowClient client = new DaprWorkflowClient(PropertyUtils.getProperties(args))) { String instanceId = client.scheduleNewWorkflow(BookTripWorkflow.class); System.out.printf("Started a new trip booking workflow with instance ID: %s%n", instanceId); diff --git a/examples/src/main/java/io/dapr/examples/workflows/compensation/BookTripWorker.java b/examples/src/main/java/io/dapr/examples/workflows/compensation/BookTripWorker.java index d32ade26a1..fcb5cc45fa 100644 --- a/examples/src/main/java/io/dapr/examples/workflows/compensation/BookTripWorker.java +++ b/examples/src/main/java/io/dapr/examples/workflows/compensation/BookTripWorker.java @@ -13,6 +13,7 @@ package io.dapr.examples.workflows.compensation; +import io.dapr.examples.workflows.utils.PropertyUtils; import io.dapr.workflows.runtime.WorkflowRuntime; import io.dapr.workflows.runtime.WorkflowRuntimeBuilder; @@ -20,7 +21,7 @@ public class BookTripWorker { public static void main(String[] args) throws Exception { // Register the Workflow with the builder - WorkflowRuntimeBuilder builder = new WorkflowRuntimeBuilder() + WorkflowRuntimeBuilder builder = new WorkflowRuntimeBuilder(PropertyUtils.getProperties(args)) .registerWorkflow(BookTripWorkflow.class) .registerActivity(BookFlightActivity.class) .registerActivity(CancelFlightActivity.class) diff --git a/examples/src/main/java/io/dapr/examples/workflows/continueasnew/DemoContinueAsNewClient.java b/examples/src/main/java/io/dapr/examples/workflows/continueasnew/DemoContinueAsNewClient.java index a47edb6c32..5827fa2c20 100644 --- a/examples/src/main/java/io/dapr/examples/workflows/continueasnew/DemoContinueAsNewClient.java +++ b/examples/src/main/java/io/dapr/examples/workflows/continueasnew/DemoContinueAsNewClient.java @@ -13,6 +13,7 @@ package io.dapr.examples.workflows.continueasnew; +import io.dapr.examples.workflows.utils.PropertyUtils; import io.dapr.workflows.client.DaprWorkflowClient; import java.util.concurrent.TimeoutException; @@ -25,7 +26,7 @@ public class DemoContinueAsNewClient { * @throws InterruptedException If program has been interrupted. */ public static void main(String[] args) { - try (DaprWorkflowClient client = new DaprWorkflowClient()) { + try (DaprWorkflowClient client = new DaprWorkflowClient(PropertyUtils.getProperties(args))) { String instanceId = client.scheduleNewWorkflow(DemoContinueAsNewWorkflow.class); System.out.printf("Started a new continue-as-new model workflow with instance ID: %s%n", instanceId); diff --git a/examples/src/main/java/io/dapr/examples/workflows/continueasnew/DemoContinueAsNewWorker.java b/examples/src/main/java/io/dapr/examples/workflows/continueasnew/DemoContinueAsNewWorker.java index 43ef176a2e..90c9812c01 100644 --- a/examples/src/main/java/io/dapr/examples/workflows/continueasnew/DemoContinueAsNewWorker.java +++ b/examples/src/main/java/io/dapr/examples/workflows/continueasnew/DemoContinueAsNewWorker.java @@ -13,10 +13,10 @@ package io.dapr.examples.workflows.continueasnew; +import io.dapr.examples.workflows.utils.PropertyUtils; import io.dapr.workflows.runtime.WorkflowRuntime; import io.dapr.workflows.runtime.WorkflowRuntimeBuilder; -import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; public class DemoContinueAsNewWorker { @@ -28,7 +28,7 @@ public class DemoContinueAsNewWorker { */ public static void main(String[] args) throws Exception { // Register the Workflow with the builder. - WorkflowRuntimeBuilder builder = new WorkflowRuntimeBuilder(). + WorkflowRuntimeBuilder builder = new WorkflowRuntimeBuilder(PropertyUtils.getProperties(args)). registerWorkflow(DemoContinueAsNewWorkflow.class) .withExecutorService(Executors.newFixedThreadPool(3)); builder.registerActivity(CleanUpActivity.class); diff --git a/examples/src/main/java/io/dapr/examples/workflows/externalevent/DemoExternalEventClient.java b/examples/src/main/java/io/dapr/examples/workflows/externalevent/DemoExternalEventClient.java index adae11a997..f827f2f709 100644 --- a/examples/src/main/java/io/dapr/examples/workflows/externalevent/DemoExternalEventClient.java +++ b/examples/src/main/java/io/dapr/examples/workflows/externalevent/DemoExternalEventClient.java @@ -13,6 +13,7 @@ package io.dapr.examples.workflows.externalevent; +import io.dapr.examples.workflows.utils.PropertyUtils; import io.dapr.workflows.client.DaprWorkflowClient; import java.util.concurrent.TimeoutException; @@ -25,7 +26,7 @@ public class DemoExternalEventClient { * @throws InterruptedException If program has been interrupted. */ public static void main(String[] args) { - try (DaprWorkflowClient client = new DaprWorkflowClient()) { + try (DaprWorkflowClient client = new DaprWorkflowClient(PropertyUtils.getProperties(args))) { String instanceId = client.scheduleNewWorkflow(DemoExternalEventWorkflow.class); System.out.printf("Started a new external-event workflow with instance ID: %s%n", instanceId); diff --git a/examples/src/main/java/io/dapr/examples/workflows/externalevent/DemoExternalEventWorker.java b/examples/src/main/java/io/dapr/examples/workflows/externalevent/DemoExternalEventWorker.java index f7d0c8ebf5..527bbb1453 100644 --- a/examples/src/main/java/io/dapr/examples/workflows/externalevent/DemoExternalEventWorker.java +++ b/examples/src/main/java/io/dapr/examples/workflows/externalevent/DemoExternalEventWorker.java @@ -13,6 +13,7 @@ package io.dapr.examples.workflows.externalevent; +import io.dapr.examples.workflows.utils.PropertyUtils; import io.dapr.workflows.runtime.WorkflowRuntime; import io.dapr.workflows.runtime.WorkflowRuntimeBuilder; @@ -25,7 +26,7 @@ public class DemoExternalEventWorker { */ public static void main(String[] args) throws Exception { // Register the Workflow with the builder. - WorkflowRuntimeBuilder builder = new WorkflowRuntimeBuilder().registerWorkflow(DemoExternalEventWorkflow.class); + WorkflowRuntimeBuilder builder = new WorkflowRuntimeBuilder(PropertyUtils.getProperties(args)).registerWorkflow(DemoExternalEventWorkflow.class); builder.registerActivity(ApproveActivity.class); builder.registerActivity(DenyActivity.class); diff --git a/examples/src/main/java/io/dapr/examples/workflows/faninout/DemoFanInOutClient.java b/examples/src/main/java/io/dapr/examples/workflows/faninout/DemoFanInOutClient.java index 23a76b788c..612a8979d3 100644 --- a/examples/src/main/java/io/dapr/examples/workflows/faninout/DemoFanInOutClient.java +++ b/examples/src/main/java/io/dapr/examples/workflows/faninout/DemoFanInOutClient.java @@ -13,6 +13,7 @@ package io.dapr.examples.workflows.faninout; +import io.dapr.examples.workflows.utils.PropertyUtils; import io.dapr.workflows.client.DaprWorkflowClient; import io.dapr.workflows.client.WorkflowInstanceStatus; @@ -29,7 +30,7 @@ public class DemoFanInOutClient { * @throws InterruptedException If program has been interrupted. */ public static void main(String[] args) throws InterruptedException { - try (DaprWorkflowClient client = new DaprWorkflowClient()) { + try (DaprWorkflowClient client = new DaprWorkflowClient(PropertyUtils.getProperties(args))) { // The input is an arbitrary list of strings. List listOfStrings = Arrays.asList( "Hello, world!", diff --git a/examples/src/main/java/io/dapr/examples/workflows/faninout/DemoFanInOutWorker.java b/examples/src/main/java/io/dapr/examples/workflows/faninout/DemoFanInOutWorker.java index 4c691dbc35..44f6793d57 100644 --- a/examples/src/main/java/io/dapr/examples/workflows/faninout/DemoFanInOutWorker.java +++ b/examples/src/main/java/io/dapr/examples/workflows/faninout/DemoFanInOutWorker.java @@ -13,6 +13,7 @@ package io.dapr.examples.workflows.faninout; +import io.dapr.examples.workflows.utils.PropertyUtils; import io.dapr.workflows.runtime.WorkflowRuntime; import io.dapr.workflows.runtime.WorkflowRuntimeBuilder; @@ -25,7 +26,7 @@ public class DemoFanInOutWorker { */ public static void main(String[] args) throws Exception { // Register the Workflow with the builder. - WorkflowRuntimeBuilder builder = new WorkflowRuntimeBuilder().registerWorkflow(DemoFanInOutWorkflow.class); + WorkflowRuntimeBuilder builder = new WorkflowRuntimeBuilder(PropertyUtils.getProperties(args)).registerWorkflow(DemoFanInOutWorkflow.class); builder.registerActivity(CountWordsActivity.class); // Build and then start the workflow runtime pulling and executing tasks diff --git a/examples/src/main/java/io/dapr/examples/workflows/suspendresume/DemoSuspendResumeClient.java b/examples/src/main/java/io/dapr/examples/workflows/suspendresume/DemoSuspendResumeClient.java index 7e8289798c..5880c64f2d 100644 --- a/examples/src/main/java/io/dapr/examples/workflows/suspendresume/DemoSuspendResumeClient.java +++ b/examples/src/main/java/io/dapr/examples/workflows/suspendresume/DemoSuspendResumeClient.java @@ -14,6 +14,7 @@ package io.dapr.examples.workflows.suspendresume; import io.dapr.examples.workflows.externalevent.DemoExternalEventWorkflow; +import io.dapr.examples.workflows.utils.PropertyUtils; import io.dapr.workflows.client.DaprWorkflowClient; import io.dapr.workflows.client.WorkflowInstanceStatus; @@ -27,7 +28,7 @@ public class DemoSuspendResumeClient { * @throws InterruptedException If program has been interrupted. */ public static void main(String[] args) { - try (DaprWorkflowClient client = new DaprWorkflowClient()) { + try (DaprWorkflowClient client = new DaprWorkflowClient(PropertyUtils.getProperties(args))) { String instanceId = client.scheduleNewWorkflow(DemoExternalEventWorkflow.class); System.out.printf("Started a new external-event workflow with instance ID: %s%n", instanceId); diff --git a/examples/src/main/java/io/dapr/examples/workflows/suspendresume/DemoSuspendResumeWorker.java b/examples/src/main/java/io/dapr/examples/workflows/suspendresume/DemoSuspendResumeWorker.java index 5ca4bc34bb..6a2d9a24af 100644 --- a/examples/src/main/java/io/dapr/examples/workflows/suspendresume/DemoSuspendResumeWorker.java +++ b/examples/src/main/java/io/dapr/examples/workflows/suspendresume/DemoSuspendResumeWorker.java @@ -16,6 +16,7 @@ import io.dapr.examples.workflows.externalevent.ApproveActivity; import io.dapr.examples.workflows.externalevent.DemoExternalEventWorkflow; import io.dapr.examples.workflows.externalevent.DenyActivity; +import io.dapr.examples.workflows.utils.PropertyUtils; import io.dapr.workflows.runtime.WorkflowRuntime; import io.dapr.workflows.runtime.WorkflowRuntimeBuilder; @@ -28,7 +29,7 @@ public class DemoSuspendResumeWorker { */ public static void main(String[] args) throws Exception { // Register the Workflow with the builder. - WorkflowRuntimeBuilder builder = new WorkflowRuntimeBuilder().registerWorkflow(DemoExternalEventWorkflow.class); + WorkflowRuntimeBuilder builder = new WorkflowRuntimeBuilder(PropertyUtils.getProperties(args)).registerWorkflow(DemoExternalEventWorkflow.class); builder.registerActivity(ApproveActivity.class); builder.registerActivity(DenyActivity.class); diff --git a/examples/src/main/java/io/dapr/examples/workflows/utils/PropertyUtils.java b/examples/src/main/java/io/dapr/examples/workflows/utils/PropertyUtils.java new file mode 100644 index 0000000000..9d64e45d36 --- /dev/null +++ b/examples/src/main/java/io/dapr/examples/workflows/utils/PropertyUtils.java @@ -0,0 +1,32 @@ +/* + * Copyright 2025 The Dapr Authors + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and +limitations under the License. +*/ + +package io.dapr.examples.workflows.utils; + +import io.dapr.config.Properties; + +import java.util.HashMap; + +public class PropertyUtils { + + public static Properties getProperties(String[] args) { + Properties properties = new Properties(); + if (args != null && args.length > 0) { + properties = new Properties(new HashMap<>() {{ + put(Properties.GRPC_PORT, args[0]); + }}); + } + + return properties; + } +} diff --git a/pom.xml b/pom.xml index bd6fbf7db1..faa2b35889 100644 --- a/pom.xml +++ b/pom.xml @@ -17,7 +17,7 @@ 1.69.0 3.25.5 protoc - https://raw.githubusercontent.com/dapr/dapr/v1.16.0-rc.2/dapr/proto + https://raw.githubusercontent.com/dapr/dapr/v1.16.0-rc.3/dapr/proto 1.16.0-SNAPSHOT 0.16.0-SNAPSHOT 1.7.1 diff --git a/sdk/src/main/java/io/dapr/client/DaprClientImpl.java b/sdk/src/main/java/io/dapr/client/DaprClientImpl.java index 335e56b85f..8bae8f51d8 100644 --- a/sdk/src/main/java/io/dapr/client/DaprClientImpl.java +++ b/sdk/src/main/java/io/dapr/client/DaprClientImpl.java @@ -1314,44 +1314,44 @@ public Mono scheduleJob(ScheduleJobRequest scheduleJobRequest) { try { validateScheduleJobRequest(scheduleJobRequest); - DaprProtos.Job.Builder scheduleJobRequestBuilder = DaprProtos.Job.newBuilder(); - scheduleJobRequestBuilder.setName(scheduleJobRequest.getName()); + DaprProtos.Job.Builder jobBuilder = DaprProtos.Job.newBuilder(); + jobBuilder.setName(scheduleJobRequest.getName()); DateTimeFormatter iso8601Formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'") .withZone(ZoneOffset.UTC); if (scheduleJobRequest.getData() != null) { - scheduleJobRequestBuilder.setData(Any.newBuilder() + jobBuilder.setData(Any.newBuilder() .setValue(ByteString.copyFrom(scheduleJobRequest.getData())).build()); } if (scheduleJobRequest.getSchedule() != null) { - scheduleJobRequestBuilder.setSchedule(scheduleJobRequest.getSchedule().getExpression()); + jobBuilder.setSchedule(scheduleJobRequest.getSchedule().getExpression()); } if (scheduleJobRequest.getTtl() != null) { - scheduleJobRequestBuilder.setTtl(iso8601Formatter.format(scheduleJobRequest.getTtl())); + jobBuilder.setTtl(iso8601Formatter.format(scheduleJobRequest.getTtl())); } if (scheduleJobRequest.getRepeats() != null) { - scheduleJobRequestBuilder.setRepeats(scheduleJobRequest.getRepeats()); + jobBuilder.setRepeats(scheduleJobRequest.getRepeats()); } if (scheduleJobRequest.getDueTime() != null) { - scheduleJobRequestBuilder.setDueTime(iso8601Formatter.format(scheduleJobRequest.getDueTime())); + jobBuilder.setDueTime(iso8601Formatter.format(scheduleJobRequest.getDueTime())); } if (scheduleJobRequest.getFailurePolicy() != null) { - scheduleJobRequestBuilder.setFailurePolicy(getJobFailurePolicy(scheduleJobRequest.getFailurePolicy())); + jobBuilder.setFailurePolicy(getJobFailurePolicy(scheduleJobRequest.getFailurePolicy())); } - scheduleJobRequestBuilder.setOverwrite(scheduleJobRequest.getOverwrite()); Mono scheduleJobResponseMono = Mono.deferContextual(context -> this.createMono( it -> intercept(context, asyncStub) - .scheduleJobAlpha1(DaprProtos.ScheduleJobRequest.newBuilder() - .setJob(scheduleJobRequestBuilder.build()).build(), it) + .scheduleJobAlpha1(DaprProtos.ScheduleJobRequest.newBuilder() + .setOverwrite(scheduleJobRequest.getOverwrite()) + .setJob(jobBuilder.build()).build(), it) ) ); diff --git a/sdk/src/test/java/io/dapr/client/DaprPreviewClientGrpcTest.java b/sdk/src/test/java/io/dapr/client/DaprPreviewClientGrpcTest.java index 2db9358557..8f0667b8d3 100644 --- a/sdk/src/test/java/io/dapr/client/DaprPreviewClientGrpcTest.java +++ b/sdk/src/test/java/io/dapr/client/DaprPreviewClientGrpcTest.java @@ -22,15 +22,15 @@ import io.dapr.client.domain.BulkPublishRequest; import io.dapr.client.domain.BulkPublishResponse; import io.dapr.client.domain.CloudEvent; -import io.dapr.client.domain.DeleteJobRequest; -import io.dapr.client.domain.GetJobRequest; -import io.dapr.client.domain.GetJobResponse; import io.dapr.client.domain.ConstantFailurePolicy; -import io.dapr.client.domain.DropFailurePolicy; -import io.dapr.client.domain.JobSchedule; import io.dapr.client.domain.ConversationInput; import io.dapr.client.domain.ConversationRequest; import io.dapr.client.domain.ConversationResponse; +import io.dapr.client.domain.DeleteJobRequest; +import io.dapr.client.domain.DropFailurePolicy; +import io.dapr.client.domain.GetJobRequest; +import io.dapr.client.domain.GetJobResponse; +import io.dapr.client.domain.JobSchedule; import io.dapr.client.domain.QueryStateItem; import io.dapr.client.domain.QueryStateRequest; import io.dapr.client.domain.QueryStateResponse; @@ -1005,12 +1005,12 @@ public void scheduleJobShouldSucceedWhenNameAlreadyExistsWithOverwrite() { // Verify the first call doesn't have overwrite set DaprProtos.ScheduleJobRequest firstActualRequest = captor.getAllValues().get(0); - assertFalse(firstActualRequest.getJob().getOverwrite()); + assertFalse(firstActualRequest.getOverwrite()); assertEquals("testJob", firstActualRequest.getJob().getName()); // Verify the second call has overwrite set to true DaprProtos.ScheduleJobRequest secondActualRequest = captor.getAllValues().get(1); - assertTrue(secondActualRequest.getJob().getOverwrite()); + assertTrue(secondActualRequest.getOverwrite()); assertEquals("testJob", secondActualRequest.getJob().getName()); } diff --git a/spring-boot-examples/kubernetes/README.md b/spring-boot-examples/kubernetes/README.md index 106747e94e..2f3fddac8d 100644 --- a/spring-boot-examples/kubernetes/README.md +++ b/spring-boot-examples/kubernetes/README.md @@ -30,7 +30,7 @@ Once you have the cluster up and running you can install Dapr: helm repo add dapr https://dapr.github.io/helm-charts/ helm repo update helm upgrade --install dapr dapr/dapr \ ---version=1.16.0-rc.2 \ +--version=1.16.0-rc.3 \ --namespace dapr-system \ --create-namespace \ --wait diff --git a/spring-boot-examples/workflows/README.md b/spring-boot-examples/workflows/README.md index ae02d2ee6b..595857cb10 100644 --- a/spring-boot-examples/workflows/README.md +++ b/spring-boot-examples/workflows/README.md @@ -24,8 +24,7 @@ expected_stdout_lines: - 'Started WorkflowPatternsApplication' background: true expected_return_code: 143 -sleep: 30 -timeout_seconds: 45 +timeout_seconds: 180 --> @@ -67,15 +66,14 @@ output_match_mode: substring expected_stdout_lines: - 'TOKYO, LONDON, SEATTLE' background: true -sleep: 1 -timeout_seconds: 2 +timeout_seconds: 90 --> To start the workflow with the three chained activities you can run: ```sh -curl -X POST localhost:8080/wfp/chain -H 'Content-Type: application/json' +sleep 35 && curl -X POST localhost:8080/wfp/chain -H 'Content-Type: application/json' ``` @@ -145,15 +143,14 @@ output_match_mode: substring expected_stdout_lines: - '!wolfkroW rpaD olleH' background: true -sleep: 1 -timeout_seconds: 2 +timeout_seconds: 90 --> To start the workflow with the three chained activities you can run: ```sh -curl -X POST localhost:8080/wfp/child -H 'Content-Type: application/json' +sleep 35 && curl -X POST localhost:8080/wfp/child -H 'Content-Type: application/json' ``` @@ -195,13 +192,12 @@ output_match_mode: substring expected_stdout_lines: - '{"cleanUpTimes":5}' background: true -sleep: 10 -timeout_seconds: 15 +timeout_seconds: 90 --> ```sh -curl -X POST localhost:8080/wfp/continueasnew -H 'Content-Type: application/json' +sleep 30 && curl -X POST localhost:8080/wfp/continueasnew -H 'Content-Type: application/json' ``` @@ -265,13 +261,12 @@ name: Start External Event Workflow match_order: none output_match_mode: substring background: true -sleep: 1 -timeout_seconds: 2 +timeout_seconds: 90 --> ```sh -curl -X POST "localhost:8080/wfp/externalevent?orderId=123" -H 'Content-Type: application/json' +sleep 30 && curl -X POST "localhost:8080/wfp/externalevent?orderId=123" -H 'Content-Type: application/json' ``` @@ -296,15 +291,14 @@ output_match_mode: substring expected_stdout_lines: - '{"approved":true}' background: true -sleep: 5 -timeout_seconds: 10 +timeout_seconds: 90 --> To send the event you can run: ```sh -curl -X POST "localhost:8080/wfp/externalevent-continue?orderId=123&decision=true" -H 'Content-Type: application/json' +sleep 42 && curl -X POST "localhost:8080/wfp/externalevent-continue?orderId=123&decision=true" -H 'Content-Type: application/json' ``` @@ -353,13 +347,12 @@ output_match_mode: substring expected_stdout_lines: - '{"wordCount":60}' background: true -sleep: 1 -timeout_seconds: 2 +timeout_seconds: 90 --> ```sh -curl -X POST localhost:8080/wfp/fanoutin -H 'Content-Type: application/json' -d @body.json +sleep 45 && curl -X POST localhost:8080/wfp/fanoutin -H 'Content-Type: application/json' -d @body.json ``` @@ -406,13 +399,12 @@ name: Start Suspend/Resume Workflow match_order: none output_match_mode: substring background: true -sleep: 1 -timeout_seconds: 2 +timeout_seconds: 90 --> ```sh -curl -X POST "localhost:8080/wfp/suspendresume?orderId=123" -H 'Content-Type: application/json' +sleep 50 && curl -X POST "localhost:8080/wfp/suspendresume?orderId=456" -H 'Content-Type: application/json' ``` @@ -440,15 +432,14 @@ output_match_mode: substring expected_stdout_lines: - 'SUSPENDED' background: true -sleep: 5 -timeout_seconds: 10 +timeout_seconds: 90 --> - + Let's suspend the workflow instance by sending the following request: ```sh -curl -X POST "localhost:8080/wfp/suspendresume/suspend?orderId=123" -H 'Content-Type: application/json' +sleep 55 && curl -X POST "localhost:8080/wfp/suspendresume/suspend?orderId=456" -H 'Content-Type: application/json' ``` @@ -469,15 +460,14 @@ output_match_mode: substring expected_stdout_lines: - 'RUNNING' background: true -sleep: 5 -timeout_seconds: 10 +timeout_seconds: 90 --> - + To send the event you can run: ```sh -curl -X POST "localhost:8080/wfp/suspendresume/resume?orderId=123" -H 'Content-Type: application/json' +sleep 60 && curl -X POST "localhost:8080/wfp/suspendresume/resume?orderId=456" -H 'Content-Type: application/json' ``` @@ -498,15 +488,14 @@ output_match_mode: substring expected_stdout_lines: - '{"approved":true}' background: true -sleep: 5 -timeout_seconds: 10 +timeout_seconds: 90 --> To send the event you can run: ```sh -curl -X POST "localhost:8080/wfp/suspendresume/continue?orderId=123&decision=true" -H 'Content-Type: application/json' +sleep 65 && curl -X POST "localhost:8080/wfp/suspendresume/continue?orderId=456&decision=true" -H 'Content-Type: application/json' ``` diff --git a/spring-boot-examples/workflows/src/main/java/io/dapr/springboot/examples/wfp/WorkflowPatternsRestController.java b/spring-boot-examples/workflows/src/main/java/io/dapr/springboot/examples/wfp/WorkflowPatternsRestController.java index 8da0ec1515..f1f8856d1d 100644 --- a/spring-boot-examples/workflows/src/main/java/io/dapr/springboot/examples/wfp/WorkflowPatternsRestController.java +++ b/spring-boot-examples/workflows/src/main/java/io/dapr/springboot/examples/wfp/WorkflowPatternsRestController.java @@ -67,7 +67,7 @@ public String chain() throws TimeoutException { String instanceId = daprWorkflowClient.scheduleNewWorkflow(ChainWorkflow.class); logger.info("Workflow instance " + instanceId + " started"); return daprWorkflowClient - .waitForInstanceCompletion(instanceId, Duration.ofSeconds(2), true) + .waitForInstanceCompletion(instanceId, Duration.ofSeconds(10), true) .readOutputAs(String.class); } @@ -81,7 +81,7 @@ public String child() throws TimeoutException { String instanceId = daprWorkflowClient.scheduleNewWorkflow(ParentWorkflow.class); logger.info("Workflow instance " + instanceId + " started"); return daprWorkflowClient - .waitForInstanceCompletion(instanceId, Duration.ofSeconds(2), true) + .waitForInstanceCompletion(instanceId, Duration.ofSeconds(10), true) .readOutputAs(String.class); } diff --git a/testcontainers-dapr/src/main/java/io/dapr/testcontainers/DaprContainerConstants.java b/testcontainers-dapr/src/main/java/io/dapr/testcontainers/DaprContainerConstants.java index acfc811d8d..dd24e0a467 100644 --- a/testcontainers-dapr/src/main/java/io/dapr/testcontainers/DaprContainerConstants.java +++ b/testcontainers-dapr/src/main/java/io/dapr/testcontainers/DaprContainerConstants.java @@ -14,7 +14,7 @@ package io.dapr.testcontainers; public interface DaprContainerConstants { - String DAPR_VERSION = "1.16.0-rc.2"; + String DAPR_VERSION = "1.16.0-rc.3"; String DAPR_RUNTIME_IMAGE_TAG = "daprio/daprd:" + DAPR_VERSION; String DAPR_PLACEMENT_IMAGE_TAG = "daprio/placement:" + DAPR_VERSION; String DAPR_SCHEDULER_IMAGE_TAG = "daprio/scheduler:" + DAPR_VERSION;