Closed datakurre closed 2 years ago
This time I remembered to build and run demo projects from JAR files (because asyncResponseTimeout does not work on Maven project otherwise, as discussed in the original asyncResponseTimeout issue long time ago).
Hi @datakurre , Just to be sure: release 2.8.0 fails for you too, right?
@tobiasschaefer Yes. I started from 2.10.0 and tried all versions down to 2.7.2, which worked.
The broken version 2.8.0 basically only contains one commit which zu updates Micronaut from 3.4.4 to 3.5.2: https://github.com/camunda-community-hub/micronaut-camunda-platform-7/commit/eb512522aa6fa6736e3e526b314fd85f06d38af2
I'll take a closer look.
I double checked that the issue existed already on 2.8.0. It does.
@tobiasschaefer I spent some time with debugger and found the following difference between 2.7.2 and 2.8.0
When a process enters external service task, the following transaction listener is fired in 2.7.2 but no longer in 2.8.0 (the method is called to register the listener, but it never fires), and therefore long poll request does not get the signal about new task and waits until the timeout:
Thanks for that detailed analysis. It must be related to Micronaut's transaction handling which changed in 2.8.0.
I'll have a look.
🤩
Thanks to this, I know now much better, how Camunda long polling works. I was not aware that only new tasks are immediately delivered, because of that event being triggered. Tasks with silently expiring lock, are only redelivered after asyncResponseTimeout (or with tasks that fired that event). Therefore, optimal asyncResponseTimeout might be surprisingly short. A compromise between not polling all the time, but poll often enough to also deliver those exceptions in timely manner.
Hey @datakurre ,
can you please test release v2.11.1. It fixes the issue for me.
Note to myself:
time curl -X POST http://localhost:8080/engine-rest/external-task/fetchAndLock -H "Content-Type: application/json" -d'{"maxTasks": 1, "workerId": "aWorkerId", "asyncResponseTimeout": 10000, "topics": [{"topicName": "Example", "lockDuration": 10000}]}'
curl -X POST http://localhost:8080/engine-rest/process-definition/key/Example/start -d '{}' -H 'Content-Type: application/json'
Process Model: diagram_1.bpmn.txt
@tobiasschaefer I can confirm the fix. Thanks again!
The last version where asyncResponseTimeout for REST API external task long poll works properly is 2.7.2
Minimal working demo: demo-2.7.2.zip
Here I start a long poll and then start a new instance of a process and get response immediately after starting the instance, which is much less than 10 seconds of asyncResponseTimeout:
Minimal failing demo: demo-2.10.0.zip
Here I do the same, but I only get the response after asyncResponseTimeout of 10000 has exceeded: