The handler worker starts a GreetingWorkflow for a User ID.
NexusGreetingServiceHandler derives the Workflow ID and routes every Nexus operation to it.
The caller's input does not have that Workflow ID as the caller doesn't know it -- but the caller
sends in the User ID, and NexusGreetingServiceHandler knows how to get the desired Workflow ID
from that User ID (see the get_workflow_id call).
The handler worker uses the same get_workflow_id call to generate a Workflow ID from a User ID
when it launches the Workflow.
The caller Workflow:
- Queries for supported languages (
get_languages-- backed by a@workflow.query) - Changes the language to Arabic (
set_language-- backed by a@workflow.updatethat calls an activity) - Confirms the change via a second query (
get_language) - Approves the Workflow (
approve-- backed by a@workflow.signal)
This sample requires a Temporal dev server build that supports Workflow Update callbacks. Download the compatible binary from the Temporal CLI pre-release instructions.
Start the Temporal dev server with the required namespaces pre-created and Workflow Update callbacks enabled:
./temporal server start-dev \
--dynamic-config-value history.enableUpdateCallbacks=true \
--dynamic-config-value history.enableCHASMSignalBacklinks=true \
--namespace nexus-messaging-handler-namespace \
--namespace nexus-messaging-caller-namespaceCreate the Nexus endpoint:
./temporal operator nexus endpoint create \
--name nexus-messaging-nexus-endpoint \
--target-namespace nexus-messaging-handler-namespace \
--target-task-queue nexus-messaging-handler-task-queueIn one terminal, start the handler worker:
uv run python -m nexus_messaging.callerpattern.handler.workerIn another terminal, run the following command to start the example:
uv run python -m nexus_messaging.callerpattern.caller.appExpected output:
Supported languages: [<Language.CHINESE: 2>, <Language.ENGLISH: 3>]
Language changed: ENGLISH -> ARABIC
Workflow approved