From e8a6bf02639c7ec6529f59446836928b7ad2d8ae Mon Sep 17 00:00:00 2001 From: Javier Aliaga Date: Thu, 7 Aug 2025 10:04:29 +0200 Subject: [PATCH 01/12] chore: Use dapr release 1.16-rc.3 Signed-off-by: Javier Aliaga --- .github/workflows/build.yml | 2 +- .github/workflows/validate.yml | 2 +- daprdocs/content/en/java-sdk-docs/spring-boot/_index.md | 4 ++-- pom.xml | 2 +- spring-boot-examples/kubernetes/README.md | 2 +- .../java/io/dapr/testcontainers/DaprContainerConstants.java | 2 +- 6 files changed, 7 insertions(+), 7 deletions(-) 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..f826e9c8e9 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: 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/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/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/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; From b5e907831dbebe3f725cf8a057605ce6d3c91b54 Mon Sep 17 00:00:00 2001 From: Javier Aliaga Date: Thu, 7 Aug 2025 10:04:57 +0200 Subject: [PATCH 02/12] feat: Move field to top level request Signed-off-by: Javier Aliaga --- .../java/io/dapr/client/DaprClientImpl.java | 22 +++++++++---------- .../client/DaprPreviewClientGrpcTest.java | 14 ++++++------ 2 files changed, 18 insertions(+), 18 deletions(-) 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()); } From 33d91b22c993d81a24504bd556f55bcf19dc044c Mon Sep 17 00:00:00 2001 From: Javier Aliaga Date: Thu, 7 Aug 2025 18:06:47 +0200 Subject: [PATCH 03/12] chore: Update mechanical markdown workflow timeouts Signed-off-by: Javier Aliaga --- spring-boot-examples/workflows/README.md | 12 ++++++------ .../examples/wfp/WorkflowPatternsRestController.java | 4 ++-- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/spring-boot-examples/workflows/README.md b/spring-boot-examples/workflows/README.md index ae02d2ee6b..53bb2a980c 100644 --- a/spring-boot-examples/workflows/README.md +++ b/spring-boot-examples/workflows/README.md @@ -25,7 +25,7 @@ expected_stdout_lines: background: true expected_return_code: 143 sleep: 30 -timeout_seconds: 45 +timeout_seconds: 120 --> @@ -68,7 +68,7 @@ expected_stdout_lines: - 'TOKYO, LONDON, SEATTLE' background: true sleep: 1 -timeout_seconds: 2 +timeout_seconds: 10 --> @@ -146,7 +146,7 @@ expected_stdout_lines: - '!wolfkroW rpaD olleH' background: true sleep: 1 -timeout_seconds: 2 +timeout_seconds: 10 --> @@ -266,7 +266,7 @@ match_order: none output_match_mode: substring background: true sleep: 1 -timeout_seconds: 2 +timeout_seconds: 10 --> @@ -354,7 +354,7 @@ expected_stdout_lines: - '{"wordCount":60}' background: true sleep: 1 -timeout_seconds: 2 +timeout_seconds: 10 --> @@ -407,7 +407,7 @@ match_order: none output_match_mode: substring background: true sleep: 1 -timeout_seconds: 2 +timeout_seconds: 10 --> 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); } From f946103d047aad62dad0f95d594ee359439bdd07 Mon Sep 17 00:00:00 2001 From: Javier Aliaga Date: Fri, 8 Aug 2025 11:36:05 +0200 Subject: [PATCH 04/12] chore: Run MM workflows tests in parallel Signed-off-by: Javier Aliaga --- .../java/io/dapr/examples/workflows/README.md | 88 +++++++++++++------ .../workflows/chain/DemoChainClient.java | 3 +- .../workflows/chain/DemoChainWorker.java | 3 +- .../DemoChildWorkerflowClient.java | 3 +- .../DemoChildWorkflowWorker.java | 3 +- .../compensation/BookTripClient.java | 3 +- .../compensation/BookTripWorker.java | 3 +- .../DemoContinueAsNewClient.java | 3 +- .../DemoContinueAsNewWorker.java | 4 +- .../DemoExternalEventClient.java | 3 +- .../DemoExternalEventWorker.java | 3 +- .../faninout/DemoFanInOutClient.java | 3 +- .../faninout/DemoFanInOutWorker.java | 3 +- .../DemoSuspendResumeClient.java | 3 +- .../DemoSuspendResumeWorker.java | 3 +- .../workflows/utils/PropertyUtils.java | 19 ++++ 16 files changed, 109 insertions(+), 41 deletions(-) create mode 100644 examples/src/main/java/io/dapr/examples/workflows/utils/PropertyUtils.java 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..c0b8cec34e 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,20 @@ 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 +251,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 +314,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 +625,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 +642,28 @@ 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 +683,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 +696,35 @@ 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..a774d75782 --- /dev/null +++ b/examples/src/main/java/io/dapr/examples/workflows/utils/PropertyUtils.java @@ -0,0 +1,19 @@ +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; + } +} From 0bc74f8205e0093ff04b969fd18c41b2226d1bb2 Mon Sep 17 00:00:00 2001 From: Javier Aliaga Date: Fri, 8 Aug 2025 13:13:32 +0200 Subject: [PATCH 05/12] fix: Fix tracing examples Signed-off-by: Javier Aliaga --- .../src/main/java/io/dapr/examples/tracing/InvokeClient.java | 1 + examples/src/main/java/io/dapr/examples/tracing/README.md | 3 +++ 2 files changed, 4 insertions(+) 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 From 6301ea36c8a85d9511a6b954ee2f55ade2f1aa8d Mon Sep 17 00:00:00 2001 From: Javier Aliaga Date: Fri, 8 Aug 2025 13:18:24 +0200 Subject: [PATCH 06/12] ci: Do not run tests during example validations We have specifics jobs that runs tests. Do not run them as part as validations Signed-off-by: Javier Aliaga --- .github/workflows/validate.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/validate.yml b/.github/workflows/validate.yml index f826e9c8e9..6aa82d6fda 100644 --- a/.github/workflows/validate.yml +++ b/.github/workflows/validate.yml @@ -112,7 +112,7 @@ jobs: - name: Build sdk run: ./mvnw compile -q - name: Install jars - run: ./mvnw install -q + run: ./mvnw install -DskipTests -q env: DOCKER_HOST: ${{steps.setup_docker.outputs.sock}} - name: Validate Jobs example From b426a983b9b4de402e24f6c4f20fbf6ebd57e558 Mon Sep 17 00:00:00 2001 From: Javier Aliaga Date: Fri, 8 Aug 2025 13:21:17 +0200 Subject: [PATCH 07/12] ci: Improve validate job No need to run separate jobs for clean, compile and install Signed-off-by: Javier Aliaga --- .github/workflows/validate.yml | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/.github/workflows/validate.yml b/.github/workflows/validate.yml index 6aa82d6fda..f8860ab697 100644 --- a/.github/workflows/validate.yml +++ b/.github/workflows/validate.yml @@ -107,12 +107,8 @@ 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 -DskipTests -q + run: ./mvnw clean install -DskipTests -q env: DOCKER_HOST: ${{steps.setup_docker.outputs.sock}} - name: Validate Jobs example From e6defd2c327c229d83be51b2d2eb444459f6a2ea Mon Sep 17 00:00:00 2001 From: Javier Aliaga Date: Fri, 8 Aug 2025 13:38:17 +0200 Subject: [PATCH 08/12] ci: Run workflows examples sequentially Signed-off-by: Javier Aliaga --- examples/src/main/java/io/dapr/examples/workflows/README.md | 4 ---- 1 file changed, 4 deletions(-) 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 c0b8cec34e..109e29ced9 100644 --- a/examples/src/main/java/io/dapr/examples/workflows/README.md +++ b/examples/src/main/java/io/dapr/examples/workflows/README.md @@ -166,7 +166,6 @@ output_match_mode: substring expected_stdout_lines: - 'completed with result: TOKYO, LONDON, SEATTLE' timeout_seconds: 20 -background: true --> Then, execute the following script in order to run DemoChainClient: ```sh @@ -279,7 +278,6 @@ output_match_mode: substring expected_stdout_lines: - 'completed with result: 60' timeout_seconds: 20 -background: true --> Execute the following script in order to run DemoFanInOutClient: @@ -659,7 +657,6 @@ output_match_mode: substring expected_stdout_lines: - 'Workflow failed, compensation applied' timeout_seconds: 30 -background: true --> Once running, execute the following script to run the BookTripClient: ```sh @@ -721,7 +718,6 @@ expected_stdout_lines: - "Workflow Instance Status: RUNNING" - "Now that the instance is RUNNING again, lets send the external event." timeout_seconds: 30 -background: true --> ```sh sleep 15 && java -jar target/dapr-java-sdk-examples-exec.jar io.dapr.examples.workflows.suspendresume.DemoSuspendResumeClient 50004 From b4e7440421b8474e5df1b324a84dcd1c35c11036 Mon Sep 17 00:00:00 2001 From: Javier Aliaga Date: Fri, 8 Aug 2025 13:55:33 +0200 Subject: [PATCH 09/12] ci: Add timeout to strem pubsub Signed-off-by: Javier Aliaga --- .../src/main/java/io/dapr/examples/pubsub/stream/README.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) 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 From 0a860bed5c820f097625bfa1acf2095efcb151eb Mon Sep 17 00:00:00 2001 From: Javier Aliaga Date: Fri, 8 Aug 2025 16:01:44 +0200 Subject: [PATCH 10/12] ci: Fix order of examples Signed-off-by: Javier Aliaga --- .github/workflows/validate.yml | 37 +++++++++++---------- spring-boot-examples/workflows/README.md | 42 +++++++++++------------- 2 files changed, 39 insertions(+), 40 deletions(-) diff --git a/.github/workflows/validate.yml b/.github/workflows/validate.yml index f8860ab697..dd052bbcd4 100644 --- a/.github/workflows/validate.yml +++ b/.github/workflows/validate.yml @@ -111,6 +111,24 @@ jobs: 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 working-directory: ./examples run: | @@ -195,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/spring-boot-examples/workflows/README.md b/spring-boot-examples/workflows/README.md index 53bb2a980c..dccd33ca16 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: 120 +timeout_seconds: 180 --> @@ -35,6 +34,15 @@ timeout_seconds: 120 + + By running the `spring-boot:test-run` goal, the application is loaded using the [test configurations](src/test/java/io/dapr/springboot/examples/wfp/DaprTestContainersConfig.java) configured using [Testcontainers](https://testcontainers.com) to boostrap the [Dapr](https://dapr.io) sidecar and control plane. @@ -66,8 +74,7 @@ match_order: none output_match_mode: substring expected_stdout_lines: - 'TOKYO, LONDON, SEATTLE' -background: true -sleep: 1 +background: false timeout_seconds: 10 --> @@ -144,8 +151,7 @@ match_order: none output_match_mode: substring expected_stdout_lines: - '!wolfkroW rpaD olleH' -background: true -sleep: 1 +background: false timeout_seconds: 10 --> @@ -194,8 +200,7 @@ match_order: none output_match_mode: substring expected_stdout_lines: - '{"cleanUpTimes":5}' -background: true -sleep: 10 +background: false timeout_seconds: 15 --> @@ -264,8 +269,7 @@ To start the workflow you can run: name: Start External Event Workflow match_order: none output_match_mode: substring -background: true -sleep: 1 +background: false timeout_seconds: 10 --> @@ -295,8 +299,7 @@ match_order: none output_match_mode: substring expected_stdout_lines: - '{"approved":true}' -background: true -sleep: 5 +background: false timeout_seconds: 10 --> @@ -352,8 +355,7 @@ match_order: none output_match_mode: substring expected_stdout_lines: - '{"wordCount":60}' -background: true -sleep: 1 +background: false timeout_seconds: 10 --> @@ -405,8 +407,7 @@ To start the workflow, you can run: name: Start Suspend/Resume Workflow match_order: none output_match_mode: substring -background: true -sleep: 1 +background: false timeout_seconds: 10 --> @@ -439,8 +440,7 @@ match_order: none output_match_mode: substring expected_stdout_lines: - 'SUSPENDED' -background: true -sleep: 5 +background: false timeout_seconds: 10 --> @@ -468,8 +468,7 @@ match_order: none output_match_mode: substring expected_stdout_lines: - 'RUNNING' -background: true -sleep: 5 +background: false timeout_seconds: 10 --> @@ -497,8 +496,7 @@ match_order: none output_match_mode: substring expected_stdout_lines: - '{"approved":true}' -background: true -sleep: 5 +background: false timeout_seconds: 10 --> From 1e4cb7881a0c77847606a19abe5c151d65e140a3 Mon Sep 17 00:00:00 2001 From: Javier Aliaga Date: Fri, 8 Aug 2025 16:27:31 +0200 Subject: [PATCH 11/12] ci: Fix validation tests for sb workflows Signed-off-by: Javier Aliaga --- spring-boot-examples/workflows/README.md | 73 +++++++++++------------- 1 file changed, 32 insertions(+), 41 deletions(-) diff --git a/spring-boot-examples/workflows/README.md b/spring-boot-examples/workflows/README.md index dccd33ca16..595857cb10 100644 --- a/spring-boot-examples/workflows/README.md +++ b/spring-boot-examples/workflows/README.md @@ -34,15 +34,6 @@ timeout_seconds: 180 - - By running the `spring-boot:test-run` goal, the application is loaded using the [test configurations](src/test/java/io/dapr/springboot/examples/wfp/DaprTestContainersConfig.java) configured using [Testcontainers](https://testcontainers.com) to boostrap the [Dapr](https://dapr.io) sidecar and control plane. @@ -74,15 +65,15 @@ match_order: none output_match_mode: substring expected_stdout_lines: - 'TOKYO, LONDON, SEATTLE' -background: false -timeout_seconds: 10 +background: true +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' ``` @@ -151,15 +142,15 @@ match_order: none output_match_mode: substring expected_stdout_lines: - '!wolfkroW rpaD olleH' -background: false -timeout_seconds: 10 +background: true +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' ``` @@ -200,13 +191,13 @@ match_order: none output_match_mode: substring expected_stdout_lines: - '{"cleanUpTimes":5}' -background: false -timeout_seconds: 15 +background: true +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' ``` @@ -269,13 +260,13 @@ To start the workflow you can run: name: Start External Event Workflow match_order: none output_match_mode: substring -background: false -timeout_seconds: 10 +background: true +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' ``` @@ -299,15 +290,15 @@ match_order: none output_match_mode: substring expected_stdout_lines: - '{"approved":true}' -background: false -timeout_seconds: 10 +background: true +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' ``` @@ -355,13 +346,13 @@ match_order: none output_match_mode: substring expected_stdout_lines: - '{"wordCount":60}' -background: false -timeout_seconds: 10 +background: true +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 ``` @@ -407,13 +398,13 @@ To start the workflow, you can run: name: Start Suspend/Resume Workflow match_order: none output_match_mode: substring -background: false -timeout_seconds: 10 +background: true +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 +431,15 @@ match_order: none output_match_mode: substring expected_stdout_lines: - 'SUSPENDED' -background: false -timeout_seconds: 10 +background: true +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' ``` @@ -468,15 +459,15 @@ match_order: none output_match_mode: substring expected_stdout_lines: - 'RUNNING' -background: false -timeout_seconds: 10 +background: true +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' ``` @@ -496,15 +487,15 @@ match_order: none output_match_mode: substring expected_stdout_lines: - '{"approved":true}' -background: false -timeout_seconds: 10 +background: true +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' ``` From c611edd85838e53088b97883a182e63e0c399bac Mon Sep 17 00:00:00 2001 From: Javier Aliaga Date: Fri, 8 Aug 2025 18:20:39 +0200 Subject: [PATCH 12/12] nit: Add copyright header Signed-off-by: Javier Aliaga --- .../examples/workflows/utils/PropertyUtils.java | 13 +++++++++++++ 1 file changed, 13 insertions(+) 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 index a774d75782..9d64e45d36 100644 --- a/examples/src/main/java/io/dapr/examples/workflows/utils/PropertyUtils.java +++ b/examples/src/main/java/io/dapr/examples/workflows/utils/PropertyUtils.java @@ -1,3 +1,16 @@ +/* + * 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;