BPMN Error event on User Task - How to correlate to the current instance

Hi,

All of the cases about BPMN Error events I’ve seen are attaced to Service or Script Tasks (or Call activities/Subprocesses).
My case is to attach an Error event on a User Task.


While the User Task is active, I have an active websocket connection in the process to receive messages.
In a case of a business error, I want to trigger the boundary error event.
In my Java code that I catch the websocket messages, I can call the
"throw new BpmnError("task_failed_code", "User Task failed!");"
but it doesn’t trigger the boundary event. Also, what if I run many instances of that process? Which error event will be triggered?
Are boundary error events “active” when the Task in which they are assigned is also “active”?

Thanks!

Can you show your error message configuration?

You must run your throw Bpmn error throw code as part of your user task execution. Such as when the user task is completed and you execute the error code throw as a execution listener or task listener.

I think the error code is set correctly.
error_code
The point is that the Error Message is being caught by the websocket connection at any point (that means before the User Task is complete).
But, yes, your idea to have an execution listener may work.
But should I specify the Execution Listener at “start” or “end”?
Also, how can I call that Execution Listener from another Java class that handles the websocket messages?

Thanks!