I basically want to check if a workflow is open with the given type and workflow id, If it is open get the run id. I looked around and couldn’t find a way to do this using using WorkflowClient, the only way seems to be to use DescribeWorkflowExecution api, please let me know if i am wrong.
Using the DescribeWorkflowExecution API how do i know if the workflow is open or closed? I do see a status field, could you let me know which of these status correspond to an open workflow? Is there a helper method for the same?
I have an api that creates an upload for a feed (parent entity). All this API does it kick off a temporal workflow with the feed-id as the workflow-id and it uses the run-id returned by the workflow as upload-id and returns this back as the response of our api. The workflow is responsible for actually creating and persisting the actual upload entity to our database.
Now i have 2 additional read apis that i need to support
Get all uploads for a feed: Ideally i would have just queried our database to get this. But since the temporal workflow is the one that creates these uploads there is time gap between when i open a workflow and when the first step of the workflow executes (which creates the upload), i also need to look at temporal to get run id for an open workflow
Get upload with the given id(run id): again because of the time gap between when the temporal is kicked off and when the upload is created i need to query temporal to see if a workflow exists for this run id.
As I understand 1 can be done using DescribeWorkflowExecution, Is there a way i can query a workflow just by the run-id for use case 2
@maxim
cannot we use “ListWorkflowExecutionsRequest” with the query for getting running workflow with workflow id.
I used this quer = “WorkflowType = ‘subscription.new’ and ExecutionStatus=”
+ WorkflowExecutionStatus.WORKFLOW_EXECUTION_STATUS_RUNNING_VALUE
and I got all the running workflows and then i checked for my workflow id. But if I have many open workflows then this will be huge list and iterating over that would be costly. So i am wondering if a can query by woekflowId to get the exact workflow and if there are none I do not want to get a exception.
Yes @tihomir , when I tried with ExecutionStatus = Running, it worked but when I tried with executionStatus = 1, it returned me an empty list although I had one workflow with same ID running.
Is that using ListWorkflowExecutionsRequest?
Here is example with that shows the use with ExecutionStatus set to WorkflowExecutionStatus.WORKFLOW_EXECUTION_STATUS_RUNNING_VALUE which has value 1