Interface TemporalNexusClient


@Experimental public interface TemporalNexusClient
Nexus-aware client wrapping WorkflowClient. Provides methods for interacting with Temporal from within a Nexus operation handler.

Obtained via the TemporalOperationHandler.StartHandler parameter.

Example usage to start a workflow from an operation handler:


 @OperationImpl
 public OperationHandler<TransferInput, TransferResult> startTransfer() {
   return TemporalOperationHandler.create((context, client, input) -> {
     return client.startWorkflow(
         TransferWorkflow.class,
         TransferWorkflow::transfer, input.getFromAccount(), input.getToAccount(),
         WorkflowOptions.newBuilder()
             .setWorkflowId("transfer-" + input.getTransferId())
             .build());
   });
 }
 

For synchronous operations, use getWorkflowClient() directly and return a TemporalOperationResult.sync(R) result. For example, to send a signal:


 @OperationImpl
 public OperationHandler<CancelOrderInput, Void> cancelOrder() {
   return TemporalOperationHandler.create((context, client, input) -> {
     client.getWorkflowClient()
         .newUntypedWorkflowStub("order-" + input.getOrderId())
         .signal("requestCancellation", input);
     return TemporalOperationResult.sync(null);
   });
 }
 
  • Method Details

    • getWorkflowClient

      WorkflowClient getWorkflowClient()
      Returns the underlying WorkflowClient for advanced use cases.
    • startWorkflow

      <T, R> TemporalOperationResult<R> startWorkflow(Class<T> workflowClass, Functions.Func1<T,R> workflowMethod, WorkflowOptions options)
      Starts a zero-argument workflow that returns a value.

      Example:

      
       client.startWorkflow(MyWorkflow.class, MyWorkflow::run, options)
       
      Type Parameters:
      T - the workflow interface type
      R - the workflow return type
      Parameters:
      workflowClass - the workflow interface class
      workflowMethod - unbound method reference to the workflow method
      options - workflow start options (must include workflowId)
      Returns:
      an async TemporalOperationResult with the workflow-run operation token
    • startWorkflow

      <T, A1, R> TemporalOperationResult<R> startWorkflow(Class<T> workflowClass, Functions.Func2<T,A1,R> workflowMethod, A1 arg1, WorkflowOptions options)
      Starts a one-argument workflow that returns a value.

      Example:

      
       client.startWorkflow(MyWorkflow.class, MyWorkflow::processOrder, input, options)
       
      Type Parameters:
      T - the workflow interface type
      A1 - the type of the first workflow argument
      R - the workflow return type
      Parameters:
      workflowClass - the workflow interface class
      workflowMethod - unbound method reference to the workflow method
      arg1 - first workflow argument
      options - workflow start options (must include workflowId)
      Returns:
      an async TemporalOperationResult with the workflow-run operation token
    • startWorkflow

      <T, A1, A2, R> TemporalOperationResult<R> startWorkflow(Class<T> workflowClass, Functions.Func3<T,A1,A2,R> workflowMethod, A1 arg1, A2 arg2, WorkflowOptions options)
      Starts a two-argument workflow that returns a value.

      Example:

      
       client.startWorkflow(MyWorkflow.class, MyWorkflow::run, arg1, arg2, options)
       
      Type Parameters:
      T - the workflow interface type
      A1 - the type of the first workflow argument
      A2 - the type of the second workflow argument
      R - the workflow return type
      Parameters:
      workflowClass - the workflow interface class
      workflowMethod - unbound method reference to the workflow method
      arg1 - first workflow argument
      arg2 - second workflow argument
      options - workflow start options (must include workflowId)
      Returns:
      an async TemporalOperationResult with the workflow-run operation token
    • startWorkflow

      <T, A1, A2, A3, R> TemporalOperationResult<R> startWorkflow(Class<T> workflowClass, Functions.Func4<T,A1,A2,A3,R> workflowMethod, A1 arg1, A2 arg2, A3 arg3, WorkflowOptions options)
      Starts a three-argument workflow that returns a value.

      Example:

      
       client.startWorkflow(MyWorkflow.class, MyWorkflow::run, arg1, arg2, arg3, options)
       
      Type Parameters:
      T - the workflow interface type
      A1 - the type of the first workflow argument
      A2 - the type of the second workflow argument
      A3 - the type of the third workflow argument
      R - the workflow return type
      Parameters:
      workflowClass - the workflow interface class
      workflowMethod - unbound method reference to the workflow method
      arg1 - first workflow argument
      arg2 - second workflow argument
      arg3 - third workflow argument
      options - workflow start options (must include workflowId)
      Returns:
      an async TemporalOperationResult with the workflow-run operation token
    • startWorkflow

      <T, A1, A2, A3, A4, R> TemporalOperationResult<R> startWorkflow(Class<T> workflowClass, Functions.Func5<T,A1,A2,A3,A4,R> workflowMethod, A1 arg1, A2 arg2, A3 arg3, A4 arg4, WorkflowOptions options)
      Starts a four-argument workflow that returns a value.

      Example:

      
       client.startWorkflow(MyWorkflow.class, MyWorkflow::run, arg1, arg2, arg3, arg4, options)
       
      Type Parameters:
      T - the workflow interface type
      A1 - the type of the first workflow argument
      A2 - the type of the second workflow argument
      A3 - the type of the third workflow argument
      A4 - the type of the fourth workflow argument
      R - the workflow return type
      Parameters:
      workflowClass - the workflow interface class
      workflowMethod - unbound method reference to the workflow method
      arg1 - first workflow argument
      arg2 - second workflow argument
      arg3 - third workflow argument
      arg4 - fourth workflow argument
      options - workflow start options (must include workflowId)
      Returns:
      an async TemporalOperationResult with the workflow-run operation token
    • startWorkflow

      <T, A1, A2, A3, A4, A5, R> TemporalOperationResult<R> startWorkflow(Class<T> workflowClass, Functions.Func6<T,A1,A2,A3,A4,A5,R> workflowMethod, A1 arg1, A2 arg2, A3 arg3, A4 arg4, A5 arg5, WorkflowOptions options)
      Starts a five-argument workflow that returns a value.

      Example:

      
       client.startWorkflow(MyWorkflow.class, MyWorkflow::run, arg1, arg2, arg3, arg4, arg5, options)
       
      Type Parameters:
      T - the workflow interface type
      A1 - the type of the first workflow argument
      A2 - the type of the second workflow argument
      A3 - the type of the third workflow argument
      A4 - the type of the fourth workflow argument
      A5 - the type of the fifth workflow argument
      R - the workflow return type
      Parameters:
      workflowClass - the workflow interface class
      workflowMethod - unbound method reference to the workflow method
      arg1 - first workflow argument
      arg2 - second workflow argument
      arg3 - third workflow argument
      arg4 - fourth workflow argument
      arg5 - fifth workflow argument
      options - workflow start options (must include workflowId)
      Returns:
      an async TemporalOperationResult with the workflow-run operation token
    • startWorkflow

      <T, A1, A2, A3, A4, A5, A6, R> TemporalOperationResult<R> startWorkflow(Class<T> workflowClass, Functions.Func7<T,A1,A2,A3,A4,A5,A6,R> workflowMethod, A1 arg1, A2 arg2, A3 arg3, A4 arg4, A5 arg5, A6 arg6, WorkflowOptions options)
      Starts a six-argument workflow that returns a value.

      Example:

      
       client.startWorkflow(MyWorkflow.class, MyWorkflow::run, arg1, arg2, arg3, arg4, arg5, arg6, options)
       
      Type Parameters:
      T - the workflow interface type
      A1 - the type of the first workflow argument
      A2 - the type of the second workflow argument
      A3 - the type of the third workflow argument
      A4 - the type of the fourth workflow argument
      A5 - the type of the fifth workflow argument
      A6 - the type of the sixth workflow argument
      R - the workflow return type
      Parameters:
      workflowClass - the workflow interface class
      workflowMethod - unbound method reference to the workflow method
      arg1 - first workflow argument
      arg2 - second workflow argument
      arg3 - third workflow argument
      arg4 - fourth workflow argument
      arg5 - fifth workflow argument
      arg6 - sixth workflow argument
      options - workflow start options (must include workflowId)
      Returns:
      an async TemporalOperationResult with the workflow-run operation token
    • startWorkflow

      <T> TemporalOperationResult<Void> startWorkflow(Class<T> workflowClass, Functions.Proc1<T> workflowMethod, WorkflowOptions options)
      Starts a zero-argument workflow with no return value.

      Example:

      
       client.startWorkflow(MyWorkflow.class, MyWorkflow::execute, options)
       
      Type Parameters:
      T - the workflow interface type
      Parameters:
      workflowClass - the workflow interface class
      workflowMethod - unbound method reference to the workflow method
      options - workflow start options (must include workflowId)
      Returns:
      an async TemporalOperationResult with the workflow-run operation token
    • startWorkflow

      <T, A1> TemporalOperationResult<Void> startWorkflow(Class<T> workflowClass, Functions.Proc2<T,A1> workflowMethod, A1 arg1, WorkflowOptions options)
      Starts a one-argument workflow with no return value.

      Example:

      
       client.startWorkflow(MyWorkflow.class, MyWorkflow::execute, input, options)
       
      Type Parameters:
      T - the workflow interface type
      A1 - the type of the first workflow argument
      Parameters:
      workflowClass - the workflow interface class
      workflowMethod - unbound method reference to the workflow method
      arg1 - first workflow argument
      options - workflow start options (must include workflowId)
      Returns:
      an async TemporalOperationResult with the workflow-run operation token
    • startWorkflow

      <T, A1, A2> TemporalOperationResult<Void> startWorkflow(Class<T> workflowClass, Functions.Proc3<T,A1,A2> workflowMethod, A1 arg1, A2 arg2, WorkflowOptions options)
      Starts a two-argument workflow with no return value.

      Example:

      
       client.startWorkflow(MyWorkflow.class, MyWorkflow::execute, arg1, arg2, options)
       
      Type Parameters:
      T - the workflow interface type
      A1 - the type of the first workflow argument
      A2 - the type of the second workflow argument
      Parameters:
      workflowClass - the workflow interface class
      workflowMethod - unbound method reference to the workflow method
      arg1 - first workflow argument
      arg2 - second workflow argument
      options - workflow start options (must include workflowId)
      Returns:
      an async TemporalOperationResult with the workflow-run operation token
    • startWorkflow

      <T, A1, A2, A3> TemporalOperationResult<Void> startWorkflow(Class<T> workflowClass, Functions.Proc4<T,A1,A2,A3> workflowMethod, A1 arg1, A2 arg2, A3 arg3, WorkflowOptions options)
      Starts a three-argument workflow with no return value.

      Example:

      
       client.startWorkflow(MyWorkflow.class, MyWorkflow::execute, arg1, arg2, arg3, options)
       
      Type Parameters:
      T - the workflow interface type
      A1 - the type of the first workflow argument
      A2 - the type of the second workflow argument
      A3 - the type of the third workflow argument
      Parameters:
      workflowClass - the workflow interface class
      workflowMethod - unbound method reference to the workflow method
      arg1 - first workflow argument
      arg2 - second workflow argument
      arg3 - third workflow argument
      options - workflow start options (must include workflowId)
      Returns:
      an async TemporalOperationResult with the workflow-run operation token
    • startWorkflow

      <T, A1, A2, A3, A4> TemporalOperationResult<Void> startWorkflow(Class<T> workflowClass, Functions.Proc5<T,A1,A2,A3,A4> workflowMethod, A1 arg1, A2 arg2, A3 arg3, A4 arg4, WorkflowOptions options)
      Starts a four-argument workflow with no return value.

      Example:

      
       client.startWorkflow(MyWorkflow.class, MyWorkflow::execute, arg1, arg2, arg3, arg4, options)
       
      Type Parameters:
      T - the workflow interface type
      A1 - the type of the first workflow argument
      A2 - the type of the second workflow argument
      A3 - the type of the third workflow argument
      A4 - the type of the fourth workflow argument
      Parameters:
      workflowClass - the workflow interface class
      workflowMethod - unbound method reference to the workflow method
      arg1 - first workflow argument
      arg2 - second workflow argument
      arg3 - third workflow argument
      arg4 - fourth workflow argument
      options - workflow start options (must include workflowId)
      Returns:
      an async TemporalOperationResult with the workflow-run operation token
    • startWorkflow

      <T, A1, A2, A3, A4, A5> TemporalOperationResult<Void> startWorkflow(Class<T> workflowClass, Functions.Proc6<T,A1,A2,A3,A4,A5> workflowMethod, A1 arg1, A2 arg2, A3 arg3, A4 arg4, A5 arg5, WorkflowOptions options)
      Starts a five-argument workflow with no return value.

      Example:

      
       client.startWorkflow(MyWorkflow.class, MyWorkflow::execute, arg1, arg2, arg3, arg4, arg5, options)
       
      Type Parameters:
      T - the workflow interface type
      A1 - the type of the first workflow argument
      A2 - the type of the second workflow argument
      A3 - the type of the third workflow argument
      A4 - the type of the fourth workflow argument
      A5 - the type of the fifth workflow argument
      Parameters:
      workflowClass - the workflow interface class
      workflowMethod - unbound method reference to the workflow method
      arg1 - first workflow argument
      arg2 - second workflow argument
      arg3 - third workflow argument
      arg4 - fourth workflow argument
      arg5 - fifth workflow argument
      options - workflow start options (must include workflowId)
      Returns:
      an async TemporalOperationResult with the workflow-run operation token
    • startWorkflow

      <T, A1, A2, A3, A4, A5, A6> TemporalOperationResult<Void> startWorkflow(Class<T> workflowClass, Functions.Proc7<T,A1,A2,A3,A4,A5,A6> workflowMethod, A1 arg1, A2 arg2, A3 arg3, A4 arg4, A5 arg5, A6 arg6, WorkflowOptions options)
      Starts a six-argument workflow with no return value.

      Example:

      
       client.startWorkflow(MyWorkflow.class, MyWorkflow::execute, arg1, arg2, arg3, arg4, arg5, arg6, options)
       
      Type Parameters:
      T - the workflow interface type
      A1 - the type of the first workflow argument
      A2 - the type of the second workflow argument
      A3 - the type of the third workflow argument
      A4 - the type of the fourth workflow argument
      A5 - the type of the fifth workflow argument
      A6 - the type of the sixth workflow argument
      Parameters:
      workflowClass - the workflow interface class
      workflowMethod - unbound method reference to the workflow method
      arg1 - first workflow argument
      arg2 - second workflow argument
      arg3 - third workflow argument
      arg4 - fourth workflow argument
      arg5 - fifth workflow argument
      arg6 - sixth workflow argument
      options - workflow start options (must include workflowId)
      Returns:
      an async TemporalOperationResult with the workflow-run operation token
    • startWorkflow

      <R> TemporalOperationResult<R> startWorkflow(String workflowType, Class<R> resultClass, WorkflowOptions options, Object... args)
      Starts a workflow using an untyped workflow type name.

      Example:

      
       client.startWorkflow("MyWorkflow", String.class, options, input)
       
      Type Parameters:
      R - the workflow return type
      Parameters:
      workflowType - the workflow type name string
      resultClass - the expected result class
      options - workflow start options (must include workflowId)
      args - workflow arguments
      Returns:
      an async TemporalOperationResult with the workflow-run operation token
    • startWorkflow

      <R> TemporalOperationResult<R> startWorkflow(String workflowType, Class<R> resultClass, Type resultType, WorkflowOptions options, Object... args)
      Starts a workflow using an untyped workflow type name, with both a result class and a generic Type. Use this overload when the workflow returns a generic type (e.g. List<String>) so the result can be deserialized correctly.

      Example:

      
       client.startWorkflow(
           "MyWorkflow",
           List.class,
           new TypeToken<List<String>>() {}.getType(),
           options,
           input)
       
      Type Parameters:
      R - the workflow return type
      Parameters:
      workflowType - the workflow type name string
      resultClass - the expected result class
      resultType - the expected result Type (carries generic parameters)
      options - workflow start options (must include workflowId)
      args - workflow arguments
      Returns:
      an async TemporalOperationResult with the workflow-run operation token