There seems to be two ways to implement global listeners (task and execution).
First method from:
On top of the Execution and Task Listeners which are explicitly configured in the BPMN 2.0 XML, the process application API supports defining a global ExecutionListener and a global TaskListener which are notified about all events happening in the processes deployed by a process application
Second method described in this GitHub project.
First, is my understanding correct that these are two distinct method of implementing global listeners.
Secondly, if correct, what are the pros and cons of the two methods? At first glance, the first method definitely seems to be much simpler.
If you look at the task properties in Camunda Modeler, you will see a “listeners” tab. The tab on a User task will have both Execution Listener and Task Listener options. When you click on the “+” to add one of each, you will see the difference between the two.
Execution Listeners can only react to the start and end events of the task. While Task listeners have more event options that correlate with the Task lifecycle.
I was and am already familiar with both execution and task listeners and how they can be attached to process models and tasks.
My post referred to the subject of global execution and task listeners and the two different ways in which they can be implemented.
If you follow the links referred to in the post, that should familiarize you with subject matter.
Sorry about that. I don’t know too much about Java applications. This is my guess, not from experience. It looks like you can have multiple java applications using a single Camunda engine. A global plugin would then register and react to events across all applications.
Please take the following guesses with appropriate lack of confidence.
How I read the two links you supplied agree with your assertion that they are two different ways of implementing listeners, but not necessarily global listeners. My understanding is that the parse listener doesn’t really generate “global” listeners, but adds the same logic globally.
The parse listener seems to be a way to automate adding the same BPMN Task listeners to every instance of a particular class of task when the BPMN gets deployed. Thus you could filter out adding these listeners based on task name, process name or basically anything else. From the execution engine’s standpoint, it would be the same as if you added the task (or execution) listener in the BPMN.
The process-application-listener seems to be attached to the process application, and gets all the events for all the tasks (or executions) in that application. The code that gets executed is the same for all of them, thus the code has to contain all the branches and cases within it to handle the various types of task events. If you have a lot of different types of tasks with a lot of conditional logic, this code could become very convoluted.
As with many things in Camunda, I think think the “which is better” comes down to an answer of “it depends on your circumstances and exactly what you’re trying to achieve”
@GotnOGuts I like you explanation. Seems pretty reasonable and complete to me. I’ll dig a bit more into the subject parse listener. Thanks a lot for your help.