Package io.iworkflow.core
Class Client
- java.lang.Object
-
- io.iworkflow.core.Client
-
public class Client extends java.lang.Object
-
-
Constructor Summary
Constructors Constructor Description Client(Registry registry, ClientOptions clientOptions)return a full featured client.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description WorkflowInfodescribeWorkflow(java.lang.String workflowId)Describe a workflow to get its info.WorkflowInfodescribeWorkflow(java.lang.String workflowId, java.lang.String workflowRunId)Describe a workflow to get its info.java.util.Map<java.lang.String,java.lang.Object>getAllDataAttributes(java.lang.Class<? extends ObjectWorkflow> workflowClass, java.lang.String workflowId)Get all the data attributes of a workflowjava.util.Map<java.lang.String,java.lang.Object>getAllDataAttributes(java.lang.Class<? extends ObjectWorkflow> workflowClass, java.lang.String workflowId, java.lang.String workflowRunId)Get all the data attributes of a workflowjava.util.Map<java.lang.String,java.lang.Object>getAllSearchAttributes(java.lang.Class<? extends ObjectWorkflow> workflowClass, java.lang.String workflowId)Get all the search attributes of a workflowjava.util.Map<java.lang.String,java.lang.Object>getAllSearchAttributes(java.lang.Class<? extends ObjectWorkflow> workflowClass, java.lang.String workflowId, java.lang.String workflowRunId)Get all the search attributes of a workflowjava.util.List<StateCompletionOutput>getComplexWorkflowResultWithWait(java.lang.String workflowId)java.util.List<StateCompletionOutput>getComplexWorkflowResultWithWait(java.lang.String workflowId, java.lang.String workflowRunId)In some cases, a workflow may have more than one completion states<T> TgetSimpleWorkflowResultWithWait(java.lang.Class<T> valueClass, java.lang.String workflowId)<T> TgetSimpleWorkflowResultWithWait(java.lang.Class<T> valueClass, java.lang.String workflowId, java.lang.String workflowRunId)For most cases, a workflow only has one result(one completion state) Use this API to retrieve the output of the stateUnregisteredClientgetUnregisteredClient()java.util.Map<java.lang.String,java.lang.Object>getWorkflowDataAttributes(java.lang.Class<? extends ObjectWorkflow> workflowClass, java.lang.String workflowId, java.lang.String workflowRunId, java.util.List<java.lang.String> keys)Get specified data attributes (by keys) of a workflowjava.util.Map<java.lang.String,java.lang.Object>getWorkflowDataAttributes(java.lang.Class<? extends ObjectWorkflow> workflowClass, java.lang.String workflowId, java.util.List<java.lang.String> keys)Get specified data attributes (by keys) of a workflowjava.util.Map<java.lang.String,java.lang.Object>getWorkflowSearchAttributes(java.lang.Class<? extends ObjectWorkflow> workflowClass, java.lang.String workflowId, java.lang.String workflowRunId, java.util.List<java.lang.String> attributeKeys)Get specified search attributes (by attributeKeys) of a workflowjava.util.Map<java.lang.String,java.lang.Object>getWorkflowSearchAttributes(java.lang.Class<? extends ObjectWorkflow> workflowClass, java.lang.String workflowId, java.util.List<java.lang.String> attributeKeys)Get specified search attributes (by attributeKeys) of a workflow<O> OinvokeRPC(RpcDefinitions.RpcFunc0<O> rpcStubMethod)invoking the RPC through RPC stub<I,O>
OinvokeRPC(RpcDefinitions.RpcFunc1<I,O> rpcStubMethod, I input)invoking the RPC through RPC stubvoidinvokeRPC(RpcDefinitions.RpcProc0 rpcStubMethod)invoking the RPC through RPC stub<I> voidinvokeRPC(RpcDefinitions.RpcProc1<I> rpcStubMethod, I input)invoking the RPC through RPC stub<T> TnewRpcStub(java.lang.Class<T> workflowClassForRpc, java.lang.String workflowId)create a new stub for invoking RPC<T> TnewRpcStub(java.lang.Class<T> workflowClassForRpc, java.lang.String workflowId, java.lang.String workflowRunId)create a new stub for invoking RPCjava.lang.StringresetWorkflow(java.lang.String workflowId, ResetWorkflowTypeAndOptions resetWorkflowTypeAndOptions)java.lang.StringresetWorkflow(java.lang.String workflowId, java.lang.String workflowRunId, ResetWorkflowTypeAndOptions resetWorkflowTypeAndOptions)WorkflowSearchResponsesearchWorkflow(WorkflowSearchRequest request)This search API support paginationWorkflowSearchResponsesearchWorkflow(java.lang.String query, int pageSize)This is a simplified API to search without pagination, use the other searchWorkflow API for pagination featurevoidsignalWorkflow(java.lang.Class<? extends ObjectWorkflow> workflowClass, java.lang.String workflowId, java.lang.String signalChannelName, java.lang.Object signalValue)Emit a signal message for the workflow object to receive from external sourcesvoidsignalWorkflow(java.lang.Class<? extends ObjectWorkflow> workflowClass, java.lang.String workflowId, java.lang.String workflowRunId, java.lang.String signalChannelName, java.lang.Object signalValue)Emit a signal message for the workflow object to receive from external sourcesvoidskipTimer(java.lang.String workflowId, java.lang.String workflowRunId, java.lang.Class<? extends WorkflowState> stateClass, int stateExecutionNumber, int timerCommandIndex)voidskipTimer(java.lang.String workflowId, java.lang.String workflowRunId, java.lang.Class<? extends WorkflowState> stateClass, int stateExecutionNumber, java.lang.String timerCommandId)voidskipTimer(java.lang.String workflowId, java.lang.String workflowRunId, java.lang.String workflowStateId, int stateExecutionNumber, int timerCommandIndex)voidskipTimer(java.lang.String workflowId, java.lang.String workflowRunId, java.lang.String workflowStateId, int stateExecutionNumber, java.lang.String timerCommandId)java.lang.StringstartWorkflow(java.lang.Class<? extends ObjectWorkflow> workflowClass, java.lang.String workflowId, int workflowTimeoutSeconds)startWorkflow starts a workflow executionjava.lang.StringstartWorkflow(java.lang.Class<? extends ObjectWorkflow> workflowClass, java.lang.String workflowId, int workflowTimeoutSeconds, java.lang.Object input)startWorkflow starts a workflow executionjava.lang.StringstartWorkflow(java.lang.Class<? extends ObjectWorkflow> workflowClass, java.lang.String workflowId, int workflowTimeoutSeconds, java.lang.Object input, WorkflowOptions option)startWorkflow starts a workflow executionjava.lang.StringstartWorkflow(java.lang.String wfType, java.lang.String workflowId, int workflowTimeoutSeconds, java.lang.Object input, WorkflowOptions options)startWorkflow starts a workflow executionvoidstopWorkflow(java.lang.String workflowId)Stop a workflow, this is essentially terminate the workflow gracefully The workflow status will be CANCELEDvoidstopWorkflow(java.lang.String workflowId, StopWorkflowOptions options)Stop a workflow with optionsvoidstopWorkflow(java.lang.String workflowId, java.lang.String workflowRunId, StopWorkflowOptions options)Stop a workflow with options
-
-
-
Constructor Detail
-
Client
public Client(Registry registry, ClientOptions clientOptions)
return a full featured client. If you don't have the workflow Registry, you should useUnregisteredClientinstead- Parameters:
registry- registry is required so that this client can perform some validation checks (workflow types, channel names)clientOptions- is for configuring the client
-
-
Method Detail
-
getUnregisteredClient
public UnregisteredClient getUnregisteredClient()
-
startWorkflow
public java.lang.String startWorkflow(java.lang.Class<? extends ObjectWorkflow> workflowClass, java.lang.String workflowId, int workflowTimeoutSeconds)
startWorkflow starts a workflow execution- Parameters:
workflowClass- is requiredworkflowId- is requiredworkflowTimeoutSeconds- is required- Returns:
- runId
-
startWorkflow
public java.lang.String startWorkflow(java.lang.Class<? extends ObjectWorkflow> workflowClass, java.lang.String workflowId, int workflowTimeoutSeconds, java.lang.Object input)
startWorkflow starts a workflow execution- Parameters:
workflowClass- is requiredworkflowId- is requiredworkflowTimeoutSeconds- is requiredinput- is optional, can be null- Returns:
- runId
-
startWorkflow
public java.lang.String startWorkflow(java.lang.Class<? extends ObjectWorkflow> workflowClass, java.lang.String workflowId, int workflowTimeoutSeconds, java.lang.Object input, WorkflowOptions option)
startWorkflow starts a workflow execution- Parameters:
workflowClass- is requiredworkflowId- is requiredworkflowTimeoutSeconds- is requiredinput- is optional, can be nulloption- is optional, can be null- Returns:
- runId
-
startWorkflow
public java.lang.String startWorkflow(java.lang.String wfType, java.lang.String workflowId, int workflowTimeoutSeconds, java.lang.Object input, WorkflowOptions options)startWorkflow starts a workflow execution- Parameters:
wfType- is required. It should be the same as theObjectWorkflow.getWorkflowType()workflowId- is requiredworkflowTimeoutSeconds- is requiredinput- is optional, can be nulloptions- is optional, can be null- Returns:
- runId
-
getSimpleWorkflowResultWithWait
public <T> T getSimpleWorkflowResultWithWait(java.lang.Class<T> valueClass, java.lang.String workflowId, java.lang.String workflowRunId)For most cases, a workflow only has one result(one completion state) Use this API to retrieve the output of the state- Type Parameters:
T- type of the output- Parameters:
valueClass- the type class of the outputworkflowId- the workflowIdworkflowRunId- optional runId, can be empty- Returns:
- the output result
-
getSimpleWorkflowResultWithWait
public <T> T getSimpleWorkflowResultWithWait(java.lang.Class<T> valueClass, java.lang.String workflowId)
-
getComplexWorkflowResultWithWait
public java.util.List<StateCompletionOutput> getComplexWorkflowResultWithWait(java.lang.String workflowId, java.lang.String workflowRunId)
In some cases, a workflow may have more than one completion states- Parameters:
workflowId- workflowIdworkflowRunId- workflowRunId- Returns:
- a list of the state output for completion states. User code will figure how to use ObjectEncoder to decode the output
-
getComplexWorkflowResultWithWait
public java.util.List<StateCompletionOutput> getComplexWorkflowResultWithWait(java.lang.String workflowId)
-
signalWorkflow
public void signalWorkflow(java.lang.Class<? extends ObjectWorkflow> workflowClass, java.lang.String workflowId, java.lang.String workflowRunId, java.lang.String signalChannelName, java.lang.Object signalValue)
Emit a signal message for the workflow object to receive from external sources- Parameters:
workflowClass- requiredworkflowId- requiredworkflowRunId- optional, can be emptysignalChannelName- requiredsignalValue- optional, can be null
-
signalWorkflow
public void signalWorkflow(java.lang.Class<? extends ObjectWorkflow> workflowClass, java.lang.String workflowId, java.lang.String signalChannelName, java.lang.Object signalValue)
Emit a signal message for the workflow object to receive from external sources- Parameters:
workflowClass- requiredworkflowId- requiredsignalChannelName- requiredsignalValue- optional, can be null
-
resetWorkflow
public java.lang.String resetWorkflow(java.lang.String workflowId, java.lang.String workflowRunId, ResetWorkflowTypeAndOptions resetWorkflowTypeAndOptions)- Parameters:
workflowId- requiredworkflowRunId- optional, can be emptyresetWorkflowTypeAndOptions- required, the combination parameter for reset- Returns:
- the new runId after reset
-
resetWorkflow
public java.lang.String resetWorkflow(java.lang.String workflowId, ResetWorkflowTypeAndOptions resetWorkflowTypeAndOptions)- Parameters:
workflowId- requiredresetWorkflowTypeAndOptions- required, the combination parameter for reset- Returns:
- the new runId after reset
-
stopWorkflow
public void stopWorkflow(java.lang.String workflowId, java.lang.String workflowRunId, StopWorkflowOptions options)Stop a workflow with options- Parameters:
workflowId- requiredworkflowRunId- optional, can be emptyoptions- optional, can be null. If not set, the workflow status will be CANCELED
-
stopWorkflow
public void stopWorkflow(java.lang.String workflowId, StopWorkflowOptions options)Stop a workflow with options- Parameters:
workflowId- requiredoptions- optional, can be null. If not set, the workflow status will be CANCELED
-
stopWorkflow
public void stopWorkflow(java.lang.String workflowId)
Stop a workflow, this is essentially terminate the workflow gracefully The workflow status will be CANCELED- Parameters:
workflowId- required
-
getWorkflowDataAttributes
public java.util.Map<java.lang.String,java.lang.Object> getWorkflowDataAttributes(java.lang.Class<? extends ObjectWorkflow> workflowClass, java.lang.String workflowId, java.lang.String workflowRunId, java.util.List<java.lang.String> keys)
Get specified data attributes (by keys) of a workflow- Parameters:
workflowClass- requiredworkflowId- requiredworkflowRunId- optional, can be emptykeys- required, cannot be empty or null- Returns:
- the data attributes
-
getWorkflowDataAttributes
public java.util.Map<java.lang.String,java.lang.Object> getWorkflowDataAttributes(java.lang.Class<? extends ObjectWorkflow> workflowClass, java.lang.String workflowId, java.util.List<java.lang.String> keys)
Get specified data attributes (by keys) of a workflow- Parameters:
workflowClass- requiredworkflowId- requiredkeys- required, cannot be empty or null- Returns:
- the data attributes
-
getAllDataAttributes
public java.util.Map<java.lang.String,java.lang.Object> getAllDataAttributes(java.lang.Class<? extends ObjectWorkflow> workflowClass, java.lang.String workflowId, java.lang.String workflowRunId)
Get all the data attributes of a workflow- Parameters:
workflowClass- requiredworkflowId- requiredworkflowRunId- optional, can be empty- Returns:
- the data attributes
-
getAllDataAttributes
public java.util.Map<java.lang.String,java.lang.Object> getAllDataAttributes(java.lang.Class<? extends ObjectWorkflow> workflowClass, java.lang.String workflowId)
Get all the data attributes of a workflow- Parameters:
workflowClass- requiredworkflowId- required- Returns:
- the data attributes
-
searchWorkflow
public WorkflowSearchResponse searchWorkflow(java.lang.String query, int pageSize)
This is a simplified API to search without pagination, use the other searchWorkflow API for pagination feature- Parameters:
query- the query of the search, see Cadence/Temporal search attributes docpageSize- the page size- Returns:
- the results of the search, this will only return one page of the results
-
searchWorkflow
public WorkflowSearchResponse searchWorkflow(WorkflowSearchRequest request)
This search API support pagination- Parameters:
request- the search request- Returns:
- the results of the search
-
newRpcStub
public <T> T newRpcStub(java.lang.Class<T> workflowClassForRpc, java.lang.String workflowId, java.lang.String workflowRunId)create a new stub for invoking RPC- Type Parameters:
T- the class of defining the RPCs to invoke- Parameters:
workflowClassForRpc- the class of defining the RPCs to invokeworkflowId- requiredworkflowRunId- optional, can be empty- Returns:
- the result of the RPC
-
newRpcStub
public <T> T newRpcStub(java.lang.Class<T> workflowClassForRpc, java.lang.String workflowId)create a new stub for invoking RPC- Type Parameters:
T- the class of defining the RPCs to invoke- Parameters:
workflowClassForRpc- the class of defining the RPCs to invokeworkflowId- required- Returns:
- the result of the RPC
-
invokeRPC
public <I,O> O invokeRPC(RpcDefinitions.RpcFunc1<I,O> rpcStubMethod, I input)
invoking the RPC through RPC stub- Type Parameters:
I- the input typeO- the output type- Parameters:
rpcStubMethod- the RPC method from stub created bynewRpcStub(Class, String, String)input- the input of the RPC method- Returns:
- output
-
invokeRPC
public <O> O invokeRPC(RpcDefinitions.RpcFunc0<O> rpcStubMethod)
invoking the RPC through RPC stub- Type Parameters:
O- the output type- Parameters:
rpcStubMethod- the RPC method from stub created bynewRpcStub(Class, String, String)- Returns:
- output
-
invokeRPC
public <I> void invokeRPC(RpcDefinitions.RpcProc1<I> rpcStubMethod, I input)
invoking the RPC through RPC stub- Type Parameters:
I- the input type- Parameters:
rpcStubMethod- the RPC method from stub created bynewRpcStub(Class, String, String)input- the input of the RPC method
-
invokeRPC
public void invokeRPC(RpcDefinitions.RpcProc0 rpcStubMethod)
invoking the RPC through RPC stub- Parameters:
rpcStubMethod- the RPC method from stub created bynewRpcStub(Class, String, String)
-
getWorkflowSearchAttributes
public java.util.Map<java.lang.String,java.lang.Object> getWorkflowSearchAttributes(java.lang.Class<? extends ObjectWorkflow> workflowClass, java.lang.String workflowId, java.lang.String workflowRunId, java.util.List<java.lang.String> attributeKeys)
Get specified search attributes (by attributeKeys) of a workflow- Parameters:
workflowClass- requiredworkflowId- requiredworkflowRunId- optional, can be emptyattributeKeys- required, cannot be empty or null- Returns:
- the search attributes
-
getWorkflowSearchAttributes
public java.util.Map<java.lang.String,java.lang.Object> getWorkflowSearchAttributes(java.lang.Class<? extends ObjectWorkflow> workflowClass, java.lang.String workflowId, java.util.List<java.lang.String> attributeKeys)
Get specified search attributes (by attributeKeys) of a workflow- Parameters:
workflowClass- requiredworkflowId- requiredattributeKeys- required, cannot be empty or null- Returns:
- the search attributes
-
getAllSearchAttributes
public java.util.Map<java.lang.String,java.lang.Object> getAllSearchAttributes(java.lang.Class<? extends ObjectWorkflow> workflowClass, java.lang.String workflowId, java.lang.String workflowRunId)
Get all the search attributes of a workflow- Parameters:
workflowClass- requiredworkflowId- requiredworkflowRunId- optional, can be empty- Returns:
- the search attributes
-
getAllSearchAttributes
public java.util.Map<java.lang.String,java.lang.Object> getAllSearchAttributes(java.lang.Class<? extends ObjectWorkflow> workflowClass, java.lang.String workflowId)
Get all the search attributes of a workflow- Parameters:
workflowClass- requiredworkflowId- required- Returns:
- the search attributes
-
describeWorkflow
public WorkflowInfo describeWorkflow(java.lang.String workflowId, java.lang.String workflowRunId)
Describe a workflow to get its info. If the workflow does not exist, throw the WORKFLOW_NOT_EXISTS_SUB_STATUS exception.- Parameters:
workflowId- requiredworkflowRunId- optional, can be empty- Returns:
- the workflow's info
-
describeWorkflow
public WorkflowInfo describeWorkflow(java.lang.String workflowId)
Describe a workflow to get its info. If the workflow does not exist, throw the WORKFLOW_NOT_EXISTS_SUB_STATUS exception.- Parameters:
workflowId- required- Returns:
- the workflow's info
-
skipTimer
public void skipTimer(java.lang.String workflowId, java.lang.String workflowRunId, java.lang.Class<? extends WorkflowState> stateClass, int stateExecutionNumber, java.lang.String timerCommandId)
-
skipTimer
public void skipTimer(java.lang.String workflowId, java.lang.String workflowRunId, java.lang.String workflowStateId, int stateExecutionNumber, java.lang.String timerCommandId)
-
skipTimer
public void skipTimer(java.lang.String workflowId, java.lang.String workflowRunId, java.lang.Class<? extends WorkflowState> stateClass, int stateExecutionNumber, int timerCommandIndex)
-
skipTimer
public void skipTimer(java.lang.String workflowId, java.lang.String workflowRunId, java.lang.String workflowStateId, int stateExecutionNumber, int timerCommandIndex)
-
-