How is execution listener implemented

Hi all,
I had a technical question. I know that execution listener is an extension element in Camunda, and is not a standard BPMN element. I wonder how is it implemented? I mean it is anyway implemented using some standard BPMN elements. Is it implemented by a service task, which is put for example at the beginning or at the end of another element?

Thanks in advance

Hi @NSh,

all Camunda extension use the extension points offered in the BPMN specification.

For a task listener, the XML of the diagram looks like this:

    <bpmn2:userTask id="UserTask_1" name="do something" camunda:formKey="embedded:app:forms/do.html" camunda:assignee="demo">
      <bpmn2:extensionElements>
        <camunda:taskListener class="org.camunda.bpm.quickstart.TaskAssignmentListener" event="assignment" />
      </bpmn2:extensionElements>
      <bpmn2:incoming>SequenceFlow_1</bpmn2:incoming>
      <bpmn2:outgoing>SequenceFlow_5</bpmn2:outgoing>
    </bpmn2:userTask>

The camunda element is included in the extensionElements element.

The camunda elements and attributes have their namespace announced in the XML as xmlns:camunda:

<bpmn2:definitions xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:camunda="http://camunda.org/schema/1.0/bpmn" xmlns:bpmn2="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" ...

Hope this helps, Ingo

1 Like

Hi @Ingo_Richtsmeier.
Thanks for your quick reply.
I actually asked it because I want to know how complex an execution listener is. I want to add some crosscutting behavior just before another task, and I wonder whether an execution listener is preferred to adding for example a service task?

Kind regards

Hi @NSh,

An execution listener is always information hiding, as you cannot see them in the process diagram.

On the other hand, if you have to add the service task for crosscutting behavior before each task, then an execution listener is useful to focus on the business requirements of the process.

It depends …

Hope this helps, Ingo

1 Like

Hi Ingo,
Thanks. Yes as you mentioned execution listener hides the information and can be preferred to focus on the business. But my observation was that it is a little slower than internal service tasks. And that was why I wanted to know how an execution listener is implemented.

Kind regards

Hi @NSh,

I don’t know all the details of the implementation, but it could only be a few method calls slower, and it should be hard to measure.

As its open source, you check the implementation by yourself and start here:

Hope this helps, Ingo

1 Like

Thanks a lot @Ingo_Richtsmeier.