EventListener configuration

I believe I found a slightly difference in the configuration of event listeners done via processEngineConfiguration whether on process models XMLs.

If I operate something like:

<property name="typedEventListeners">    
    <entry key="JOB_EXECUTION_FAILURE" >            
        <bean class="com.playground.MyListener"/>            

I cannot have MyListener to be CDI aware, all @Inject annotations will be null objects.

But if I put:

<flowable:eventListener events=“JOB_EXECUTION_FAILURE” delegateExpression="${myListener}"></flowable:eventListener>

in every process model, since I’m using delegateExpression, it will work.

The downside is that it would require editing for all existing process models.

Is there a way to use “delegateExpression” for <bean class in the processEngineConfiguration aswell?

Moreover: I already have a “startExecutionListener” in any of my processes, it would be the same to have this API usage:

void addEventListener(FlowableEventListener listenerToAdd, FlowableEventType… types);

in the listener I’m already invoking on that execution listener?

Thanks for any suggestion! :wink:


This text will be hidden

How are you using Flowable in CDI? If you’re creating the engine programmatically, you could set the CDI-aware beans on the processEngineConfiguration directly (and they would have all dependencies injected).

Hi Joram,
I’m actually using a custom “com.playground.CdiJtaProcessEngineConfiguration” extending the default CdiJtaProcessEngineConfiguration because I’m overriding in it the transaction manager related methods.

I’m fully CDI aware when executing custom Service Tasks (since they’re declared as delegate in the process definition) and same goes for my process defined ExecutionListeners (onStart and onComplete) but I cannot get an EventListener to be CDI aware if I define it in the flowable.cfg.xml, I managed to do it by injecting a programmatical EventListener in every process flow design, but doing that only in the process engine cfg file would be better since I would not have the issue of modifying any existing process flow in Design app.

Cheers, thanks.

(See you on friday, btw, yay!)

True - however, is it needed you boot up the engine from xml config? Is there a way you could do it programmatically, as a CDI-aware bean?

I think I missed the point.

Actually I have flowable-engine in my war pom’s file, then in my webapp, and that requires afaik an xml config…
I already have a @Startup annotated Singleton which is deputed to start some of my beans, so it would be easy to manage there the engine aswell, but I lack some… infos, tho.

Is there some sort of example around to switch the engine configuration from xml to CDI aware and get rid of the xml file?

No, not beyond what’s described in https://flowable.org/docs/userguide/index.html#cdiintegration. Sadly, we don’t see that much CDI usage to add these things (but PR’s are of course appreciated :wink: ).