AnsweredAssumed Answered

Automatically delete a process instance on failure

Question asked by izlatanov on Feb 20, 2016
Latest reply on Feb 22, 2016 by izlatanov

Beginner question here: is it possible to automatically (i.e. programmatically) delete a process instance data from runtime if the process fails with exception?

we have some processes with async steps that we never rerun if they fail. We don't want them to pile up so we need to have them deleted. Our first attempt was to add an event listener for JOB_EXECUTION_FAILURE and call RuntimeService.deleteProcessInstance from there - doesn't work, no exceptions but process instance not deleted either. If the event listener does not call deleteProcessInstance immediately but schedules a Timer for say 2 minutes, process instance is deleted however this doesn't look like a clean solution, more like a workaround. Any recommendations? I found similar questions in the forum but nothing solid. Thanks.