I've been using Camunda BPMN 2.0 for one of my workflow applications. In one of my service tasks, I created an execution listener at the start event and a task listener at the create event. I'm not sure whether it's proper to assign these simultaneously at the start event. If it's correct, which one of them will be getting executed first - Execution listener or Task Listener, at start or create event, respectively ?
Asked
Active
Viewed 2.3k times
14
-
1Could you please show your code? What did you try? – abarisone Apr 08 '15 at 05:54
-
@abarisone I assigned the listeners directly to the service tasks in BPMN diagram via Eclipse. – Ramdas Nair Apr 08 '15 at 05:57
1 Answers
20
Task listeners can only be used with user tasks, since they provide callbacks when task (i.e. the task a human has to perform) state changes, cf http://docs.camunda.org/latest/guides/user-guide/#process-engine-delegation-code-task-listener
Assuming you have a user task like
<userTask id="task1" name="My task" >
<extensionElements>
<camunda:executionListener event="start" class="com.example.MyExecutionListener" />
<camunda:taskListener event="create" class="com.example.MyTaskListener" />
</extensionElements>
</userTask>
When the user task is executed
- The execution listener is called
- The task listener is called
In general, the task listener event cycle is contained between execution listener events start
and end
. So the cycle when a user task is executed is:
- ExecutionListener#start
- TaskListener#create
- TaskListener#{assignment}*
- TaskListener#{complete, delete}
- ExecutionListener#end

thorben
- 1,577
- 8
- 14
-
I added a TaskListener#Create first and only then added the ExecutionListener#start by setting it in the properties of my user task in the bpmn diagram. I found that the flow is going directly into taskListener rather that executionListener. So do I have to change the order in my XML Current order:
-
The order of the elements in the XML should not be relevant and in a test case, I was not able to reproduce your problem. I suggest you raise this as an issue in the Camunda forums and provide a test case: https://groups.google.com/forum/#!forum/camunda-bpm-users – thorben Apr 08 '15 at 11:04
-
Thank you @thorben, As it turned out, the issue was that I didn't give the complete package name in the class attribute of the execution Listener. One other question I'd like to ask: if I use two task listeners with event create, will both get invoked? – Ramdas Nair Apr 08 '15 at 12:54
-
1Yes, both are invoked. There is no guaranteed order though. If that is important, you might consider implementing a composite TaskListener. – thorben Apr 08 '15 at 15:43