How to remove an execution data from camunda using workflows

Viewed 566

I have a bpmn process that once starts and continues its execution forever based on the Timer cycle event. There is no end event for it. I had recently done few changes with the workflow and made a redeployment to camunda. Since the existing processes are already running I need an option to stop it which I am finding difficult to do through workflow. How can I stop existing execution if a new workflow started its execution? Can we achieve that using workflow itself? REST / Java coding cannot be done to achieve this.

I have another question regarding an order by query in camunda. From the above scenario, i ended up seeing quite a few similar variables in variable table. How can i get the latest variable out of it? orderByActivityInstanceId is the only option i saw, which i feel is not reliable.

3 Answers

You can use other events (conditional, message or signal) to react to the situation in which you want to stop the looping process. You can for instance add an event-based sub process with a interrupting message start event to your process model.

enter image description here

To your second point: https://docs.camunda.org/manual/7.15/reference/rest/history/activity-instance/get-activity-instance-query/

sortBy Sort the results by a given criterion. Valid values are activityInstanceId, instanceId, executionId, activityId, activityName, activityType, startTime, endTime, duration, definitionId, occurrence and tenantId. Must be used in conjunction with the sortOrder parameter.

https://docs.camunda.org/manual/7.15/reference/rest/variable-instance/get/ is another option

To stop all the active process instances in Camunda, you can do this by calling a Camunda REST API or by Java Coding.

Using REST API

Activate/Suspend Process Instance By Id

Using Java

Suspend Process Instances

If you would like to suspend all process instances of a given process definition, you can use the method suspendProcessDefinitionById(...) of theRepositoryService and specify the suspendProcessInstances option.

Thanks a lot, i appreciate your response @amine & @rob. I got it resolved using a signal event. Every time when a new process is deployed it triggers a signal event that will stop the recursion.

To sort the data there are options within camunda. But I had done it differently. If there is more than one variable, I fetch them using versionTag from the process definition table.

Related