cancel
Showing results for 
Search instead for 
Did you mean: 

Process and Task variables storage

frankee787
Champ on-the-rise
Champ on-the-rise
Dear All,
  This is about a design choice. In all process backed applications which involves "Human Task" etc, there will definitely be process variables and task variables. These variables will hold values which are either filled in by the end user(eg: leave dates) or sometimes generated by the system(eg: document reference numbers). I understand these variables are stored as key value pairs in the Activiti database.

Question:
   1)What is the best practices when choosing the structure of these process variable? Should they just be flat key,value pairs or key,domain-object pairs? Any rule of thumb in choosing?
    2)At times it would be required to provide search across these variable values. Storing them as key,value pairs or key,domain-object pairs make it hard to search across them since there is no relational structure. How can you work around this and what is the best practice to handle this ?

Note:
  The "TaskQuery taskVariableValueEquals(String variableName, Object variableValue)" searches for task which have variables with variableName and values as variableValue . But could the query performance keep degrading as the number of process instances keep increasing?

Happened to see this article by Joram.
http://www.jorambarrez.be/blog/2008/04/03/some-real-life-jbpm-action/

The speed in completion of processes is good. However, how would querying for tasks and task which contain a specific variable value behave. I am really interested in knowing how this can be tuned .



Regards,
Franklin
3 REPLIES 3

trademak
Star Contributor
Star Contributor
Hi,

1. If you want to query on them using the Activiti query API using name/value pairs is the easiest of course. You can use complex Javabeans implementing Serializable, but you won't be able to query on them very easily.
2. Of course, when there are a lot of database rows and complex variable structures performance can become an issue. But process variables should not become complex structures to my opinion. They should be simple name/value pairs and process container objects consisting of a flat Javabean structure. If you need complex structures it's better to store it separately in a database and use the JPA extension of Activiti.

Best regards,

frankee787
Champ on-the-rise
Champ on-the-rise
Hi Tijs,
  Thanks for the prompt response. Its good to get information straight from the horse's mouth.

  Could you tell me what exactly is "process container objects" ?

If you need complex structures it's better to store it separately in a database and use the JPA extension of Activiti.

Do you mean its better to store these complex structure in a relational manner or again as key value pairs?

What do you mean by JPA extension of Activiti ?

Regards,
Franklin

trademak
Star Contributor
Star Contributor
Hi Franklin,

A process container object is a POJO that contains several simple type attributes that overcomes the issue of having a lot of simple name/value process variables.
In mean that if you have a complex structure it's better to store it separately in a relational manner. Then you can use the built-in JPA functionality in Activiti to make it easily accessible in your process instance. The JPA extension is described in the userguide. But you can of course also build your own data logic classes.

Best regards,