cancel
Showing results for 
Search instead for 
Did you mean: 

Async multi instance runs in 1 transaction

stainii
Champ in-the-making
Champ in-the-making
Hello,

We use Spring 3.2 and Activiti 5.17. Our transactionmanager has a timeout of 5 seconds.

We have a multi-instance for 3 items and each item starts with an exclusive gateway check. This read-only check takes 2 seconds. We would expect that every item runs in a separate transaction. But we see a timeout exception when the third item is called.

After some testing, we found out that Activiti starts one transaction, and reuses it for every instance?

We've made sure that async is true for the multi-instance (see attachment).

Are we missing something here?

Kind regards,
Stijn


4 REPLIES 4

stainii
Champ in-the-making
Champ in-the-making
Hello,

As a workaround, we placed a serviceTask in front of the exclusive gateway. This serviceTask now does the java call and sets a boolean variable that is used in the exclusive gateway. Now we dont get a timeout, as the serviceTask makes sure a different transaction is used.

Still I find it very strange that a callActivity of a multi-instance with async=true runs the exclusive gateway of ALL instances in 1 transaction…

jbarrez
Star Contributor
Star Contributor
Activiti does not start multiple threads/transactions for a multi instance. This is related to how Activiti is designed: http://activiti.org/faq.html#WhatIsTheDifferenceBetweenProcessConcurrencyAndJavaConcurrency

I'm assuming this is a multi instance subprocess? If so, it might help to make the elements in the subprocess async (haven't tried it)?

stainii
Champ in-the-making
Champ in-the-making
Making the elements in the multi instace subprocess async did work, indeed. However, it seems that there is still a timeout due to a lot of write queries to the Activiti history tables, which all seemed to happen in 1 transaction.

We solved this problem, by not starting 1 process which starts 1500 muli-instances, but by starting the 1500 multi-instances ourselves in a transactionless EJB.

Thank you for your reply!

jbarrez
Star Contributor
Star Contributor
1500 multi instances does produce quite some data on the default history level 😉