This sample demonstrates how to expose a long-running Temporal Workflow's queries, updates, and signals as Nexus operations. It provides two distinct architectural patterns depending on whether the caller needs to manage the Workflow lifecycle or simply interact with an existing one.
Pattern 1: Caller Pattern (callerpattern/)
Use this pattern when you want to signal an existing Workflow that is already running.
- Workflow Creation: The handler worker starts the Workflow automatically on boot.
- Workflow ID Management: Only the handler knows the Workflow ID; the caller interacts with the Nexus service without needing to know the specific ID.
- Nexus Service: Implemented via
NexusGreetingService.
Pattern 2: On-Demand Pattern (ondemandpattern/)
Use this pattern when you want to create and run Workflows on demand and then send signals to them.
- Workflow Creation: The caller starts the Workflow by invoking a Nexus operation.
- Workflow ID Management: The caller chooses and passes the Workflow ID in every operation.
- Nexus Service: Implemented via
NexusRemoteGreetingService.
In both patterns, the core Workflow logic (GreetingWorkflow, GreetingWorkflowImpl) and Activities (GreetingActivity, GreetingActivityImpl) remain consistent; only the Nexus service interface and implementation change to accommodate the different lifecycle requirements.