The handler worker starts a GreetingWorkflow for a User ID.
NexusGreetingServiceHandler holds that 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 Wser 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)
Start a Temporal server:
temporal server start-devCreate the namespaces and Nexus endpoint:
temporal operator namespace create --namespace nexus-messaging-handler-namespace
temporal operator namespace create --namespace nexus-messaging-caller-namespace
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