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 Summary
Modifier and TypeMethodDescriptionReturns the underlyingWorkflowClientfor advanced use cases.<T,R> TemporalOperationResult <R> startWorkflow(Class<T> workflowClass, Functions.Func1<T, R> workflowMethod, WorkflowOptions options) Starts a zero-argument workflow that returns a value.<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.<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.<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.<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.<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.<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.startWorkflow(Class<T> workflowClass, Functions.Proc1<T> workflowMethod, WorkflowOptions options) Starts a zero-argument workflow with no return value.<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.<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.<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.<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.<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.<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.<R> TemporalOperationResult<R> startWorkflow(String workflowType, Class<R> resultClass, WorkflowOptions options, Object... args) Starts a workflow using an untyped workflow type name.<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 genericType.
-
Method Details
-
getWorkflowClient
WorkflowClient getWorkflowClient()Returns the underlyingWorkflowClientfor 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 typeR- the workflow return type- Parameters:
workflowClass- the workflow interface classworkflowMethod- unbound method reference to the workflow methodoptions- workflow start options (must include workflowId)- Returns:
- an async
TemporalOperationResultwith the workflow-run operation token
-
startWorkflow
<T,A1, TemporalOperationResult<R> startWorkflowR> (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 typeA1- the type of the first workflow argumentR- the workflow return type- Parameters:
workflowClass- the workflow interface classworkflowMethod- unbound method reference to the workflow methodarg1- first workflow argumentoptions- workflow start options (must include workflowId)- Returns:
- an async
TemporalOperationResultwith the workflow-run operation token
-
startWorkflow
<T,A1, TemporalOperationResult<R> startWorkflowA2, R> (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 typeA1- the type of the first workflow argumentA2- the type of the second workflow argumentR- the workflow return type- Parameters:
workflowClass- the workflow interface classworkflowMethod- unbound method reference to the workflow methodarg1- first workflow argumentarg2- second workflow argumentoptions- workflow start options (must include workflowId)- Returns:
- an async
TemporalOperationResultwith the workflow-run operation token
-
startWorkflow
<T,A1, TemporalOperationResult<R> startWorkflowA2, A3, R> (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 typeA1- the type of the first workflow argumentA2- the type of the second workflow argumentA3- the type of the third workflow argumentR- the workflow return type- Parameters:
workflowClass- the workflow interface classworkflowMethod- unbound method reference to the workflow methodarg1- first workflow argumentarg2- second workflow argumentarg3- third workflow argumentoptions- workflow start options (must include workflowId)- Returns:
- an async
TemporalOperationResultwith the workflow-run operation token
-
startWorkflow
<T,A1, TemporalOperationResult<R> startWorkflowA2, A3, A4, R> (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 typeA1- the type of the first workflow argumentA2- the type of the second workflow argumentA3- the type of the third workflow argumentA4- the type of the fourth workflow argumentR- the workflow return type- Parameters:
workflowClass- the workflow interface classworkflowMethod- unbound method reference to the workflow methodarg1- first workflow argumentarg2- second workflow argumentarg3- third workflow argumentarg4- fourth workflow argumentoptions- workflow start options (must include workflowId)- Returns:
- an async
TemporalOperationResultwith the workflow-run operation token
-
startWorkflow
<T,A1, TemporalOperationResult<R> startWorkflowA2, A3, A4, A5, R> (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 typeA1- the type of the first workflow argumentA2- the type of the second workflow argumentA3- the type of the third workflow argumentA4- the type of the fourth workflow argumentA5- the type of the fifth workflow argumentR- the workflow return type- Parameters:
workflowClass- the workflow interface classworkflowMethod- unbound method reference to the workflow methodarg1- first workflow argumentarg2- second workflow argumentarg3- third workflow argumentarg4- fourth workflow argumentarg5- fifth workflow argumentoptions- workflow start options (must include workflowId)- Returns:
- an async
TemporalOperationResultwith the workflow-run operation token
-
startWorkflow
<T,A1, TemporalOperationResult<R> startWorkflowA2, A3, A4, A5, A6, R> (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 typeA1- the type of the first workflow argumentA2- the type of the second workflow argumentA3- the type of the third workflow argumentA4- the type of the fourth workflow argumentA5- the type of the fifth workflow argumentA6- the type of the sixth workflow argumentR- the workflow return type- Parameters:
workflowClass- the workflow interface classworkflowMethod- unbound method reference to the workflow methodarg1- first workflow argumentarg2- second workflow argumentarg3- third workflow argumentarg4- fourth workflow argumentarg5- fifth workflow argumentarg6- sixth workflow argumentoptions- workflow start options (must include workflowId)- Returns:
- an async
TemporalOperationResultwith 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 classworkflowMethod- unbound method reference to the workflow methodoptions- workflow start options (must include workflowId)- Returns:
- an async
TemporalOperationResultwith 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 typeA1- the type of the first workflow argument- Parameters:
workflowClass- the workflow interface classworkflowMethod- unbound method reference to the workflow methodarg1- first workflow argumentoptions- workflow start options (must include workflowId)- Returns:
- an async
TemporalOperationResultwith the workflow-run operation token
-
startWorkflow
<T,A1, TemporalOperationResult<Void> startWorkflowA2> (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 typeA1- the type of the first workflow argumentA2- the type of the second workflow argument- Parameters:
workflowClass- the workflow interface classworkflowMethod- unbound method reference to the workflow methodarg1- first workflow argumentarg2- second workflow argumentoptions- workflow start options (must include workflowId)- Returns:
- an async
TemporalOperationResultwith the workflow-run operation token
-
startWorkflow
<T,A1, TemporalOperationResult<Void> startWorkflowA2, A3> (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 typeA1- the type of the first workflow argumentA2- the type of the second workflow argumentA3- the type of the third workflow argument- Parameters:
workflowClass- the workflow interface classworkflowMethod- unbound method reference to the workflow methodarg1- first workflow argumentarg2- second workflow argumentarg3- third workflow argumentoptions- workflow start options (must include workflowId)- Returns:
- an async
TemporalOperationResultwith the workflow-run operation token
-
startWorkflow
<T,A1, TemporalOperationResult<Void> startWorkflowA2, A3, A4> (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 typeA1- the type of the first workflow argumentA2- the type of the second workflow argumentA3- the type of the third workflow argumentA4- the type of the fourth workflow argument- Parameters:
workflowClass- the workflow interface classworkflowMethod- unbound method reference to the workflow methodarg1- first workflow argumentarg2- second workflow argumentarg3- third workflow argumentarg4- fourth workflow argumentoptions- workflow start options (must include workflowId)- Returns:
- an async
TemporalOperationResultwith the workflow-run operation token
-
startWorkflow
<T,A1, TemporalOperationResult<Void> startWorkflowA2, A3, A4, A5> (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 typeA1- the type of the first workflow argumentA2- the type of the second workflow argumentA3- the type of the third workflow argumentA4- the type of the fourth workflow argumentA5- the type of the fifth workflow argument- Parameters:
workflowClass- the workflow interface classworkflowMethod- unbound method reference to the workflow methodarg1- first workflow argumentarg2- second workflow argumentarg3- third workflow argumentarg4- fourth workflow argumentarg5- fifth workflow argumentoptions- workflow start options (must include workflowId)- Returns:
- an async
TemporalOperationResultwith the workflow-run operation token
-
startWorkflow
<T,A1, TemporalOperationResult<Void> startWorkflowA2, A3, A4, A5, A6> (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 typeA1- the type of the first workflow argumentA2- the type of the second workflow argumentA3- the type of the third workflow argumentA4- the type of the fourth workflow argumentA5- the type of the fifth workflow argumentA6- the type of the sixth workflow argument- Parameters:
workflowClass- the workflow interface classworkflowMethod- unbound method reference to the workflow methodarg1- first workflow argumentarg2- second workflow argumentarg3- third workflow argumentarg4- fourth workflow argumentarg5- fifth workflow argumentarg6- sixth workflow argumentoptions- workflow start options (must include workflowId)- Returns:
- an async
TemporalOperationResultwith 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 stringresultClass- the expected result classoptions- workflow start options (must include workflowId)args- workflow arguments- Returns:
- an async
TemporalOperationResultwith 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 genericType. 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 stringresultClass- the expected result classresultType- the expected resultType(carries generic parameters)options- workflow start options (must include workflowId)args- workflow arguments- Returns:
- an async
TemporalOperationResultwith the workflow-run operation token
-