You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This sample demonstrates how to use Standalone Nexus Operations (executing Nexus operations directly from client code without wrapping them in a Workflow).
2
2
It shows both sync and async (workflow-backed) operations, and how to use the `ListNexusOperations` and `CountNexusOperations` APIs.
3
3
4
-
## Note: Standalone Nexus operations require a server version that supports this feature. Use the dev server build at https://github.com/temporalio/cli/releases/tag/v1.7.3-standalone-nexus-operations.
4
+
The starter and worker connect to two different namespaces (a "caller" namespace and a "handler" namespace) — this mirrors how Nexus is typically used to cross namespace boundaries. The client is configured via the SDK's [environment configuration](https://docs.temporal.io/develop/environment-configuration) support, which reads `TEMPORAL_NAMESPACE`, `TEMPORAL_ADDRESS`, etc. from the environment (and optionally profiles from `temporal.toml`).
5
5
6
-
### Steps to run this sample (with expected output):
7
-
1) Run the [Temporal dev server build that supports standalone Nexus operations](https://github.com/temporalio/cli/releases/tag/v1.7.3-standalone-nexus-operations). (If you are going to run locally, you will want to start it in another terminal; this command is blocking and runs until it receives a SIGINT (Ctrl + C) command.)
6
+
## Note: Standalone Nexus operations require a server version that supports this feature. Use the dev server build at https://github.com/temporalio/cli/releases/tag/v1.7.4-standalone-nexus-operations.
8
7
9
-
Start the dev server with the dynamic config flags required for standalone Nexus operations:
8
+
## Run locally against a dev server
9
+
10
+
1) Start the [Temporal dev server build that supports standalone Nexus operations](https://docs.temporal.io/standalone-nexus-operation#temporal-cli-support) with the required namespaces pre-created:
You should see a line about the CLI, Server and UI versions, and one line each for the Server URL, UI URL and Metrics endpoint. It should look something like this:
18
+
2) Create a Nexus endpoint that routes to the handler namespace and the worker's task queue:
2) Create a Nexus endpoint that routes to the worker's task queue. In a second terminal, run:
28
-
```bash
29
-
temporal operator nexus endpoint create \
30
-
--name nexus-standalone-operations-endpoint \
31
-
--target-namespace default \
32
-
--target-task-queue nexus-standalone-operations
33
-
```
27
+
3) In a new terminal, start the worker in the handler namespace:
34
28
35
-
1) Then run the following command to start the worker. The worker is a blocking process that runs until it receives a SIGINT (Ctrl + C) command.
36
29
```bash
37
-
go run nexus-standalone-operations/worker/main.go
30
+
TEMPORAL_NAMESPACE=my-handler-namespace \
31
+
go run nexus-standalone-operations/worker/main.go
38
32
```
39
33
40
-
You should see the following log line:
41
-
1. Starting the Worker with Namespace `default`, and TaskQueue `nexus-standalone-operations` and it will list the WorkerID for the created worker.
34
+
You should see a log line similar to:
42
35
43
-
For example:
44
36
```bash
45
-
2026/05/21 08:59:49 INFO Started Worker Namespace default TaskQueue nexus-standalone-operations WorkerID 71172
37
+
2026/05/21 08:59:49 INFO Started Worker Namespace my-handler-namespace TaskQueue nexus-handler-queue WorkerID 71172
46
38
```
47
39
48
-
> [!NOTE]
49
-
> Timestamps and IDs will differ on your machine.
40
+
4) In a third terminal, run the starter in the caller namespace:
50
41
51
-
4) In a third terminal, run the following command to start the example:
52
42
```bash
53
-
go run nexus-standalone-operations/starter/main.go
43
+
TEMPORAL_NAMESPACE=my-caller-namespace \
44
+
go run nexus-standalone-operations/starter/main.go
54
45
```
55
46
56
-
You should see something similar to the following output:
47
+
You should see something similar to:
57
48
58
49
```bash
59
50
2026/05/21 09:00:30 Started Echo operation OperationID nexus-standalone-echo-op
@@ -66,5 +57,44 @@ You should see something similar to the following output:
66
57
2026/05/21 09:00:30 Total Nexus operations: 2
67
58
```
68
59
69
-
If you run the starter code multiple times, you should see additional `ListNexusOperations` results, as more operations are run.
70
-
The same goes for the number from `CountNexusOperations`.
60
+
If you run the starter multiple times, additional entries will appear in the `ListNexusOperations` output and the `CountNexusOperations` total will grow.
61
+
62
+
## Run against Temporal Cloud
63
+
64
+
1) Create two namespaces in Temporal Cloud (for example `my-caller-namespace.<account>` and `my-handler-namespace.<account>`) and generate an API key (or mTLS cert) that can access both.
65
+
66
+
2) Create a Nexus endpoint that targets the handler namespace and the worker's task queue. See the Temporal Cloud instructions at https://docs.temporal.io/nexus/registry#create-a-nexus-endpoint. Use:
- Allowed caller namespaces: include `my-caller-namespace.<account>` (endpoints reject callers that are not on this list)
71
+
72
+
3) Add two profiles to your [environment configuration file](https://docs.temporal.io/develop/environment-configuration), one per namespace. Using API keys:
73
+
74
+
```toml
75
+
[profile.handler]
76
+
address = "<region>.<cloud>.api.temporal.io:7233"
77
+
namespace = "my-handler-namespace.<account>"
78
+
api_key = "<your-api-key>"
79
+
80
+
[profile.caller]
81
+
address = "<region>.<cloud>.api.temporal.io:7233"
82
+
namespace = "my-caller-namespace.<account>"
83
+
api_key = "<your-api-key>"
84
+
```
85
+
86
+
For mTLS instead of API keys, set `tls.client_cert_path` and `tls.client_key_path` on each profile (see the [docs](https://docs.temporal.io/develop/environment-configuration) for the full schema).
87
+
88
+
4) Run the worker and starter in separate terminals, selecting the appropriate profile in each:
89
+
90
+
```bash
91
+
# terminal 1 (worker, handler namespace)
92
+
export TEMPORAL_PROFILE="handler"
93
+
go run nexus-standalone-operations/worker/main.go
94
+
```
95
+
96
+
```bash
97
+
# terminal 2 (starter, caller namespace)
98
+
export TEMPORAL_PROFILE="caller"
99
+
go run nexus-standalone-operations/starter/main.go
0 commit comments