You can expose a long-running Temporal Workflow's queries, updates, and signals as Nexus operations using two primary patterns depending on your requirements for lifecycle control and Workflow ID management.
Caller Pattern
Use this pattern when the Workflow is managed by a handler worker that starts it automatically on boot. The caller does not need to know the Workflow ID, as the handler manages it.
- Workflow Creation: The handler worker starts the Workflow on boot.
- Workflow ID: Managed internally by the handler.
- Nexus Service Example:
NexusGreetingService
On-Demand Pattern
Use this pattern when the caller needs full control over the Workflow lifecycle and identity. The caller is responsible for creating the Workflow and providing the Workflow ID for every subsequent operation.
- Workflow Creation: The caller starts the Workflow via a Nexus operation.
- Workflow ID: The caller chooses and passes the ID in every operation.
- Nexus Service Example:
NexusRemoteGreetingService
| | `callerpattern/` | `ondemandpattern/` |
|--------------------------------|--------------------------------------|--------------------------------------------------------------------------------|
| **Pattern** | Signal an existing Workflow | Create and run Workflows on demand, and send signals to them |
| **Who creates the Workflow?** | The handler worker starts it on boot | The caller starts it via a Nexus operation |
| **Who knows the Workflow ID?** | Only the handler | The caller chooses and passes it in every operation |
| **Nexus service** | `NexusGreetingService` | `NexusRemoteGreetingService` |