Terminate long running process instances

We need to terminate long-running process instances, for example, if the process instances are active more than 30 days then all those instances are marked as long-running instances and need to be terminated(delete from runtime tables ACT_RU_* only).

Is there possibilities to trigger this action by Job Executor or we have to configure some listener by adding timer boundary event to all tasks to trigger the listener which will terminate the process instances?

Can we terminate the running process instances by using due-date or follow-up date of user task at any step?

Please suggest me the best option.

You can model that using an interrupting event sub process.

1 Like

Thanks for your reply.

The sub process not linked with any of the above user/message tasks. How it considered as same processdefinition?

This interrupting event sub process will applicable for all usertask/message task which depicted in this diagram? Will it terminate the process instance if the execution was parked at any of these workflow tasks more than specified duration?

The process i modeled will terminate 30 days after the process starts - if there is a token on any Activity. This will work for each instance that starts.

I’m using the Event Sub process which does not connect to other symbols, you can read about it here: https://docs.camunda.org/manual/latest/reference/bpmn20/subprocesses/event-subprocess/

1 Like

Thanks @Niall, i will give a try :slight_smile:


In this example, the total process expected to be completed in 30 days. Each step defined in the workflow should not take more than 10 days to approve by the user. Suppose if the user fails to approve at any step the process instance should be terminated.

Let’s say Step 1(completed in 5 days) & Step 2(completed in 5 days) completed by the user within given time period, so now the Step 3 task is available for the user. Even if the whole process has 30 days of time, but step 1 & step 2 completed in (5+5) 10 days. So remaining time is 20 days. But step 3 can utilize the allocated 10 days only. In this case, if user not able to complete the task within 10 days, the process instance should be terminated.

So how to configure event subprocess at each step level to terminate process instance after exceeding time limit?

For the scenario you mentioned an event sub process would not be a good solution. If you want each individual task to have it’s own time limit. Use an interrupting boundary event.

1 Like

Do we need to add listener to interrupting boundary event, which has piece of code to terminate the process instance?
the interrupting boundary event will automatically move to end state after certain period of time?

No code required, you just need to add a duration.
If you want to learn a little more about these slightly more advanced constructs check out this tutorial video. It will also explain how the timer boundary event works.


Hi @Niall,

From the model you proposed, how to pass process variable to eventSubprocess timerevent to set Date value dynamically?

I tried setting Duration=“PT30M”, its working. If i set Date=${triggerDate} its giving exception like unresolved property.