How to create a task listener and set it for a UserTask, when creating a bpmn.xml file using coding

I am creating a bpmn.xml file using coding. While creating a userTask,

  1. I want to set the task listener and
  2. the event when it will execute.
    I know that we can add it using userTask.setTaskListeners(List) but when we create a TaskListener it does not extend or implement a FlowableListener so we can’t set it using the above approach.
    And I don’t know how to set the event when to execute taskListener.


Not sure if I am completely following.

Your listener should implement org.flowable.engine.delegate.TaskListener. If you are talking about org.flowable.bpmn.model.FlowableListener then this is the one from the model and you should create an instance of it and populate it properly.

There are multiple types of implementation type for the listener. I would suggest that you have a look in the FlowableListenerParser to see how it is done when parsing it from the bpmn.xml


1 Like