"Inject" a generic error handling sub-process

We have several processes that make use of BpmnError in case of business exceptions. In most cases, those errors are handeled by e.g. boundary events, in other cases, the process instance terminates.

Now we are trying to build a generic solution to catch those cases and do some post-processing of the process instance.

First we tried to use a BpmnParseListener to add an Execution Listener to the ProcessDefinition. Unfortunately the listener ist not called (did we miss something?) and if it was called - how do we find out that an BpmnError was thrown?

Second idea was to build an event subprocesses in the diagram, which is triggeres by an error event and stores errorCode and errorMessage in process variables. This works fine and we can access the error information.

Now we would like to “inject” this subprocess in each of our diagrams.
We tried BpmnParseListener again, but cannot find out how to add the definition of the ModelApi using in the listener method?

void parseProcess(Element processElement, ProcessDefinitionEntity processDefinition) {
    BpmnModelInstance subProcess = Bpmn.createProcess()
            .eventSubProcess("ExceptionHandlingSubProcess")
            .startEvent("ExceptionCatched")
            .error()
            .serviceTask("ExceptionHandler").camundaDelegateExpression("${exceptionHandler}")
            .endEvent("ExceptionHandled")
            .subProcessDone().done();
    // TODO: add me!?
    }

Of course any ideas for a better solution are welcome aswell :-).

This question was asked quite recently - take a look at this post for details.

Hello Niall,

Thank’s for your quick response! ProcessInstanceModfication will help me to model the “ExceptionHandler” better.

Do you also have an idea how I could add the event subprocess to my process diagrams in a generic way? We have dozens of diagrams and I don’t want to “draw” it every time but “inject” it to the ProcessDefinition while parsing the diagram. My problem is that I don’t find a link between ModelApi and BpmnParseListener which works on Elements.

Regards
Christoph

Yes, this is also a problem I am thinking about. Actually, the CallActivity model is a good choice, but it is also because of its model characteristics that it does not seem to be suitable for building a general exception handling system

Hi @criew and @Burn,

recently I created a modeler plugin that creates connected and pre-configured BPMN elements with a drag from the palette: https://github.com/ingorichtsmeier/camunda-modeler-plugin-connected-elements

It should at the end ease the modeling part.

Hope this helps, Ingo

2 Likes

Yes it is very helpful!
The displayed support is much better than manually selecting and copying the error handling process.
I will try to complete it