Listeners are not called

Hi,

I’m trying to set up some listeners. I use Wildfly 8 with Camunda 7.4, On Wildfly I deployed application which starts my Camunda process (via RuntimeService.startProcessInstanceByKey()). I set up and deployed on Wildfly another application with Process Application class (just described like here: https://docs.camunda.org/manual/7.4/user-guide/process-applications/the-process-application-class/#deploying-a-custom-ejbprocessapplication-class). I also set up CDI bridge (following those instructions: https://docs.camunda.org/manual/7.4/user-guide/cdi-java-ee-integration/the-cdi-event-bridge/#the-cdi-event-bridge-in-a-process-application).

However, neither getExecutionListener() or getTaskListener() are not executed when I start my process :confused: I also tried to set up in Process Application class e.g. parse listeners… no success. Those are also not executed. When I debug my application from which I start Camunda process then in process engine I can see those listeners, but for some reason those are not executed.

When I set up manually in BPMN diagram listener, then it works. But I need more general way of defining listeners.

Any ideas what I’m doing wrong?

Do you also call
org.camunda.bpm.engine.ManagementService.registerProcessApplication(String, ProcessApplicationReference) ?
This required to make your process application known to your process deployment.

2 Likes

@langfr I added that too, but nothing special happened. However, I’m not sure if I use it correctly. In my Process Application class first I unregeister all deployments with: managementService.unregisterProcessApplication(); and then I register them again with: managementService.registerProcessApplication(deployment, this.getReference());

Is it correct approach?

EDIT:
Yeap that actually worked :slight_smile: I just had installed reactor plugin, and it probably messed something up. Now CDI events are working! Thank you for help. Maybe it would be nice to have such example in your GIT?

There only one more thing. I noticed, that we I restart server I have to make sure that my app with Process Application class is deployed at the very end (after all Camunda processes are already there). Which makes sense, while there must be already deployed processes to reregister them. Any solution for that? Parse listener would be good place to put logic for that, but how do that? I don’t want to add manually such listener for every process I will make in the future.

EDIT2:
Unfortunetty, I was happy too soon. I got such error now:
ENGINE-16004 Exception while closing command context: Unknown property used in expression:
Which makes sense IMO, because I unregister deployments, and cannot just like that register them :confused:

I’m not sure what you did exactly. Where and when do you this error?

Some extract from my ProcessApplication. After ProcessApplication is deployed and running, it registers itself to all existing deployments. Before shutdown unregister is done.

    @PostDeploy
    public void deployed()
    {
        List<Deployment> deployments = this.repositoryService.createDeploymentQuery().list();
        for ( Deployment deployment : deployments ) {
            this.managementService.registerProcessApplication( deployment.getId(), this.getReference() );
        }
    }

    @PreUndeploy
    public void beforeUndeploy()
    {
        List<Deployment> deployments = this.repositoryService.createDeploymentQuery().list();
        for ( Deployment deployment : deployments ) {
            this.managementService.unregisterProcessApplication( deployment.getId(), true );
        }
    }
1 Like

@langfr: I did quite the same thing you posted. After deploy I register deployments with management service. This is flow I have:

  1. I deploy my application with camunda process to Wildfly , it works like it should when I start it,
  2. I deploy application with ProcessApplication to Wildfly, it deploys correctly, then it also correctly get deployments (I can see there my camunda process from point 1)) and it registers them,
  3. I start again my camunda process and this error pops up:
    javax.ejb.EJBTransactionRolledbackException: Unknown property used in expression: #{businessCamundaBean.execute(execution)}. Cause: Cannot resolve identifier 'businessCamundaBean'

It looks like, it cannot resolve my beans. From what I researched, registering process application should solve that issue, but it doesn’t in my case :confused: Don’t know why. Do I need to register beans to camunda engine somehow?

The bean named ‘businessCamundaBean’ is in which deployment?
I your first deployment or the second one with the ProcessApplication? I guess it’s in the first one.
And after registering the ProcessApplication deployment for your processes the bean cannot be found anymore.
Why did you choose to use 2 seperate deployments? I’m not sure if this can work at all.
Why not put your ProcessApplication class into the first deployment unit containing your process?

1 Like

@langfr Yeap, it’s in first deployment. It’s because i use micro services. Every process is separated application. I change a little bit approach. I added ProcessApplocation as a dependency (in my case in maven) to my deployment with camunda process and it works… until I tried more complex process.

Some of our process executes other processes (as a Call Activity ->https://docs.camunda.org/manual/7.4/reference/bpmn20/subprocesses/call-activity/). In such case, it breaks with similar error. Here is scenario: I got two processes: P1 and P2. P1 at some point calls P2. Problem occurs, when P2 is started from P1. P2 throws error like:
javax.ejb.EJBTransactionRolledbackException: Unknown property used in expression: #{businessInProcess2CamundaBean.execute(execution)}. Cause: Cannot resolve identifier 'businessInProcess2CamundaBean'

I added as a dependency my process application to both of my camunda processes (P1 and P2). I can’t figure it out. Any ideas?

Two ideas, but really vague ideas, I never tried such setup.

  1. Did you set “aysnc before” on startevent of process P2? This triggers some kind of savepoint / commit and further execution of P2 in a seperate transaction.
  2. If P1 needs classes from P2, you might have to add a dependency using jboss-deployment-structure.xml.
    Seperated deployments in Wildfly are isolated.
1 Like

@langfr 1) no I haven’t, but i tested it without success.
2) same here, no success.

I wondering, my problem may be contected with this one: https://docs.camunda.org/manual/7.5/user-guide/spring-framework-integration/expressions/#expression-resolving-with-the-shared-process-engine Unfortunately, I don’t use Spring. Description in docs fits my setup. However I’m no sure how I could implement it by my own…

Perhaps this will help you: https://docs.jboss.org/author/display/WFLY8/CDI+Reference

1 Like

@langfr hey, I found solution. This is what I did.

  1. I built maven module with ProcessApplication as a jar,
  2. A added as a dependency to all my modules with Camunda process module from 1) (as a EJB type),
  3. In ProcessApplication I have simple code taken from: https://docs.camunda.org/manual/7.4/user-guide/cdi-java-ee-integration/the-cdi-event-bridge/#the-cdi-event-bridge-in-a-process-application

No registering PA or unregistering PA, this was making mess in my case.

Thank you very much for help, you gave me some good clues.