Skip to content

diagrid-labs/dapr-workflow-demos-java

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Dapr Workflows and Spring Boot Applications Demos

Demos applications that use the Dapr Workflow building block.

Read the blog posts:

Prerequisites

  1. JDK 17+ with Maven
  2. A REST client, such as cURL, or httpie

Chaining workflow sample

The Chaining Workflow sample is a workflow that chains three activities of the same type GreetingActivity, each prepending a random greeting to the input. The output of the activity is used as an input for the next activity in the chain.

graph TB
    A[Start]
    B1[GreetingActivity]
    B2[GreetingActivity]
    B3[GreetingActivity]
    C[End]
    A -->|"input: {name}"| B1 -->|"output/input: {greeting1} {name}"| B2
    B2 -->|"output/input: {greeting2} {greeting1} {name}"| B3
    B3 -->|"output: {greeting3} {greeting2} {greeting1} {name}"| C
Loading

Fan-out / Fan-in workflow sample

The Fan-out / Fan-in Workflow sample is a workflow that fans out and schedules an activity (GreetingActivity) for each element in the input array and waits until all of the activities are completed. The output of the workflow is an array of greetings.

graph TB
    A[Start]
    A1([for each name in names])
    B1[GreetingActivity]
    B2[GreetingActivity]
    B3[GreetingActivity]
    C([Task.WhenAll])
    D[End]
    A --> |"input: [{name1}, {name2}, {name3}]"| A1
    A1 -->|"input: {name1}"| B1 -->|"output: {greeting1} {name1}"| C
    A1 -->|"input: {name2}"| B2 -->|"output: {greeting2} {name2}"| C
    A1 -->|"input: {name3}"| B3 -->|"output: {greeting3} {name3}"| C
    C -->|"output: [{greeting1} {name1}, {greeting2} {name2}, {greeting3} {name3}]"| D
Loading

Monitor workflow sample

The Monitor sample is a workflow with a numeric input (counter) and restarts the workflow (with an updated counter) until the counter reaches 10. The workflow diagram is as follows:

graph TB
    A[Start]
    B[GreetingActivity]
    C{counter < 10}
    D[End]
    A --> |"input: {counter}"| B
    B -->|"output: {greeting} {counter}"| C
    C --> |"[Yes] {counter+=1}"| A
    C -->|"[No] output: {greeting} 10"| D
Loading

External interaction workflow sample

The External interaction sample is a workflow that will wait with execution of the workflow until an external event has been received or the timeout has expired.

graph TB
    A[Start]
    B([WaitForExternalEventAsync])
    C{IsApproved}
    D[GreetingActivity]
    F[ExternalEvent]
    E[End]
    A --> B
    F --> B
    B --> C
    C -->|"[Yes]"| D
    C -->|"[No / Timeout]"| E
    D --> E
Loading

Resources

  1. Dapr Workflow overview.

More information

Any questions or comments about this sample? Join the Dapr discord and post a message the #workflow channel. Have you made something with Dapr? Post a message in the #show-and-tell channel, we love to see your creations!

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages