Skip to content

Commit cf7dacc

Browse files
committed
adding child example
Signed-off-by: salaboy <[email protected]>
1 parent acd817b commit cf7dacc

File tree

1 file changed

+75
-6
lines changed

1 file changed

+75
-6
lines changed

spring-boot-examples/workflows/README.md

Lines changed: 75 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -59,17 +59,19 @@ graph LR
5959
```
6060

6161
<!-- STEP
62-
name: Start Customer Workflow
62+
name: Start Chain Activities Workflow
6363
match_order: none
6464
output_match_mode: substring
6565
expected_stdout_lines:
66-
- 'New Workflow Instance created for Customer'
66+
- 'TOKYO, LONDON, SEATTLE'
6767
background: true
6868
sleep: 1
6969
timeout_seconds: 2
7070
-->
7171
<!-- Timeout for above service must be more than sleep + timeout for the client-->
7272

73+
To start the workflow with the three chained activities you can run:
74+
7375
```sh
7476
curl -X POST localhost:8080/wfp/chain -H 'Content-Type: application/json'
7577
```
@@ -102,6 +104,9 @@ In the application output you should see the workflow activities being executed.
102104

103105
### Parent / Child Workflows example
104106

107+
In this example we start a Parent workflow that calls a child workflow that execute one activity that reverse the .
108+
109+
The Parent workflow looks like this:
105110

106111
```mermaid
107112
graph LR
@@ -110,15 +115,79 @@ graph LR
110115
subgraph for each word in the input
111116
GWL[Call child workflow]
112117
end
113-
ALL[Wait until all tasks
114-
are completed]
115118
EW((End
116119
Workflow))
117120
SW --> GWL
118-
GWL --> ALL
119-
ALL --> EW
121+
GWL --> EW
120122
```
121123

124+
The Child workflow looks like this:
125+
126+
```mermaid
127+
graph LR
128+
SW((Start
129+
Workflow))
130+
A1[Activity1]
131+
EW((End
132+
Workflow))
133+
SW --> A1
134+
A1 --> EW
135+
```
136+
137+
To start the parent workflow you can run:
138+
139+
140+
<!-- STEP
141+
name: Start Parent/Child Workflow
142+
match_order: none
143+
output_match_mode: substring
144+
expected_stdout_lines:
145+
- '!wolfkroW rpaD olleH'
146+
background: true
147+
sleep: 1
148+
timeout_seconds: 2
149+
-->
150+
<!-- Timeout for above service must be more than sleep + timeout for the client-->
151+
152+
To start the workflow with the three chained activities you can run:
153+
154+
```sh
155+
curl -X POST localhost:8080/wfp/child -H 'Content-Type: application/json'
156+
```
157+
158+
<!-- END_STEP -->
159+
160+
161+
As result from executing the request you should see:
162+
163+
```bash
164+
!wolfkroW rpaD olleH
165+
```
166+
167+
In the application output you should see the workflow activities being executed.
168+
169+
```bash
170+
2025-05-16T10:27:01.845+01:00 INFO 9855 --- [pool-3-thread-1] io.dapr.workflows.WorkflowContext : Starting Workflow: io.dapr.springboot.examples.wfp.child.ParentWorkflow
171+
2025-05-16T10:27:01.845+01:00 INFO 9855 --- [pool-3-thread-1] io.dapr.workflows.WorkflowContext : calling childworkflow with input: Hello Dapr Workflow!
172+
2025-05-16T10:27:01.865+01:00 INFO 9855 --- [nio-8080-exec-1] i.d.s.e.w.WorkflowPatternsRestController : Workflow instance f3ec9566-a0fc-4d28-8912-3f3ded3cd8a9 started
173+
2025-05-16T10:27:01.866+01:00 INFO 9855 --- [pool-3-thread-2] io.dapr.workflows.WorkflowContext : Starting ChildWorkflow: io.dapr.springboot.examples.wfp.child.ChildWorkflow
174+
2025-05-16T10:27:01.868+01:00 INFO 9855 --- [pool-3-thread-2] io.dapr.workflows.WorkflowContext : ChildWorkflow received input: Hello Dapr Workflow!
175+
2025-05-16T10:27:01.868+01:00 INFO 9855 --- [pool-3-thread-2] io.dapr.workflows.WorkflowContext : ChildWorkflow is calling Activity: io.dapr.springboot.examples.wfp.child.ReverseActivity
176+
2025-05-16T10:27:01.874+01:00 INFO 9855 --- [pool-3-thread-3] i.d.s.e.wfp.child.ReverseActivity : Starting Activity: io.dapr.springboot.examples.wfp.child.ReverseActivity
177+
2025-05-16T10:27:01.874+01:00 INFO 9855 --- [pool-3-thread-3] i.d.s.e.wfp.child.ReverseActivity : Message Received from input: Hello Dapr Workflow!
178+
2025-05-16T10:27:01.874+01:00 INFO 9855 --- [pool-3-thread-3] i.d.s.e.wfp.child.ReverseActivity : Sending message to output: !wolfkroW rpaD olleH
179+
2025-05-16T10:27:01.882+01:00 INFO 9855 --- [pool-3-thread-1] io.dapr.workflows.WorkflowContext : ChildWorkflow finished with: !wolfkroW rpaD olleH
180+
2025-05-16T10:27:01.892+01:00 INFO 9855 --- [pool-3-thread-2] io.dapr.workflows.WorkflowContext : childworkflow finished with: !wolfkroW rpaD olleH
181+
```
182+
183+
### ContinueAsNew Workflows example
184+
185+
186+
### External Event Workflow example
187+
188+
189+
### Fan Out/In Workflow example
190+
122191

123192
## Testing workflow executions
124193

0 commit comments

Comments
 (0)