This documentation is for WSO2 Enterprise Integrator version 6.2.0 . View documentation for the latest release in the 6.x.x family and the latest release in the 7.x.x family.

All docs This doc
Skip to end of metadata
Go to start of metadata

The Activiti API provides extension points that can be used as custom implementations that you can trigger where necessary. Task listener is one such extension point.

A task listener can be used when you need to trigger a custom implementation upon the occurrence of a particular task.

To create a task listener you need to write a java class that implements the org.activiti.engine.delegate.TaskListener interface. In the java class, you need to add the listener logic inside the notify method as follows:

package org.wso2.testbpmn;

import org.activiti.engine.delegate.DelegateTask;
import org.activiti.engine.delegate.TaskListener;

public class FirstTaskListener implements TaskListener {
    public void notify(DelegateTask delegateTask) {
   	 delegateTask.setDescription("First Task Listener");



For example, if you want to log the time that a task starts, you can use a logger inside the task listener to print the start time of a task. 

Once you write the Java class, you can build the project containing the class, add the built .jar file inside the <EI_HOME>/lib directory, and restart the server.

In the process definition you can point to the created class using an eventListener as follows:

<userTask id="myTask" name="My Task" >
    <activiti:taskListener event="create" class="org.wso2.testbpmn.FirstTaskListener"/>

If you look at the process definition given above, you will see that there is a parameter named event. You can use the event parameter to define the event that should trigger the task listener class.

For more information, see Task Listener in the Activiti User Guide.

For information on other event listeners that allow you to handle various events from business processes you create, see Event handlers in the Activiti User Guide.

  • No labels