conductor icon indicating copy to clipboard operation
conductor copied to clipboard

Terminate workflow by correlationId

Open manan164 opened this issue 6 years ago • 4 comments

Hi all, We have several use cases like we start the workflow with some correlation Id. We don't store the workflow Ids. They are independent workflows. On certain events, we are terminating by correlationId we have used to start a workflow. We have common logic to form correlationId so we don't need to store that also. Will it be a useful contribution? @apanicker-nflx @kishorebanala

manan164 avatar Mar 20 '20 19:03 manan164

@manan164 Given that this API - GET /workflow/running/{name}/correlated/{correlationId}?includeClosed=true|false&includeTasks=true|false exists, you should be able to get the list of all workflows for a given correlation id. You can then iterate on this list to terminate the workflows or use the bulk api to terminate all of these workflows.

apanicker-nflx avatar Mar 31 '20 00:03 apanicker-nflx

@apanicker-nflx Don't we have any API which will give all WFs based on only correlationId? In the above API it needs name too too. What is the purpose of name here ? Ask is to fetch all completed WFs with a given correlationId and then remove them all using remove API. Also there is no bulk API for delete too ?

techyragu avatar Feb 15 '21 05:02 techyragu

@techyragu Since the correlationId is an indexed field, you could use the GET /workflow/search API to search for all workflows given just the correlation id. You could combine the query for correlationId with the status to further filter the search.

There is no bulk delete API currently supported, but we would welcome a PR for the same :)

apanicker-nflx avatar Feb 16 '21 00:02 apanicker-nflx

@apanicker-nflx To begin with I tried with existing bulk api to terminate WFs, but it did not seem to work. WF remain in RUNNING status. Do you have any working example for existing WF API

curl -X POST --header 'Content-Type: application/json' --header 'Accept: application/json' 'http://172.17.55.27:8080/api/workflow/bulk/terminate' -d '
{
"workflowIds": ["1c631a5e-6be1-401e-a1bf-36cd40da58e1"],
"reason": "Internal error"
}
'```

techyragu avatar Feb 16 '21 21:02 techyragu