To reduce the load on the db as much as possible, I would like to delete the history of the process instance from the database immediately after the process ends, for both the cases either the process has successfully ended or is closed by an incident handler.
I know one way to delete the history for a sync process is:
historyService.deleteHistoricProcessInstance(execution.getProcessInstanceId());
In case the process instance is executing in async mode, the above wouldn’t work when we get the control either in ExecutionListener(for end event) or IncidentHandler.
Process instance is still running, cannot delete historic process instance
I tried the strategy suggested by @Yana in this discussion. The two issues with it are:
- It didn’t delete the process instance history which were closed by an IncidentHandler.
- It doesn’t look like an optimal way to delete the history when we know the exact process instance id for which we want to clean up.