Workflow Client API
At the moment, this API is available in Java only.
Clients can start and interact with Workflows using the Workflow Client API. Please note that Workflows in this document always refer to a Workflow Instance.
Starting a Workflow
To start a Workflow, a client first needs to get a WorkflowReference via Grainite.newWorkflow()
API. This provides the client with a Workflow ID which can then be used to start the Workflow using the WorkflowReference.start()
` ``` API which takes the Application name and Workflow Method name as parameters. All further interactions between the client and the Workflow will be via the WorkflowReference.
Once the Workflow has started, the Client can wait for the instance to complete using the WorkflowReference.waitForCompletion()
API by specifying a maximum wait duration. A “null” duration means waiting forever for an instance to complete.
Clients can start a new Workflow and wait for it to complete using the WorkflowReference.start()
API before returning from the start call.
Clients can get a reference to an existing Workflow using the Grainite.getWorkflow()
API. The WorkflowInfo can then be obtained from this reference. The WorkflowInfo
is serializable and can be persisted. It contains the Workflow application name, Workflow table name, and Workflow ID.
A previously stored WorkflowInfo
can be used by the client to obtain a WorkflowReference
at any time.
Workflow Status and Result
A Workflow status can be in one of these states.
NOTSTARTED
RUNNING
SUCCESS
FAILURE
Workflow Status and the Result can be fetched using the WorkflowReference.fetchStatus()
API.
Workflow progress log
A Workflow log can be fetched using the WorkflowReference.fetchLog()
API.
Invoke Query and Signal methods
Clients can invoke Query and Signal methods provided by a Workflow. The invocation is synchronous, and the client invocation returns after the method have been executed. Queries and signals take a Value argument and return a Value result.
For Queries, Clients can use the WorkflowReference.query()
API.
For Signals, Clients can use the WorkflowReference.signal()
API
Stop (Kill) a workflow
A client can stop a Workflow from executing by using the WorkflowReference.kill(
) API. This will immediately terminate the Workflow and compensating transactions will not be executed. When the API call returns, the Workflow status will be 'FAILURE'. Trying to stop a Workflow that has already been completed is considered a “nop”.
Last updated