Soru

Zorluk: OrtaImplement Durable Functions

You are developing a C# (.NET Isolated process) Durable Function to transcode and analyze video files. The workflow implements a Fan-out/Fan-in pattern: it first calls a transcoding activity, then launches parallel analysis activities on the transcoded video, and finally aggregates the results.

To ensure the durability of the execution, the Durable Functions runtime uses event sourcing and replays the orchestrator function.

You need to sequence the lifecycle and replay steps of this workflow from the initial client request to the completion of the orchestration.

In which order do these events occur during the execution of this workflow?

  1. 1An HTTP-triggered client function starts the orchestration using the Durable Task client and returns an HTTP 202 response containing status query URIs.
  2. 2The orchestrator function begins execution, schedules the transcoding activity function, and yields control when the activity task is awaited.
  3. 3The transcoding activity completes; the runtime restarts the orchestrator, which replays execution and retrieves the transcoding result from history without re-running the activity.
  4. 4The orchestrator schedules multiple analysis activities in parallel, aggregates their task objects, and yields control by awaiting Task.WhenAll.
  5. 5All parallel analysis activities finish; the orchestrator restarts, replays history, runs the final aggregation activity, and transitions to the Completed state.

Cevap

The correct order of events starts with the client launching the orchestration, followed by the orchestrator initiating execution and yielding at the transcoding task. Once completed, the orchestrator replays to resolve the transcoding result and then invokes the parallel analysis activities, yielding on their concurrent execution. Finally, after all analysis tasks finish, the orchestrator replays a last time to retrieve their values, runs the aggregation activity, and finishes.
The execution begins with the client starting the orchestration. The orchestrator runs and yields at the first await (transcoding). After the transcode completes, the orchestrator replays the function, retrieves the transcoding result from history, runs the parallel tasks, and yields again. Once the parallel tasks complete, the orchestrator replays to obtain all analysis results, runs the final aggregation activity, and completes.

Adım Adım Çözüm

1
Trigger the orchestration.
An orchestration instance is created and a status response is returned.
The client function initiates the orchestration lifecycle using the Durable Task client.
2
Execute the orchestrator up to the first await point.
The transcoding activity is scheduled and the orchestrator yields.
The orchestrator executes sequentially until it encounters an await on an asynchronous activity task.
3
Replay the orchestrator after the transcode completes.
The transcoding result is read from the execution history.
Durable Functions use event sourcing; the orchestrator replays from the start to reconstruct its state.
4
Schedule parallel tasks and yield.
Parallel activities are scheduled, and the orchestrator yields on Task.WhenAll.
For the Fan-out pattern, multiple tasks are scheduled concurrently and awaited together.
5
Replay and complete the orchestration.
The aggregation activity runs and the orchestrator completes.
After all parallel tasks finish, the orchestrator replays one last time, processes the aggregated data, and completes.

Anahtar Kavram

Durable Functions Orchestrator Replay and Execution Lifecycle
Bu soruyu puanla