Task Listener Implementation - How to interrupt execution?

I have a custom TaskListener defined as ‘Class’ in the modeler and fired on a ‘complete’ event of a user task.

The method ‘notify’ cannot throw Exceptions, so I cannot stop execution of something is not right.

In this very case I wish to check if all input parameters were correctly set and stop execution if any condition is not met.

If the taskListener is not the right place to do that, I could with an Execution Listener but I will certainly lose the task assignee and other task properties for example, unless I can query the execution to track down the latest completed task and get its properties.

Hi @Mizar01,

I think your case is identical to the example in below link

https://docs.camunda.org/manual/7.4/examples/tutorials/error-handling/#catch-exception-and-use-data-based-xor-gateway

In case you need to explicitly model errors, then see below example

https://docs.camunda.org/manual/7.4/examples/tutorials/error-handling/#bpmn-2-0-error-event

The documentation you suggested helped me to understand that technical errors should not be treated as a bpmn error.

And this is the case, sorry if I wasn’t clear: I don’t want to check if someone missed or mispelled something in the user task. I want to forbid the process to proceed further if the bpmn definition is not completed with all the desired arguments passed to delegation code.
For example i wish to throw exception from the taskListener if the task doesn’t have ‘var1’ as input variable (in the input tab of the modeler).
I have a lot of user tasks and the least I would like do is to interrupt execution if something is internally missing during java calls. I cannot apply bpmn xor gates or boundary events for every single task.

Xor gates and boundary events should be used only for meaningful bpmn flow events.

Hi @Mizar01
You can throw ProcessEngineException.

1 Like