Can you subscribe to notifications for all user tasks?

Hello,

I’m trying to understand if there is a way to subscribe for notifications about user tasks (create, assign, complete, delete, etc.). If I understand correctly - I can create a TaskListener to listen for those events, but I will need to define/attach this listener to each individual task I’m interested in (within the BPMN definition). I would prefer to not modify the BPMN at all (as I don’t have full control over the definitions), but instead subscribe to all user tasks - is that possible?

Thank you!

Hi @dimitar-b

This is indeed possible in a few different ways.
If you don’t want to have you models affected, you can build an engine plugin for the history event stream. This is can listen for specific events across the whole engine and then do whatever action it is you’d like to happen.

You can find more details here:
https://docs.camunda.org/manual/latest/user-guide/process-engine/history/

2 Likes

Another way would be to write a plugin that configures a BpmnParseListener for the engine, which is invoked when parsing any model. That can then be used to add the listeners you mention to each and every task, in the appropriate lifecycle phases.

This option is more of an annotation of the existing model at runtime which prevents you from having to do it manually to the models before deployment; @Niall 's suggestion opts to react to the events as they occur in the history stream, without having to do anything with the model at all.

1 Like

Thank you both for the prompt replies. Looks like both options will work for me, so I’ll give them a try.

Hi @dimitar-b,

here is an example for a process engine plugin with a parse listener: camunda-bpm-examples/process-engine-plugin/bpmn-parse-listener-on-user-task at master · camunda/camunda-bpm-examples · GitHub

Hope this helps, Ingo

3 Likes