Skip to main content

Temporal Operation Handler

View Markdown

Temporal has unified the Workflow handler and the synchronous Operation handler into a single handler, and added the ability to back an Operation with a Standalone Activity.

What runs behind an Operation remains private to the handler, so you can change it later without touching the contract or any caller.

The Nexus-aware Client​

The Operation handler receives a context, the Operation input, and a Client.

That Client is not an ordinary Temporal Client. It propagates bidirectional links and request IDs on every call, so caller-side and handler-side Executions are connected in the UI and in Event History without wiring anything. Constructing your own Client inside a handler works, but the Executions it starts are not linked back to the caller.

It exposes two kinds of call:

  • Async backings, at most one per Operation invocation. These determine what the Operation is, and their result reaches the caller through the Nexus completion callback. Starting a Workflow, starting an Activity, and starting a Workflow Update are all async backings.
  • Sync messaging, as many as you need. Queries, Signals, and Signal-with-Start complete during the handler call and do not require an async backing. A Query reads Workflow state, so an Operation that answers from a Query returns its result synchronously.
info

Querying a Workflow from an Operation handler is available in Temporal Cloud, and as a pre-release on a self-hosted Temporal Service in Server v1.33.0. To try it on a local development server, install the v1.8.3-server-1.32.0-162.0 Temporal CLI pre-release, which bundles a Server build with Nexus Query support.

Deriving the backing Execution's ID from the Nexus request ID keeps a retried start request targeting the same Execution instead of creating a second one.