Get DelegateExecution from RuntimeService

From BPMN Error event on User Task - How to correlate to the current instance - #3 by kontrag I understand that you would like to throw a BPMN error from such a listener. @StephenOTT’s idea in this thread is as follows:

  1. Your websocket handler class detects an error condition
  2. Your class completes the task via TaskService#completeTask providing a process variable raiseError
  3. You have an execution listener on the activity’s end event that throws BpmnError whenever it sees the raiseError variable
  4. The process engine triggers the error boundary event

That way, the process engine calls the execution listener triggered via task completion. There is no way to tell the process engine to invoke a listener outside of process instance execution context, so what you ask for in the original post is not possible.

All that said, I believe the proposed solution does not work due to the following missing feature: https://app.camunda.com/jira/browse/CAM-5399. You could work around that by introducing a script or service task after the user task and throwing and catching the BpmnError there as follows:

Of course this means you will have to change your process model because of this rather technical concern.

Cheers,
Thorben

1 Like