Terminate running process instances after some specific period of time

We need to terminate running process instances after some specific interval of time, for example, if the process instances are active for more than 14 days then we need to terminate(delete from runtime tables ACT_RU_* only).

There is a way by adding interrupt events to clean this data up. But we have many workflows/Modeler defined so we don’t want to make the same changes in multiples workflows. We do have such an option for history table clean-up by adding the below properties and defining the same in the model.

camunda.bpm:
generic-properties:
properties:
historyCleanupBatchWindowStartTime: “01:00”
historyCleanupBatchWindowEndTime: “03:00”
historyCleanupStrategy: removalTimeBased
historyCleanupBatchSize: 200

Are there any possibilities to clean the long-running instances by adding some config properties in the properties/YAML file for running instances?

Please suggest to me the best option.

Hi @Tushar_Kapadnis,

You can try to model a separate process definition to do this job.

The process definition can start with a timer start event (configured to be started on a daily basis for example) and includes service task(s) to query unfinished process instances which started before “DATE” (a calculated date relative to the start date) then delete them.

Kindly find below required Rest APIs to do the job (Java APIs can be used)

1 Like