Catch DMN technical errors

Hello,

I have a BPMN process that runs what I call (in my business logic) a simulation.
I need to keep a status for the started simulations in my DB (‘running’, ‘success’, ‘error’, ‘waiting for client response’, ‘treating client response’, …).

If a technical error occurs during the BPMN execution (e.g. a null pointer exception), I need to set the simulation status to ‘error’ and save a localized message of the exception in DB to display it to users in my frontend app.

The problem is that my BPMN contains decision evaluations (DMN). In case a technical error occurs in the DMN, I don’t know how to catch this exception to make this little extra work (i.e. change simulation status and save exception message) and re-throw to let Camunda catch the exception and stop the workflow.

In Java delegate service tasks, I was able to do this by adding try{…} catch{/* save status and rethrow*/} in the delegate body.
But, how could I do the same with DMN?

Here is a simplified example of what I want the BPMN to do:

Is there a global handler method that is called when exceptions occur in DMN?
OR, is there some other approach of doing things like that?

(Note: I’m using Camunda 7 with Spring boot)

Thanks in advance for your help

Hello @sepaquay ,

in theory, it would be possible to calculate your simulation status from the process-engine api.

In the History API, each process instance has a state. From there, you will find out whether a process instance is running or ended, which would mean that your simulation is running or successful.

Next, each running instance can be found in the runtime data. A running instance can have incidents, which would mean that your simulation is in an error state.

If you really want to represent the state of your simulation in another database, you could implement a Custom History Event Handler that would set a running state when a process instance is created, a success state when a process instance is completed, transition to error if and incident is created and transition to running when the incident is resolved.

I hope this helps

Jonathan

1 Like

Hello @jonathan.lukas,

Thanks for your response.

I was incomplete in the problem description regarding to the different statuses. Actually, the process is way bigger than the one I provided, and I set other simulation statuses during the execution of the process like ‘waiting for client response’, ‘treating client response’, and so on… that are more business-related and can’t be mapped to a process-engine state.

Sébastien

Hello @sepaquay ,

in this case, both ways are still possible:

A status can for example also be mapped to an activityId which is the id of a task.

Or, the history event handler does the same.

Jonathan