Interupting existing flow by invoking new flow with same corelation id

I have one create flow running and some service tasks are completed in that and need to interupt that in between and start new flow to rollback that existing completed service tasks in that running flow. But but i need to keep the proceess id same. So how can i invoke that flow.

sample BPMN.bpmn (15.2 KB)

Hello my friend!

I believe you can create another process that will have all the logic to reverse your tasks already done, and use the RuntimeService instance modification API.

createProcessInstanceModification(processInstanceId: String)

Follow the documentation link.

https://docs.camunda.org/javadoc/camunda-bpm-platform/7.18/org/camunda/bpm/engine/RuntimeService.html#createProcessInstanceModification(java.lang.String)

I hope this helps!

Regards.
William Robert Alves