EventListener for ALL tasks

Good day,

I decided to try and make my life a bit easier and add a @EventListener for every task, which is being executed during the flow. I found this topic - Global event listener on Process Engine Server - #4 by aravindhrs, and although it covers a good portion of the question, I realized that those listeners DO NOT capture script/service tasks.

It’s nothing special, just a

	@Order (1)
	public void printTaskEvent(DelegateTask delegateTask) {
		log.info("Executing task: {} ({}), action: {}", delegateTask.getTaskDefinitionKey(), delegateTask.getName(), delegateTask.getEventName());

So here’s my question of the day - is there a way to listen to all tasks, which are being executed. In particular, script tasks. The reason for this is that my bpmn model is a bit not on the small side, and contains sections with script tasks, following each other.

And every time when something goes wrong, COMPUTER says “There was an exception in a script”, which leaves me with the joyful opportunity to guess WHICH ONE made my day.

Thanks in advance.

Hi @Draakzward,

Task listener can only be used with user tasks.
Execution listener can be used with all activity types including service/script tasks.

Process Application Event Listeners | docs.camunda.org.

Task Event listeners allow to react to Task Events (Tasks are Created, Assigned, Completed). Execution Listeners allow to react to events fired as execution progresses through the diagram: Activities are Started, Ended and Transitions are being taken.


@hassang thank you for your response.

But isn’t @EventListener an Event listener?.. ah, Event and Execution are different words. Sorry, Monday :wink:

@hassang can you please point me to how an ExecutionListener can be implemented in terms of Camunda 7 Spring Boot? I feel like I’m missing something

For someone looking for this, found this to be the right way to go

	public void listen1(ExecutionEvent obj) {
	public void listen1(ProcessInstance obj) {

Generally, I started with listen(Object obj) to determine what type of class I need (not a strong Spring Boot event guy, so sorry for the blasphemy).

Also found in some doc (not yet tested it without these conf lines):

camunda.bpm.eventing.execution: true
camunda.bpm.eventing.history: true
camunda.bpm.eventing.task: true
camunda.bpm.eventing.skippable: true

Still can’t get a grip on how to get the scripts.

Going for

void print(Object obj)

got me close to solving this via HistoricActivityInstanceEventEntity, but I can’t get information about the script that is being executed (inline/resource). And I’m currently in a situation, where “something” is giving me (a headache) a NPE in console (Sorry Dave, but I can’t tell you which one), and the flow has several scripts as input params in a line.

Any ideas?

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.