From 6c1485f0ec398286986ad7ed76318e7316fdbd92 Mon Sep 17 00:00:00 2001 From: salaboy Date: Thu, 11 Dec 2025 16:45:34 +0100 Subject: [PATCH 1/8] separating Dapr Workflows from Spring Boot Signed-off-by: salaboy --- .../en/java-sdk-docs/spring-boot/_index.md | 54 ++----------- .../spring-boot/sb-workflows-howto.md | 79 +++++++++++++++++++ 2 files changed, 84 insertions(+), 49 deletions(-) create mode 100644 sdkdocs/java/content/en/java-sdk-docs/spring-boot/sb-workflows-howto.md diff --git a/sdkdocs/java/content/en/java-sdk-docs/spring-boot/_index.md b/sdkdocs/java/content/en/java-sdk-docs/spring-boot/_index.md index fcfaacd1a6b..506ddcb7bad 100644 --- a/sdkdocs/java/content/en/java-sdk-docs/spring-boot/_index.md +++ b/sdkdocs/java/content/en/java-sdk-docs/spring-boot/_index.md @@ -24,14 +24,14 @@ If you already have a Spring Boot application, you can directly add the followin ``` - io.dapr.spring + io.dapr.spring dapr-spring-boot-starter - 0.16.0 + 1.16.0 io.dapr.spring dapr-spring-boot-starter-test - 0.16.0 + 1.16.0 test ``` @@ -292,56 +292,12 @@ public static void setup(){ You can check and run the [full example source code here](https://github.com/salaboy/dapr-spring-boot-docs-examples). -## Using Dapr Workflows with Spring Boot - -Following the same approach that we used for Spring Data and Spring Messaging, the `dapr-spring-boot-starter` brings Dapr Workflow integration for Spring Boot users. - -To work with Dapr Workflows you need to define and implement your workflows using code. The Dapr Spring Boot Starter makes your life easier by managing `Workflow`s and `WorkflowActivity`s as Spring beans. - -In order to enable the automatic bean discovery you can annotate your `@SpringBootApplication` with the `@EnableDaprWorkflows` annotation: - -``` -@SpringBootApplication -@EnableDaprWorkflows -public class MySpringBootApplication {} -``` - -By adding this annotation, all the `WorkflowActivity`s will be automatically managed by Spring and registered to the workflow engine. - -By having all `WorkflowActivity`s as managed beans we can use Spring `@Autowired` mechanism to inject any bean that our workflow activity might need to implement its functionality, for example the `@RestTemplate`: - -``` -public class MyWorkflowActivity implements WorkflowActivity { - - @Autowired - private RestTemplate restTemplate; -``` - -You can also `@Autowired` the `DaprWorkflowClient` to create new instances of your workflows. - -``` -@Autowired -private DaprWorkflowClient daprWorkflowClient; -``` - -This enable applications to schedule new workflow instances and raise events. - -``` -String instanceId = daprWorkflowClient.scheduleNewWorkflow(MyWorkflow.class, payload); -``` - -and - -``` -daprWorkflowClient.raiseEvent(instanceId, "MyEvenet", event); -``` - -Check the [Dapr Workflow documentation](https://docs.dapr.io/developing-applications/building-blocks/workflow/workflow-overview/) for more information about how to work with Dapr Workflows. - ## Next steps Learn more about the [Dapr Java SDK packages available to add to your Java applications](https://dapr.github.io/java-sdk/). +Check the How To guide for [Dapr Workflows using Spring Boot and Testcontainers for a local workflow development experience](sb-workflows-howto.md). + ## Related links - [Java SDK examples](https://github.com/dapr/java-sdk/tree/master/examples/src/main/java/io/dapr/examples) diff --git a/sdkdocs/java/content/en/java-sdk-docs/spring-boot/sb-workflows-howto.md b/sdkdocs/java/content/en/java-sdk-docs/spring-boot/sb-workflows-howto.md new file mode 100644 index 00000000000..55beb70096e --- /dev/null +++ b/sdkdocs/java/content/en/java-sdk-docs/spring-boot/sb-workflows-howto.md @@ -0,0 +1,79 @@ +## Using Dapr Workflows with Spring Boot + +Following the same approach that we used for Spring Data and Spring Messaging, the [`dapr-spring-boot-starter`](_index.md) brings Dapr Workflow integration for Spring Boot users. + +With Dapr Workflows you define complex orchestrations (workflows) in (Java) code. The Dapr Spring Boot Starter makes your life easier by managing `Workflow`s and `WorkflowActivity`s as Spring beans. + +In order to enable the automatic bean discovery you can annotate your `@SpringBootApplication` with the `@EnableDaprWorkflows` annotation: + +``` +@SpringBootApplication +@EnableDaprWorkflows +public class MySpringBootApplication { + ... +} +``` + +By adding this annotation, all the `Workflow`s and `WorkflowActivity`s beans will be automatically discovered by Spring and registered to the workflow engine. + +## Creating Workflows and Activities + +Inside your Spring Boot application you can define as many workflows as you want. You do that by creating new implementations of the `Workflow` interface. + +``` +@Component +public class MyWorkflow implements Workflow { + + @Override + public WorkflowStub create() { + return ctx -> { + + }; + } + +} +``` + +From inside your workflow definitions, you can perform service to service interactions, schedule timers or receive external events. + +By having all `WorkflowActivity`s as managed beans we can use Spring `@Autowired` mechanism to inject any bean that our workflow activity might need to implement its functionality, for example the `@RestTemplate`: + +``` +@Component +public class MyWorkflowActivity implements WorkflowActivity { + + @Autowired + private RestTemplate restTemplate; +``` + +## Creating and interacting with Workflows + + +To create and interact with Workflow instances you need to use the `DaprWorkflowClient` that you can also `@Autowired`. + +``` +@Autowired +private DaprWorkflowClient daprWorkflowClient; +``` + +Applications can now schedule new workflow instances and raise events. + +``` +String instanceId = daprWorkflowClient.scheduleNewWorkflow(MyWorkflow.class, payload); +``` + +and + +``` +daprWorkflowClient.raiseEvent(instanceId, "MyEvenet", event); +``` + +[Check a full example here](https://github.com/dapr/java-sdk/blob/master/spring-boot-examples/workflows/patterns/src/main/java/io/dapr/springboot/examples/wfp/chain/ChainWorkflow.java) + + + +## Next Steps & Resources + +Check the blog post from [Baeldung covering Dapr Workflows and Dapr Pubsub](https://www.baeldung.com/dapr-workflows-pubsub) with a full working example. + +Check the [Dapr Workflow documentation](https://docs.dapr.io/developing-applications/building-blocks/workflow/workflow-overview/) for more information about how to work with Dapr Workflows. \ No newline at end of file From 65bace2b4129c58a190920f67420728c4d594b93 Mon Sep 17 00:00:00 2001 From: rohit <50377477+caretak3r@users.noreply.github.com> Date: Thu, 11 Dec 2025 19:15:49 -0500 Subject: [PATCH 2/8] Refactor secret scope documentation for clarity (#4965) Removed duplicate information and streamlined the scenarios for configuring secrets access. Signed-off-by: rohit <50377477+caretak3r@users.noreply.github.com> Signed-off-by: salaboy --- .../operations/configuration/secret-scope.md | 34 ++----------------- 1 file changed, 2 insertions(+), 32 deletions(-) diff --git a/daprdocs/content/en/operations/configuration/secret-scope.md b/daprdocs/content/en/operations/configuration/secret-scope.md index d32cad36f2f..aba1e8c8965 100644 --- a/daprdocs/content/en/operations/configuration/secret-scope.md +++ b/daprdocs/content/en/operations/configuration/secret-scope.md @@ -11,9 +11,7 @@ In addition to [scoping which applications can access a given component]({{% ref For more information about configuring a Configuration resource: - [Configuration overview]({{% ref configuration-overview.md %}}) - [Configuration schema]({{% ref configuration-schema.md %}}) -For more information about configuring a Configuration resource: -- [Configuration overview]({{% ref configuration-overview.md %}}) -- [Configuration schema]({{% ref configuration-schema.md %}}) + ## Configure secrets access @@ -58,10 +56,8 @@ The `allowedSecrets` and `deniedSecrets` list values take priority over the `def ### Scenario 1: Deny access to all secrets for a secret store -In a Kubernetes cluster, the native Kubernetes secret store is added to your Dapr application by default. In some scenarios, it may be necessary to deny access to Dapr secrets for a given application. To add this configuration: In a Kubernetes cluster, the native Kubernetes secret store is added to your Dapr application by default. In some scenarios, it may be necessary to deny access to Dapr secrets for a given application. To add this configuration: -1. Define the following `appconfig.yaml`. 1. Define the following `appconfig.yaml`. ```yaml @@ -75,26 +71,8 @@ In a Kubernetes cluster, the native Kubernetes secret store is added to your Dap - storeName: kubernetes defaultAccess: deny ``` - ```yaml - apiVersion: dapr.io/v1alpha1 - kind: Configuration - metadata: - name: appconfig - spec: - secrets: - scopes: - - storeName: kubernetes - defaultAccess: deny - ``` - -1. Apply it to the Kubernetes cluster using the following command: - - ```bash - kubectl apply -f appconfig.yaml`. - ``` -For applications that you need to deny access to the Kubernetes secret store, follow [the Kubernetes instructions]({{% ref kubernetes-overview %}}), adding the following annotation to the application pod. -1. Apply it to the Kubernetes cluster using the following command: +2. Apply it to the Kubernetes cluster using the following command: ```bash kubectl apply -f appconfig.yaml`. @@ -108,7 +86,6 @@ dapr.io/config: appconfig With this defined, the application no longer has access to Kubernetes secret store. -### Scenario 2: Allow access to only certain secrets in a secret store ### Scenario 2: Allow access to only certain secrets in a secret store To allow a Dapr application to have access to only certain secrets, define the following `config.yaml`: @@ -126,7 +103,6 @@ spec: allowedSecrets: ["secret1", "secret2"] ``` -This example defines configuration for secret store named `vault`. The default access to the secret store is `deny`. Meanwhile, some secrets are accessible by the application based on the `allowedSecrets` list. Follow [the Sidecar configuration instructions]({{% ref "configuration-overview.md#sidecar-configuration" %}}) to apply configuration to the sidecar. This example defines configuration for secret store named `vault`. The default access to the secret store is `deny`. Meanwhile, some secrets are accessible by the application based on the `allowedSecrets` list. Follow [the Sidecar configuration instructions]({{% ref "configuration-overview.md#sidecar-configuration" %}}) to apply configuration to the sidecar. ### Scenario 3: Deny access to certain sensitive secrets in a secret store @@ -151,9 +127,3 @@ This configuration explicitly denies access to `secret1` and `secret2` from the ## Next steps {{< button text="Service invocation access control" page="invoke-allowlist.md" >}} - -This configuration explicitly denies access to `secret1` and `secret2` from the secret store named `vault,` while allowing access to all other secrets. Follow [the Sidecar configuration instructions]({{% ref "configuration-overview.md#sidecar-configuration" %}}) to apply configuration to the sidecar. - -## Next steps - -{{< button text="Service invocation access control" page="invoke-allowlist.md" >}} From 51d0e5f09b013103f5a8b7ba321b56a572d6b28b Mon Sep 17 00:00:00 2001 From: salaboy Date: Fri, 12 Dec 2025 12:25:12 +0100 Subject: [PATCH 3/8] adding correct headers Signed-off-by: salaboy --- .../en/java-sdk-docs/spring-boot/sb-workflows-howto.md | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/sdkdocs/java/content/en/java-sdk-docs/spring-boot/sb-workflows-howto.md b/sdkdocs/java/content/en/java-sdk-docs/spring-boot/sb-workflows-howto.md index 55beb70096e..ddd7c7b071f 100644 --- a/sdkdocs/java/content/en/java-sdk-docs/spring-boot/sb-workflows-howto.md +++ b/sdkdocs/java/content/en/java-sdk-docs/spring-boot/sb-workflows-howto.md @@ -1,4 +1,11 @@ -## Using Dapr Workflows with Spring Boot +--- +type: docs +title: "How to: Author and manage Dapr Workflow with Spring Boot" +linkTitle: "How to: Author and manage workflows with Spring Boot" +weight: 40000 +description: How to get up and running with workflows using the Spring Boot integration +--- + Following the same approach that we used for Spring Data and Spring Messaging, the [`dapr-spring-boot-starter`](_index.md) brings Dapr Workflow integration for Spring Boot users. From 0b55987d381b93dc642593c580a6f804897d178d Mon Sep 17 00:00:00 2001 From: salaboy Date: Mon, 15 Dec 2025 07:29:52 +0000 Subject: [PATCH 4/8] Update sdkdocs/java/content/en/java-sdk-docs/spring-boot/sb-workflows-howto.md Co-authored-by: Mark Fussell Signed-off-by: salaboy --- .../content/en/java-sdk-docs/spring-boot/sb-workflows-howto.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sdkdocs/java/content/en/java-sdk-docs/spring-boot/sb-workflows-howto.md b/sdkdocs/java/content/en/java-sdk-docs/spring-boot/sb-workflows-howto.md index ddd7c7b071f..9cd70ac5db0 100644 --- a/sdkdocs/java/content/en/java-sdk-docs/spring-boot/sb-workflows-howto.md +++ b/sdkdocs/java/content/en/java-sdk-docs/spring-boot/sb-workflows-howto.md @@ -11,7 +11,7 @@ Following the same approach that we used for Spring Data and Spring Messaging, t With Dapr Workflows you define complex orchestrations (workflows) in (Java) code. The Dapr Spring Boot Starter makes your life easier by managing `Workflow`s and `WorkflowActivity`s as Spring beans. -In order to enable the automatic bean discovery you can annotate your `@SpringBootApplication` with the `@EnableDaprWorkflows` annotation: +In order to enable the automatic bean discovery you annotate your `@SpringBootApplication` with the `@EnableDaprWorkflows` annotation: ``` @SpringBootApplication From 82291e5e13671fc4a4be43b534844bdf98ea8668 Mon Sep 17 00:00:00 2001 From: salaboy Date: Mon, 15 Dec 2025 07:30:02 +0000 Subject: [PATCH 5/8] Update sdkdocs/java/content/en/java-sdk-docs/spring-boot/sb-workflows-howto.md Co-authored-by: Mark Fussell Signed-off-by: salaboy --- .../content/en/java-sdk-docs/spring-boot/sb-workflows-howto.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sdkdocs/java/content/en/java-sdk-docs/spring-boot/sb-workflows-howto.md b/sdkdocs/java/content/en/java-sdk-docs/spring-boot/sb-workflows-howto.md index 9cd70ac5db0..540f05fa4c5 100644 --- a/sdkdocs/java/content/en/java-sdk-docs/spring-boot/sb-workflows-howto.md +++ b/sdkdocs/java/content/en/java-sdk-docs/spring-boot/sb-workflows-howto.md @@ -43,7 +43,7 @@ public class MyWorkflow implements Workflow { From inside your workflow definitions, you can perform service to service interactions, schedule timers or receive external events. -By having all `WorkflowActivity`s as managed beans we can use Spring `@Autowired` mechanism to inject any bean that our workflow activity might need to implement its functionality, for example the `@RestTemplate`: +By having all `WorkflowActivity`s as managed beans you can use the Spring `@Autowired` mechanism to inject any bean that the workflow activity might need to implement its functionality. For example the `@RestTemplate`: ``` @Component From ce62ee2a3d9b9d68e843572f05a02fa8814b52b7 Mon Sep 17 00:00:00 2001 From: salaboy Date: Mon, 15 Dec 2025 07:30:10 +0000 Subject: [PATCH 6/8] Update sdkdocs/java/content/en/java-sdk-docs/spring-boot/sb-workflows-howto.md Co-authored-by: Mark Fussell Signed-off-by: salaboy --- .../content/en/java-sdk-docs/spring-boot/sb-workflows-howto.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sdkdocs/java/content/en/java-sdk-docs/spring-boot/sb-workflows-howto.md b/sdkdocs/java/content/en/java-sdk-docs/spring-boot/sb-workflows-howto.md index 540f05fa4c5..3e594a43129 100644 --- a/sdkdocs/java/content/en/java-sdk-docs/spring-boot/sb-workflows-howto.md +++ b/sdkdocs/java/content/en/java-sdk-docs/spring-boot/sb-workflows-howto.md @@ -56,7 +56,7 @@ public class MyWorkflowActivity implements WorkflowActivity { ## Creating and interacting with Workflows -To create and interact with Workflow instances you need to use the `DaprWorkflowClient` that you can also `@Autowired`. +To create and interact with Workflow instances you use the `DaprWorkflowClient` that you can also `@Autowired`. ``` @Autowired From 77e3f2abc891338a181e293d9de6cbf06249a440 Mon Sep 17 00:00:00 2001 From: salaboy Date: Mon, 15 Dec 2025 07:30:24 +0000 Subject: [PATCH 7/8] Update sdkdocs/java/content/en/java-sdk-docs/spring-boot/sb-workflows-howto.md Co-authored-by: Mark Fussell Signed-off-by: salaboy --- .../content/en/java-sdk-docs/spring-boot/sb-workflows-howto.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sdkdocs/java/content/en/java-sdk-docs/spring-boot/sb-workflows-howto.md b/sdkdocs/java/content/en/java-sdk-docs/spring-boot/sb-workflows-howto.md index 3e594a43129..7aa9578d0e6 100644 --- a/sdkdocs/java/content/en/java-sdk-docs/spring-boot/sb-workflows-howto.md +++ b/sdkdocs/java/content/en/java-sdk-docs/spring-boot/sb-workflows-howto.md @@ -21,7 +21,7 @@ public class MySpringBootApplication { } ``` -By adding this annotation, all the `Workflow`s and `WorkflowActivity`s beans will be automatically discovered by Spring and registered to the workflow engine. +By adding this annotation, all the `Workflow`s and `WorkflowActivity`s beans are automatically discovered by Spring and registered to the workflow engine. ## Creating Workflows and Activities From e0979c89d9e9dfb94688b734d94f26413c8b5644 Mon Sep 17 00:00:00 2001 From: salaboy Date: Mon, 15 Dec 2025 07:30:30 +0000 Subject: [PATCH 8/8] Update sdkdocs/java/content/en/java-sdk-docs/spring-boot/sb-workflows-howto.md Co-authored-by: Mark Fussell Signed-off-by: salaboy --- .../content/en/java-sdk-docs/spring-boot/sb-workflows-howto.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sdkdocs/java/content/en/java-sdk-docs/spring-boot/sb-workflows-howto.md b/sdkdocs/java/content/en/java-sdk-docs/spring-boot/sb-workflows-howto.md index 7aa9578d0e6..4fcd973db2b 100644 --- a/sdkdocs/java/content/en/java-sdk-docs/spring-boot/sb-workflows-howto.md +++ b/sdkdocs/java/content/en/java-sdk-docs/spring-boot/sb-workflows-howto.md @@ -9,7 +9,7 @@ description: How to get up and running with workflows using the Spring Boot inte Following the same approach that we used for Spring Data and Spring Messaging, the [`dapr-spring-boot-starter`](_index.md) brings Dapr Workflow integration for Spring Boot users. -With Dapr Workflows you define complex orchestrations (workflows) in (Java) code. The Dapr Spring Boot Starter makes your life easier by managing `Workflow`s and `WorkflowActivity`s as Spring beans. +With Dapr Workflows you define complex orchestrations (workflows) in Java code. The Dapr Spring Boot Starter makes your development easier by managing `Workflow`s and `WorkflowActivity`s as Spring Beans. In order to enable the automatic bean discovery you annotate your `@SpringBootApplication` with the `@EnableDaprWorkflows` annotation: