8

As I have read:

In general, the task listener event cycle is contained between execution listener events:

ExecutionListener#start
TaskListener#create
TaskListener#{assignment}*
TaskListener#{complete, delete}
ExecutionListener#end

see complete list at Camunda BPMN - Task listener vs Execution listeners

But now I have this question: what is the difference between ExecutionListener#start and TaskListener#create, or as I noticed the create event has started after start event started, which business should I set in the start event and which one should I set in the create event? Or are there any problems if I put all of my business in the start event?

Community
  • 1
  • 1
AKZ
  • 856
  • 2
  • 12
  • 30

1 Answers1

3

I think the important difference to remember is that the ExecutionListener is available for all elements and allows access to the DelegateExecution, while the TaskListener only applies to tasks (bpmn and cmmn) and gives you access to the DelegateTask.

The DelegateTask is important for all task-lifecycle operations, like setting due date, assigning candidate groups, ... you just cannot do this with the DelegateExecution.

So in general, we use ExecutionListeners on events and gateways, JavaDelegates on ServiceTasks and TaskListeners on UserTasks.

Jan Galinski
  • 11,768
  • 8
  • 54
  • 77
  • Can you explain the difference between Delegates and Listeners? – Fjordo May 19 '21 at 10:53
  • 1
    Delegates are available only for implementing a ServiceTask (plus, then they are required). Listeners are available on every bpmn element and optional. – Jan Galinski May 20 '21 at 15:56
  • yes, but you can use both Java Delegates and Listeners in UserTasks. Why? – Fjordo May 21 '21 at 07:31
  • User Tasks do not accept delegates ... maybe you confuse TaskListeners and ExecutionListeners? ExecutionListeners are hooks that can be used on every element ... TaskListeners provide additional hooks only available on user tasks, for example for task assignment. – Jan Galinski May 21 '21 at 09:18
  • Maybe it is better to lead an open discussion in the official Camunda forum than in this comment list, feel free to answer there (forum.camunda.org) and mention me (same user name) – Jan Galinski May 21 '21 at 09:20
  • 1
    sorry, my confusion. Thank for the help – Fjordo May 21 '21 at 14:50