My second question of the day is “How to clean up”.
I know there is TTL, but “my goal” is to be more specific in what “I want to murder…”. Specifically “something, that meets some criteria of search”.
For this I’m thinking of a scheduler, but I remember “Camunda 7 Spring boot” has its own mechanics and schedulers
package org.camunda.bpm.engine.management;
/**
* @author Daniel Meyer
*
*/
public class Metrics {
...
/**
* Number of instances removed by history cleanup.
*/
public static final String HISTORY_CLEANUP_REMOVED_PROCESS_INSTANCES = "history-cleanup-removed-process-instances";
public static final String HISTORY_CLEANUP_REMOVED_CASE_INSTANCES = "history-cleanup-removed-case-instances";
public static final String HISTORY_CLEANUP_REMOVED_DECISION_INSTANCES = "history-cleanup-removed-decision-instances";
public static final String HISTORY_CLEANUP_REMOVED_BATCH_OPERATIONS = "history-cleanup-removed-batch-operations";
public static final String HISTORY_CLEANUP_REMOVED_TASK_METRICS = "history-cleanup-removed-task-metrics";
So I am trying to find a “the way” to do things right.
@GotnOGuts sorry, saw you on some of the previous discussions on this topic, so it would be nice to hear you here as well
TTL settings will remove only completed process instances, what is your intent? delete the history or adhoc deletes?
If you want to delete historic process instances on interval then you can use different properties at engine level to set up a history clean up strategy here Process Engine Configuration | docs.camunda.org
If you want to delete running process instance then you may have to use process instance delete with processinstanceQuery delete rootProcessInstances Delete Async (POST) | docs.camunda.org
You would need to model that explicitly.
Move your process into a subprocess, and put an interrupting boundary timer on it. Then on a per-process basis, there would be a time to complete the process.
This really isn’t clean, but it’s probably the best answer.
Since this is C7, you could possibly do some creative work (create a process that queries the DB looking for processes that have been running for a long time, and then pass that to a “cancel process” REST endpoint), but that introduces other issues.
I want to filter out instances, which were basically abandoned - last user interaction happened more than N days.
I already have the runtime and history service providing me with the data I need. And currently going the general solution road of @Scheduled to do my bidding.
This would be a good solution actually, but has one small drawback - the bpmn is made by people, who are just starting exploring the topic of making models (practices, tools, solutions are still the things, which are still have a long way to go). In other words… it’s a chaotic mess of (I would go for) up to 100 tasks. So, even if it was possible to wrap this, I would stay away from this approach for the time being. But the approach is quite better (and yes, I do understand that it’s a bit not up to the challenge depending on my requirements).
This is what I’m going for at the time being. Just as a @Scheduled.