You've authored your first workflow with activities. It runs, processes tasks, and returns results. But what happens when you need to:
Authoring workflows is only half the story. Production systems require workflow management: starting instances on demand, querying their status, injecting external events, and cleaning up completed runs. This lesson gives you the operational toolkit for workflow lifecycle management.
Dapr's DaprWorkflowClient provides the control plane for your workflows. While WorkflowRuntime handles execution (registering and running workflows), DaprWorkflowClient handles management (starting, querying, and controlling workflow instances).
Think of it like this:
The control room operators don't assemble products; they monitor production lines, start new runs, and intervene when something goes wrong.
The schedule_new_workflow method starts a new workflow instance:
Output:
You can also specify a custom instance ID for easier tracking:
Custom instance IDs are valuable for Idempotency, Correlation, and Debugging.
The Dapr CLI provides workflow management without writing code:
Once a workflow is running, you need visibility into its state. The get_workflow_state method returns comprehensive status information:
External events enable human-in-the-loop workflows. A workflow pauses with wait_for_external_event, and an external process sends the event to resume execution.
For administrative control, you can pause a running workflow and resume it later:
Termination forcibly stops a workflow immediately. It is marked as TERMINATED.
Warning: Termination does not run compensation logic.
Completed workflows leave history in the state store. Purging removes it permanently.
Here's a FastAPI application exposing workflow management endpoints:
Does your dapr-deployment skill understand workflow management operations?
If your skill covers wait_for_external_event and signal buffering, it's working correctly.
Prompt 2: Build a Workflow Dashboard
Prompt 3: Event Pattern Troubleshooting
Safety Note: Workflow management operations are powerful. In production, implement access controls on management endpoints and log all operations for audit trails.