You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardexpand all lines: daprdocs/content/en/java-sdk-docs/spring-boot/_index.md
+48-1
Original file line number
Diff line number
Diff line change
@@ -122,7 +122,7 @@ Besides the previous configuration (`DaprTestContainersConfig`) your tests shoul
122
122
The Java SDK allows you to interface with all of the [Dapr building blocks]({{< ref building-blocks >}}).
123
123
But if you want to leverage the Spring and Spring Boot programming model you can use the `dapr-spring-boot-starter` integration.
124
124
This includes implementations of Spring Data (`KeyValueTemplate` and `CrudRepository`) as well as a `DaprMessagingTemplate` for producing and consuming messages
125
-
(similar to [Spring Kafka](https://spring.io/projects/spring-kafka), [Spring Pulsar](https://spring.io/projects/spring-pulsar) and [Spring AMQP for RabbitMQ](https://spring.io/projects/spring-amqp)).
125
+
(similar to [Spring Kafka](https://spring.io/projects/spring-kafka), [Spring Pulsar](https://spring.io/projects/spring-pulsar) and [Spring AMQP for RabbitMQ](https://spring.io/projects/spring-amqp)) and Dapr workflows.
126
126
127
127
## Using Spring Data `CrudRepository` and `KeyValueTemplate`
128
128
@@ -277,6 +277,53 @@ public static void setup(){
277
277
278
278
You can check and run the [full example source code here](https://github.com/salaboy/dapr-spring-boot-docs-examples).
279
279
280
+
## Using Dapr Workflows with Spring Boot
281
+
282
+
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.
283
+
284
+
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.
285
+
286
+
In order to enable the automatic bean discovery you can annotate your `@SpringBootApplication` with the `@EnableDaprWorkflows` annotation:
287
+
288
+
```
289
+
@SpringBootApplication
290
+
@EnableDaprWorkflows
291
+
public class MySpringBootApplication {}
292
+
```
293
+
294
+
By adding this annotation, all the `WorkflowActivity`s will be automatically managed by Spring and registered to the workflow engine.
295
+
296
+
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`:
297
+
298
+
```
299
+
public class MyWorkflowActivity implements WorkflowActivity {
300
+
301
+
@Autowired
302
+
private RestTemplate restTemplate;
303
+
```
304
+
305
+
You can also `@Autowired` the `DaprWorkflowClient` to create new instances of your workflows.
306
+
307
+
```
308
+
@Autowired
309
+
private DaprWorkflowClient daprWorkflowClient;
310
+
```
311
+
312
+
This enable applications to schedule new workflow instances and raise events.
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.
325
+
326
+
280
327
## Next steps
281
328
282
329
Learn more about the [Dapr Java SDK packages available to add to your Java applications](https://dapr.github.io/java-sdk/).
0 commit comments