cancel
Showing results for 
Search instead for 
Did you mean: 

Caching, process variables, multiple jvms

imamchishty
Champ in-the-making
Champ in-the-making
Lets say that I've created a variable called userId and this is available for spring beans:

For example:

<serviceTask id="userTask" name="userTasks" activiti:expression="#{userTask.findUsersAddress(userId)}" />

In the above example the userId would be automatically provided to the userTask spring bean.

Questions:

1. Each time userId is required is this variable obtained directly from the database? Or from a local cache, e.g. map?

2. If I have multiple JVMs is there a recommended mechanism to handle variables to keep them in sync.

3. If JVM1 adds a new variable is this only available locally or to all JVMs?

4. Any recommendation on ehcache or hazlecast integration. I.e. let the cache maintain the variables rather than activiti?
1 REPLY 1

trademak
Star Contributor
Star Contributor
Hi,

1. It's cached inside the Activiti Engine.
2. If you have multiple JVMs it also should be no problem as-is. The Activiti Engine runs all the synchronous elements of a process definition in one go.
When for example a user task is encountered, the process state is stored to the database, including its variables.
Then when the user task is completed and the process instance continues, the process execution and variables are retrieved from the database or the cache.
3. It's available only on JVM1 at first, but when the process instance is persisted it's of course available to all JVMs.
4. Do you see performance issues for your usage? Activiti is pretty fast already, and is scalable to multiple JVMs out-of-the-box, so why would you want to add another cache?

Best regards,