Batch delete of running process instances

Hello,

I want to bulk delete running workflow instances but the

runtimeService.bulkDeleteProcessInstances(ids,
    "Definition " + workflowDefinitionId + " is deleted");

deletes them one by one if I understood correctly.

Can I create my own BatchBuilder? or there is some other way?

Use historyService.createHistoricProcessInstanceQuery()…. .deleteParallelUsingBatch….

I want to keep the historic process instances and remove only the runtime ones.

We use this technique for implementing “cancel” for running workflow instances

Fine, use the same approach as for HistoricProcessInstances.

Why do you need to batch delete running process instances?

Regards

Martin

By using the same approach as HistoricProcessInstances, you mean to implement something like deleteParallelUsingBatch?

There might be a lot of process instances, so I want to use batch for faster execution.

The logic is that I want to delete a specific version of a process definition and cancel all running instances of it. Is maybe other way to do that?

Yes,

split the query into batch parts, to keep transaction small. Each batch part will be responsible for deleting specific part of the query.