cancel
Showing results for 
Search instead for 
Did you mean: 

5.17 - Async service tasks executed on multiple engines

nofranks
Champ in-the-making
Champ in-the-making
Hi,

I have created a simple process consisting of a single user task and an async service task. The service task is implemented as a java delegate which sends an email to me with a unique identifier in the subject. I deployed this process and have process engines configured over the same activiti database with the async job executer enabled running on different VM's. I wrote a junit test which creates 50 process instances then completes the 50 user tasks. What I would expect to get back is 50 emails. This is always the case when the service task is not marked async. However, when it is marked as async I'm receiving a degree more, normally 70+.

Some of these tasks are being executed by several process engines. Would this behavior be expected? If not I'd be grateful of some advice as to where I may be at error. Many thanks
3 REPLIES 3

warper
Star Contributor
Star Contributor
If you manage to enable both jobExecutor and asyncExecutor (possibly on different nodes), you'll run into this all the time.

You should set exclusive flag on in tasks, so async jobs will have exclusive flag on, so async executor will lock process in DB to avoid parallel executions. Also you should make sure asyncJobLockTimeInMillis parameter is set properly to avoid job unlocking before previous task execution completes (or fails).
It helps for the most part, but still it's possible to get "optimistic locks" from time to time.

nofranks
Champ in-the-making
Champ in-the-making
Thanks, I figure I must have something wrong with the way in which I've configured the process engines but I can't see it. I have jobExectorActivate to false and asyncExecutorEnabled and asyncExecutorActivate to true. The asyncJobLockTimeInMillis is currently set at default but these executions only take around one second to complete. I've attached output from two different nodes that I think show the issue.

Both seem to claim the job, execute it, then one fails with an ActivitiOptimisticLock exception. This exception doesn't get back to me though so I can't do anything with it to correct the actions taken by the service task. Is this something for which I need to use an error boundary event to clean up after the failed execution?

The failed execution is in dev02_snippet.txt

nofranks
Champ in-the-making
Champ in-the-making
I think this may have been a bug with version 5.17. I have created a 5.21 setup and ran the same process and testing code over it which works as I'd expect it to, no duplication at all.