Skip to content

Commit 35146df

Browse files
committed
tweaks
Signed-off-by: Hannah Hunter <[email protected]>
1 parent d460b10 commit 35146df

File tree

1 file changed

+153
-9
lines changed

1 file changed

+153
-9
lines changed

articles/azure-functions/durable-task-scheduler/quickstart-portable-durable-task-sdks.md

Lines changed: 153 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,9 @@ Before you begin:
5555

5656
::: zone pivot="java"
5757

58+
- Install [Docker](https://www.docker.com/products/docker-desktop/) for running the emulator.
59+
- Clone the [Durable Task Scheduler GitHub repository](https://github.com/Azure-Samples/Durable-Task-Scheduler) to use the quickstart sample.
60+
5861
::: zone-end
5962

6063
::: zone pivot="csharp,python,java"
@@ -97,7 +100,7 @@ Since the example code automatically uses the default emulator settings, you don
97100
1. From the `Azure-Samples/Durable-Task-Scheduler` root directory, navigate to the Python SDK sample dirctory.
98101
99102
```bash
100-
cd samples/portable-sdks/python/sub-orchestrations-with-fan-out-fan-in
103+
cd samples/portable-sdks/python/fan-out-fan-in
101104
```
102105
103106
1. Pull the Docker image for the emulator.
@@ -120,6 +123,28 @@ Since the example code automatically uses the default emulator settings, you don
120123

121124
::: zone pivot="java"
122125

126+
1. From the `Azure-Samples/Durable-Task-Scheduler` root directory, navigate to the Java SDK sample dirctory.
127+
128+
```bash
129+
cd samples/portable-sdks/java/fan-out-fan-in
130+
```
131+
132+
1. Pull the Docker image for the emulator.
133+
134+
```bash
135+
docker pull mcr.microsoft.com/dts/dts-emulator:v0.0.6
136+
```
137+
138+
1. Run the emulator. The container may take a few seconds to be ready.
139+
140+
```bash
141+
docker run --name dtsemulator -d -p 8080:8080 mcr.microsoft.com/dts/dts-emulator:v0.0.6
142+
```
143+
144+
Since the example code automatically uses the default emulator settings, you don't need to set any environment variables.
145+
- Endpoint: `http://localhost:8080`
146+
- Task hub: `default`
147+
123148
::: zone-end
124149
125150
::: zone pivot="csharp,python,java"
@@ -148,21 +173,27 @@ Since the example code automatically uses the default emulator settings, you don
148173
149174
### Understanding the output
150175
151-
When you run this sample, you receive output from both the worker and client processes. The worker output shows:
176+
When you run this sample, you receive output from both the worker and client processes.
177+
178+
#### Worker output
179+
180+
The worker output shows:
152181
153182
- Registration of the orchestrator and activities
154183
- Log entries when each activity is called
155184
- Parallel processing of multiple work items
156185
- Final aggregation of results
157186
187+
#### Client output
188+
158189
The client output shows:
159190
160191
- Starting the orchestration with a list of work items
161192
- The unique orchestration instance ID
162193
- The final aggregated results, showing each work item and its corresponding result
163194
- Total count of processed items
164195
165-
**Example output**
196+
#### Example output
166197
167198
```
168199
Starting Fan-Out Fan-In Pattern - Parallel Processing Client
@@ -221,11 +252,11 @@ Total items processed: 5
221252
You'll see output indicating that the worker has started and is waiting for work items.
222253
223254
```
224-
INFO:__main__:Starting Fan Out/Fan In pattern worker...
255+
Starting Fan Out/Fan In pattern worker...
225256
Using taskhub: default
226257
Using endpoint: http://localhost:8080
227-
2025-04-23 12:56:58.612 durabletask-worker INFO: Starting gRPC worker that connects to http://localhost:8080
228-
2025-04-23 12:56:58.830 durabletask-worker INFO: Successfully connected to http:// localhost:8080. Waiting for work items...
258+
Starting gRPC worker that connects to http://localhost:8080
259+
Successfully connected to http://localhost:8080. Waiting for work items...
229260
```
230261
231262
1. In a new terminal (with the virtual environment activated, if applicable), run the client.
@@ -242,13 +273,19 @@ Total items processed: 5
242273
243274
### Understanding the output
244275
245-
When you run this sample, you receive output from both the worker and client processes. The worker output shows:
276+
When you run this sample, you receive output from both the worker and client processes.
277+
278+
#### Worker output
279+
280+
The worker output shows:
246281
247282
- Registration of the orchestrator and activities.
248283
- Status messages when processing each work item in parallel, showing that they're executing concurrently.
249284
- Random delays for each work item (between 0.5 and 2 seconds) to simulate varying processing times.
250285
- A final message showing the aggregation of results.
251286

287+
#### Client output
288+
252289
The client output shows:
253290

254291
- Starting the orchestration with the specified number of work items.
@@ -258,7 +295,7 @@ The client output shows:
258295
- Sum of all results (each item result is the square of its value)
259296
- Average of all results
260297

261-
**Example output**
298+
#### Example output
262299

263300
```
264301
Starting fan out/fan in orchestration with 10 items
@@ -293,6 +330,60 @@ Orchestration completed with status: COMPLETED
293330
294331
::: zone pivot="java"
295332
333+
1. Install the required packages.
334+
335+
```bash
336+
337+
```
338+
339+
1. Start the worker.
340+
341+
```bash
342+
343+
```
344+
345+
1. In a new terminal, run the client.
346+
347+
```bash
348+
349+
```
350+
351+
You can provide the number of work items as an argument. If no argument is provided, the example runs 10 items by default.
352+
353+
```bash
354+
355+
```
356+
357+
### Understanding the output
358+
359+
When you run this sample, you receive output from both the worker and client processes.
360+
361+
#### Worker output
362+
363+
The worker output shows:
364+
365+
- Registration of the orchestrator and activities.
366+
- Status messages when processing each work item in parallel, showing that they're executing concurrently.
367+
- Random delays for each work item (between 0.5 and 2 seconds) to simulate varying processing times.
368+
- A final message showing the aggregation of results.
369+
370+
#### Client output
371+
372+
The client output shows:
373+
374+
- Starting the orchestration with the specified number of work items.
375+
- The unique orchestration instance ID.
376+
- The final aggregated result, which includes:
377+
- Total number of items processed
378+
- Sum of all results (each item result is the square of its value)
379+
- Average of all results
380+
381+
#### Example output
382+
383+
```
384+
385+
```
386+
296387
::: zone-end
297388
298389
@@ -310,13 +401,17 @@ You can view the orchestration status and history via the [Durable Task Schedule
310401
- The input and output at each step
311402
- The time taken for each step
312403
404+
::: zone-end
405+
406+
::: zone pivot="csharp"
407+
313408
:::image type="content" source="media/quickstart-portable-durable-task-sdks/review-dashboard.png" alt-text="Screenshot showing the orchestartion instance's details.":::
314409
315410
::: zone-end
316411
317412
::: zone pivot="csharp,python,java"
318413
319-
## What happened?
414+
## Understanding the code structure
320415
321416
::: zone-end
322417
@@ -507,6 +602,55 @@ result = client.wait_for_orchestration_completion(
507602

508603
::: zone pivot="java"
509604

605+
### Worker
606+
607+
To demonstrate [the fan-out/fan-in pattern](../durable/durable-functions-overview.md#fan-in-out), the worker project orchestration creates parallel activity tasks and waits for all to complete. The orchestrator:
608+
609+
1. Takes a list of work items as input.
610+
1. Fans out by creating a separate task for each work item using ``.
611+
1. Executes all tasks in parallel.
612+
1. Waits for all tasks to complete using ``.
613+
1. Fans in by aggregating all individual results using ``.
614+
1. Returns the final aggregated result to the client.
615+
616+
Using fan-out/fan-in, the orchestration creates parallel activity tasks and waits for all to complete.
617+
618+
```java
619+
620+
```
621+
622+
#### Client
623+
624+
The worker uses `Microsoft.Extensions.Hosting` for proper lifecycle management.
625+
626+
```csharp
627+
using Microsoft.Extensions.Hosting;
628+
//..
629+
630+
builder.Services.AddDurableTaskWorker()
631+
.AddTasks(registry =>
632+
{
633+
registry.AddOrchestrator<ParallelProcessingOrchestration>();
634+
registry.AddActivity<ProcessWorkItemActivity>();
635+
registry.AddActivity<AggregateResultsActivity>();
636+
})
637+
.UseDurableTaskScheduler(connectionString);
638+
```
639+
640+
### The client project
641+
642+
The client project:
643+
644+
- Uses the same connection string logic as the worker.
645+
- Creates a list of work items to be processed in parallel.
646+
- Schedules an orchestration instance with the list as input.
647+
- Waits for the orchestration to complete and displays the aggregated results.
648+
- Uses `` for efficient polling.
649+
650+
```java
651+
652+
```
653+
510654
::: zone-end
511655

512656

0 commit comments

Comments
 (0)