Amazon Simple Workflow - Given workflowID List all executions

1.3k Views Asked by At

Workflow when started again, with the same workflowID, but it gets a different runID. Is there a way to retrieve such executions (containing different runID) of a given workflow ID?

I explored ListClosedWorkflowExecutionsRequest API, but it just lists all the workflow executions, not for a particular workflowID.

The problem I am trying to solve is: There were many workflows that failed for some reason. In restarting the process, I didn't include a correct time filter and few of them were restarted while a few got skipped. So I am trying to list all failed workflow IDs using ListClosedWorkflowExecutionsRequest. For each workflowID, fetch all executions and if latest of them is successful, skip it else restart.

I am little new to SWF, so is there a better way to accomplish the same?

1

There are 1 best solutions below

1
On BEST ANSWER

Yes, it is possible to filter by workflowId as described in How do you get the state of a WorkflowExecution if all you have is a workflowId in Amazon SWF.

The answer is on line [7] and [9] in the example, the executions() method call. For your use case though, since all you want are closed executions, you'll just alter the method call to include closed=True. So, in order to get all closed executions in the 24hours (the default):

In [7]: domain.executions(closed=True)

And for closed executions filtered by workflow id:

In [9]: domain.executions(workflow_id='my_wf_id', closed=True)

If you're not using boto.swf but an alternative library instead, refer to the API docs for what are the necessary parameters to pass to the ListClosedWorkflowExecutions API.