Listeners

It is possible to add listeners to almost every BPMN element. These listeners can execute custom logic when the element is in a certain state. Unlike Delegates, a listener is not visible on the BPMN diagram. It is hidden from the users. Some examples of elements to which you can add listeners:

  • take: A sequence flow is traversed.
  • create: A user task is created, meaning the task is initiated.
  • start: A service task starts its execution.

There are two different types of listeners:

  • execution listeners: A generic listener that you can add to almost every element, for example start events, service tasks, user tasks or sequence flows. API v1 execution listeners are part of the com.collibra.dgc.core.workflow.activiti.executionlistener Java Core API package.
  • task listeners: A listener you can only add to and that only works within a user task. API v1 execution listeners are part of the com.collibra.dgc.core.workflow.activiti.tasklistener Java Core API package.

API v2 listeners belong to the com.collibra.dgc.workflow.api.listener Java Workflow API package.

Deprecated Java Core API v1 listeners will not be available in the next major release. Use Java Workflow API v2 listeners where available or script tasks to replace the functionality of v1 listeners. See Alternatives to API v1 listeners for examples.

Similar to delegates, you can also construct your own listener on the fly that executes one single expression. However, it is not possible to have a return value.

This section describes the packaged listeners. Most listeners are used in the packaged workflows.