Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
## Caller pattern

The handler worker starts a `GreetingWorkflow` for a User ID.
`NexusGreetingServiceImpl` holds that ID and routes every Nexus operation to it.
`NexusGreetingServiceImpl` 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 `NexusGreetingServiceImpl` knows how to get the desired Workflow ID from that User ID (see the getWorkflowId call).
and `NexusGreetingServiceImpl` knows how to get the desired Workflow ID from that User ID (see the `getWorkflowId` call).

HandlerWorker is using the same getWorkflowId call to generate a Workflow ID from a User ID when it launches the Workflow.
`HandlerWorker` is using the same `getWorkflowId` call to generate a Workflow ID from a User ID when it launches the Workflow.

The caller Workflow:
1. Queries for supported languages (`getLanguages` — backed by a `@QueryMethod`)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,9 @@
import org.slf4j.LoggerFactory;

/**
* Nexus operation handler for the on-demand pattern. Each operation receives the target workflow ID
* in its input, and {@code runFromRemote} starts a brand-new GreetingWorkflow.
* Nexus operation handler for the on-demand pattern. Each operation receives a userId, which is
* mapped to a workflow ID using {@link #WORKFLOW_ID_PREFIX}, and {@code runFromRemote} starts a
* brand-new GreetingWorkflow.
*/
@ServiceImpl(service = NexusRemoteGreetingService.class)
public class NexusRemoteGreetingServiceImpl {
Expand All @@ -38,8 +39,8 @@ private GreetingWorkflow getWorkflowStub(String userId) {
.newWorkflowStub(GreetingWorkflow.class, getWorkflowId(userId));
}

// Starts a new GreetingWorkflow with the caller-specified workflow ID. This is an async
// Nexus operation backed by WorkflowRunOperation.
// Starts a new GreetingWorkflow, using a workflow ID derived from the caller-supplied userId.
// This is an async Nexus operation backed by WorkflowRunOperation.
@OperationImpl
public OperationHandler<NexusRemoteGreetingService.RunFromRemoteInput, String> runFromRemote() {
return WorkflowRunOperation.fromWorkflowHandle(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
This sample shows how to expose a long-running Workflow's queries, updates, and signals as Nexus operations. This
version uses the experimental `@TemporalOperation` annotation to declare Temporal-backed Nexus operations as ordinary
methods on `@ServiceImpl` classes instead of `@OperationImpl` factories that return `TemporalOperationHandler.create(...)`.
methods on `@ServiceImpl` classes instead of `@OperationImpl` factories that return `OperationHandler.sync(...)` and
`WorkflowRunOperation.fromWorkflowHandle(...)`.

There are two self-contained examples, each in its own directory:

Expand Down
Loading