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).
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…
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.