Workflow Message Passing - Interactive Demo
What is Workflow Message Passing?
You've started a long-running Workflow. It's running. Now what? How do you check on its progress? How do you tell it something changed? How do you get a value out of it?
The core idea in one sentence
You define named handlers on your Workflow for three types of messages: Signals (push a notification in), Queries (read state out), and Updates (change state and get a result back). Your client calls them by name on a Workflow handle, and the running Workflow reacts.
A concrete way to see it
Say you have a chef cooking a multi-course meal. The meal is in progress and the chef keeps working, but the rest of the restaurant still needs to reach them:
A waiter tells the chef "Table six would like more bread." The chef notes it and keeps cooking. No reply needed. The waiter moves on.
A manager asks "How many courses have gone out?" The chef checks the board and answers without stopping work.
A customer asks "Can you add a dessert?" The chef checks if there's still time. If yes: "Added." If no: "The order is already closed." The customer waits for that answer before leaving the table.
The three types, side by side
| Type | Like saying... | Gets a response? | Can change state? |
|---|---|---|---|
| Signal | "Hey, FYI" | No | Yes |
| Query | "What's the current status?" | Yes (read-only) | No |
| Update | "Please change X and confirm it" | Yes (result or rejection) | Yes |
What it looks like in code
handle.signal(approve)handle.query(get_status)handle.execute_update(set_priority, 3)@workflow.signal approve()@workflow.query get_status()@workflow.update set_priority()