Skip to content

Sample code for Nexus messaging#776

Open
Evanthx wants to merge 6 commits intomainfrom
signals-nexus-java
Open

Sample code for Nexus messaging#776
Evanthx wants to merge 6 commits intomainfrom
signals-nexus-java

Conversation

@Evanthx
Copy link
Copy Markdown
Contributor

@Evanthx Evanthx commented Apr 8, 2026

This shows two ways to send messages through Nexus.

@Evanthx Evanthx requested review from a team, antmendoza and tsurdilo as code owners April 8, 2026 21:53
public interface NexusRemoteGreetingService {

class RunFromRemoteInput {
private final String workflowId;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So part of the reason to wrap a Workflow in a Nexus service is to hide the workflow from the caller, so I wouldn't call this ID workflowId the service doesn't need to expose that it using workflows to the caller.

.newWorkflowStub(
GreetingWorkflow.class,
WorkflowOptions.newBuilder()
.setWorkflowId(input.getWorkflowId())
Copy link
Copy Markdown
Contributor

@Quinn-With-Two-Ns Quinn-With-Two-Ns Apr 9, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Even though it make make the sample a bit more complex, I wonder if we should show here the workflow ID doesn't have to directly map to the nexus operation input. The workflow ID can just be derived/computed liked .setWorkflowId("NexusRemoteGreetingServiceWorkflow-" + input.getId())

operations. The caller interacts only with the Nexus service; the workflow is a private
implementation detail.

There are **two caller patterns** that share the same handler workflow (`GreetingWorkflow`):
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think I would split these up into two separate samples since the amount of code here could be overwhelming and make it harder to follow

public class CallerStarter {

public static void main(String[] args) {
WorkflowServiceStubs service = WorkflowServiceStubs.newLocalServiceStubs();
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All samples should support env config. You can look at other samples to see how to create the client and follow the pattern there https://github.com/temporalio/samples-java/blob/main/core/src/main/java/io/temporal/samples/asyncchild/Starter.java#L22

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants