cancel
Showing results for 
Search instead for 
Did you mean: 

Automatically delete a process instance on failure

izlatanov
Champ in-the-making
Champ in-the-making
Hello,

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

Details:
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.

Ivaylo
2 REPLIES 2

martin_grofcik
Confirmed Champ
Confirmed Champ
Hi Ivaylo,

It could be easily  done with Terminate End Event. Your process has to throw BpmnError which can be caught by boundary catching error event associated with the given process.

Regards
Martin

Hello Martin,

simply beautiful solution, thanks !

Ivaylo