I have a workflow called orderfullfilentworkflow. I have one instance of the workflow running with id
orderfullfilentworkflow-1. I need to find the status of the workflow by that id in java.
It would totally helpful if I can get some java snippet around the same to get the status of the workflow by id.
Hello @kambalavijay
Using the java-sdk you can get with DescribeWorkflowExecution,
see an example here
// Create the DescribeWorkflowExecutionRequest through which we can query our client for our
// search queries
DescribeWorkflowExecutionRequest request =
DescribeWorkflowExecutionRequest.newBuilder()
.setNamespace(client.getOptions().getNamespace())
.setExecution(execution)
.build();
try {
// Get the DescribeWorkflowExecutionResponse from our service
DescribeWorkflowExecutionResponse resp =
service.blockingStub().describeWorkflowExecution(request);
// get all search attributes
SearchAttributes searchAttributes = resp.getWorkflowExecutionInfo().getSearchAttributes();
// Get the specific value of a keyword from the payload.
// In this case it is the "CustomKeywordField" with the value of "keys"
// You can update the code to extract other defined search attribute as well
String keyword = getKeywordFromSearchAttribute(searchAttributes);
// Print the value of the "CustomKeywordField" field
System.out.printf("In workflow we get CustomKeywordField is: %s\n", keyword);
and then, from the response,
resp.getWorkflowExecutionInfo().getStatus()
Note that if you can set both, workflowId and runId. If you set only the workflowId DescribeWorkflowExecution will return the last execution