Skip to content

Show in the five workflow SDK quickstarts that a workflow continues after a restart - #1395

Open
nelson-parente wants to merge 11 commits into
dapr:masterfrom
nelson-parente:workflow-quickstart-durability
Open

nelson-parente wants to merge 11 commits into
dapr:masterfrom
nelson-parente:workflow-quickstart-durability

Conversation

@nelson-parente

@nelson-parente nelson-parente commented Oct 29, 2026 •

Copy link
Copy Markdown
Contributor

This pull request does not need #1394. Both change the same parts of the Go, Java and Python READMEs, so the one that merges second needs a rebase.

Each workflow SDK quickstart now shows in the first run that a workflow keeps its progress when the app stops.

Changes

The behavior is the same in Python, JavaScript, .NET, Java and Go:

  • The order is 2 cars at 5,000 each, so the workflow waits up to 10 minutes for ApprovalEvent.
  • The app uses ORDER_ID as the workflow instance ID. Without it, the ID is order-<yyyymmdd-hhmmss>.
  • At start, the app schedules a missing instance, waits for a running instance, and prints the status of an instance that ended.
  • The app writes the inventory only when the key is absent, so a restart does not add stock.
  • The approval handler accepts a JSON object and a JSON string that holds the object. dapr workflow raise-event --input sends the string form.
  • Java: the first state call retries for up to 60 seconds while the sidecar answers UNAVAILABLE.
  • Each README stops the app, starts it again, and approves the order with one command: dapr workflow raise-event $ORDER_ID/ApprovalEvent --app-id order-processor --input '{"approved": true}'.

Tests

The README steps ran in a container with Dapr 1.19.0, Redis, Placement and Scheduler. A run passed when the instance reached COMPLETED.

  • Python, JavaScript, .NET, Go: Redis and SQLite, pass.
  • Java: Redis (3 runs) and SQLite (2 runs), pass.
  • mm.py -l README.md (mechanical-markdown) passes for the five READMEs on Redis.

🤖 Generated with Claude Code

nelson-parente and others added 7 commits November 6, 2026 11:32
…ives a restart

The order is now 2 cars at 5,000 each, so the workflow waits for approval.
The app uses ORDER_ID (or order-<yyyymmdd-hhmmss>) as the instance ID. It
attaches to an instance that is still running, schedules a new one when none
exists, and prints the status when the instance ended. The inventory is
written only when the key is absent. The approval event is named
ApprovalEvent, takes {"approved": true|false}, and times out after 10 minutes.
The README now stops the app, starts it again, and approves the order.

Signed-off-by: Nelson Parente <nelson_parente@live.com.pt>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ickstart

The order processor now orders two cars at 5000 each. The total is over
5000, so the workflow waits for ApprovalEvent (timeout 10 minutes).

The app reads ORDER_ID as the workflow instance ID. It schedules the
instance when it does not exist, waits for it when it is running, and
prints its status when it ended. It seeds the inventory only when the key
is absent, so a restart does not add stock again. The approval handler
accepts a JSON object or a JSON string, because the Dapr CLI sends the
--input value as a JSON string.

The README shows how to stop the app, start it again, approve the order
with dapr workflow raise-event, and see the workflow continue. The same
steps are in the run without Docker section.

Signed-off-by: Nelson Parente <nelson_parente@live.com.pt>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The order is now 2 cars at 5000 each, so it waits for an approval.
The app reads ORDER_ID as the workflow instance ID, attaches to an
instance that is still running, and writes the inventory only when it
is not in the store. The approval wait is 10 minutes, and the approval
event accepts a JSON object or a JSON string that holds the object.
The README stops the app during the wait, starts it again, and approves
the order with the Dapr CLI.

Signed-off-by: Nelson Parente <nelson_parente@live.com.pt>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The order-processor app now reads the order ID from ORDER_ID, places an
order of 2 cars at 5000 each, and waits for the ApprovalEvent event for
up to 10 minutes. A second start of the app finds the instance that is
running and waits for it instead of scheduling a new one. The app
writes the inventory only when the key is absent.

The workflow function does not log. The approval activity prints the
line that shows it ran. The approval payload accepts a JSON object and
a JSON string that holds the object, which is what the Dapr CLI sends.
The README walks through stop, restart and approve.

Signed-off-by: Nelson Parente <nelson_parente@live.com.pt>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…resume

The Go workflow quickstart now orders 2 cars at 5000 each, so the workflow
waits for the ApprovalEvent event. The app reads the instance ID from
ORDER_ID, attaches to an instance that is still running, and writes the
starting inventory only when it is not in the state store. The workflow
logs only from activities, and the README steps stop the app, start it
again, and approve the order with `dapr workflow raise-event`.

Signed-off-by: Nelson Parente <nelson_parente@live.com.pt>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…idecar starts

Right after the sidecar starts, the workflow runtime of the sidecar can
answer a call with UNAVAILABLE ("actor runtime is closed"). The first
getInstanceState call of the app, which checks whether the order exists,
failed with that error and ended the app.

Retry the call every second for up to 60 seconds while the status is
UNAVAILABLE. Any other error is thrown at once.

Signed-off-by: Nelson Parente <nelson_parente@live.com.pt>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…EADMEs

Write the approve step the same way in the Python, JavaScript, .NET, Java
and Go READMEs: `dapr workflow raise-event $ORDER_ID/ApprovalEvent
--app-id order-processor --input '{"approved": true}'`. The text before the
command tells the reader to set ORDER_ID, in the second terminal, to the
order ID that the app printed. The approve STEP block sets ORDER_ID to
order-validate, so mechanical-markdown runs the same command that the
reader runs.

Signed-off-by: Nelson Parente <nelson_parente@live.com.pt>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@nelson-parente
nelson-parente force-pushed the workflow-quickstart-durability branch from d3e6930 to af390b3 Compare November 6, 2026 11:33
@nelson-parente
nelson-parente marked this pull request as ready for review November 6, 2026 11:33
@nelson-parente
nelson-parente requested review from a team as code owners November 6, 2026 11:33
JoshVanL
JoshVanL previously approved these changes Nov 6, 2026
…proval

The console app now uses runOrder, which waits for approval and resumes
after a restart. The Express and DaprServer entry points still use
processOrder, which runs one order of 1 car (total 5000). That total is
not over the approval threshold, so the HTTP call returns without an
approval step.

The README said that both entry points share the console app's order
lifecycle. That is no longer true, so the README and a comment on
processOrder now describe the difference.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Nelson Parente <nelson_parente@live.com.pt>
nelson-parente and others added 3 commits November 9, 2026 12:18
Resolve the conflicts with dapr#1394 in the Go, Java and Python SDK
READMEs. This branch replaces the run steps, the expected output and
the "What happened" list with the stop, restart and approve flow, so
the conflicting hunks keep this branch. The other dapr#1394 changes in these
files stay.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01LWoz3gpTsSSL3KbxrLqcW1
Signed-off-by: Nelson Parente <nelson_parente@live.com.pt>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants