Adding/Removing Listeners at runtime

Is it possible to add or remove the Task/Execution listeners at runtime in camunda?

In Activiti, It’s possible to add and remove additional event-listeners to the engine by using the API ( RuntimeService)

void addEventListener(ActivitiEventListener listenerToAdd);

void addEventListener(ActivitiEventListener listenerToAdd, ActivitiEventType... types);

void removeEventListener(ActivitiEventListener listenerToRemove);

But the listeners added at runtime are not retained when the engine is rebooted.

Hi @aravindhrs,

what is the reason that you want to add or remove Listeners at runtime?

Regards
Michael

Based on criteria,at runtime we need to execute listeners at certain sequence i.e., execution order

I would suggest adding the Listeners where they might be needed and set some boolean-flags in the process so that you can evaluate in the Listener if the logic should be executed or not. Like the following:

if(myProcessVariable == true) {
// execute logic
}

Otherwise it could be confusing for other persons when they see that there is a Listener involved that wasn’t modeled in the diagram but added later on.

Regards
Michael

@MichiDahm tahnks for the reply. I can achieve it through business rule task also, for “n” number of conditions. But the context of question is different :smile: