Complete TaskListener in SpringBoot process application

Hello,
I have problem with using Complete TaskListener in my SpringBoot process application.

My process application is running as springboot application on Server1. But my Camunda REST API is running on another Tomcat server - Server2. If I try to call POST ‘/task/{id}/complete’ on Camunda REST API server I will get error:

Unknown property used in expression: ${checkClaimCompleteListener}. Cause: Cannot resolve identifier ‘checkClaimCompleteListener’

This is because ${checkClaimCompleteListener} JavaDelegate is deployed on SpringBoot server - Server1, not on Camunda REST API server. So, I understand the reason but I don’t know how to solve it.

I’m using Async in my process model and I’m using deployment-aware configuration.

I think my case is typical for SpringBoot process application. So there should be some best practice.

Thanks for your help.

Michal

Have you added camunda dependencies to this application?

@aravindhrs Thanks for your response.
Yes. All my other Execution and Task Listeners are working as expected.
Only Complete Task Listener is run on Camunda REST API server. I suppose the same problem will be with Assignment Task Listener because assignment event is also typically invoked by REST API call.

@Michal_Moravek, so you’re performing the part of the bpmn process in your springboot process application and part of the process using camunda REST api.

I think there’s an architecture or application setup issue with your current design.

Please go through these docs for architecture and cluster-setups

@Michal_Moravek you are using Async Before on the user task?

If you use a Service Task after your user task (sync) and try and access the delegate, does it work? (just want to make sure the normal path is working, to see if its something specific about listeners).

Take a look at this great presentation that outlines many of the smaller but very important configuration patterns:

Maybe I didn’t descibe it well. All my listeners (execution + task) and all my service tasks Java Delegates are located in my springboot process application. And all my listeners and service tasks is processed in springboot application - so, cluster-setup is working.
EXCEPT complete task listener. Complete operation on task I invoke typically via Camunda REST API. But Camunda REST API is running on separated Tomcat server. And if I invoke task complete operation, Camunda REST API engine is trying to run Complete Task listener. But it is located in springboot application, so Camunda REST API engine is not able to find it.

@StephenOTT This presentation is great. And this is exactly approach I followed. But I think, this approach is not working for Assignment and Complete Task Listeners. Because these listeners are invoked transactionally in Web App (in case of Abhishek Pande example).

@StephenOTT and @aravindhrs Here is visualisation of the problem:

Hi @Michal_Moravek,

what about moving the listener code from task events to sequence flow listeners?

Or moving the listener implementation to the spring boot rest application?

Hope this helps, Ingo

Hi @Ingo_Richtsmeier,

Moving the listener code from user task is possible but only in cases where you don’t need task context data in your listener business logic (eg. taskId, assignee…).

Ad moving the listener implementation to the springboot REST app: Yes, this is the second option. But I really don’t like it. In this case you separate part of business logic of your process application (which is contextually and logically part of your process application) and move it to the shared Camunda REST API web app. Finally, Camunda REST API web app will contain a lot of libs (jars) from another process applications. With this approach you can easily harm availability and reliability of your Camunda REST API web app. So, I don’t prefer this solution.

Hi @Michal_Moravek,

another option is to move the camunda-bpm-spring-boot-starter-rest from it’s separated application into the application containing the process.

However, the listener class and the executed process instance have to run on the same JVM where you complete the user task, as the listener is always invoked in the same transaction with the completion command.

Hope this helps, Ingo

Hi @Ingo_Richtsmeier,

In this case you will have many Camunda REST APIs after some time. And you will need to know which REST API endpoint to call for which task completion. And you will not be able to use standard Camunda Tasklist, because it uses one REST endpoint.

I think this behavior (or lets call it feature) should be descibed in Camunda documentation - “Hey, async continuations is working, BUT with these limitations - complete and assignment Task Listener. Because, these listeners are invoked in client thread transaction.”

1 Like

Hi @Michal_Moravek,

somehow it’s mentioned here: Transactions in Processes | docs.camunda.org, but not as explicit as you would like to have it.

You can improve the documentation with a pull request: Each page has a link to it’s Github page on the top:

You can edit the page and immediatly create a pull request with your commited change. The product team with judge and most likely accept it.

Hope this helps, Ingo