cancel
Showing results for 
Search instead for 
Did you mean: 

How to store some process variables elsewhere?

mamue
Champ in-the-making
Champ in-the-making
The values of the process variables are stored in tables ACT_RU_VARIABLE and ACT_GE_BYTEARRAY.
Is it possible to store some of these variables elsewhere?

Rationale:
Some of our process variable values are already stored in our own tables.
To save table space we currently examine the possibility of eliminating redundant data.
One idea is to intervene persisting of variable values.
We found VariableScopeImpl.createVariableLocal() as a central point between Activiti and the database.
Since this is an internal class of Activiti it is surely no good idea to modify it.

Is there some other alternative to achieve the goal?

Kind regards,
Markus Müller

7 REPLIES 7

melentye
Champ in-the-making
Champ in-the-making
Hello Markus,

have you looked at http://www.activiti.org/userguide/index.html#N12126 ?

regards,
Andrey

jdev_hari
Champ in-the-making
Champ in-the-making
@melentye: The bookmark is not pointing to any section. Could you please let me know the exact title in the user guide where I can look for further info.

Thanks,

jbarrez
Star Contributor
Star Contributor
Indeed, you can implement a custom VariableType which is plugged into the process engine.

That variable type can then go to an external source.

jdev_hari
Champ in-the-making
Champ in-the-making
Hi Joram, can you let me know which class to look into for implementing custom Variable Type. Can you give some references.

Thanks

mamue
Champ in-the-making
Champ in-the-making
Hello Andrey, hello Joram,

thank you for your prompt replies.

My question above was a little bit short. Perhaps an example may be helpful:

In our application we store persons with firstname, lastname, photo, signature, scanned signed NDA, and so on. During process execution these attributes are stored flattened in the process variable map: One process variable keeps the photo, another keeps the NDA, the third keeps the firstname and so on. Additionally there are other process variables in the map which do not belong to any entity of our application.

To reduce the table space needed by our database we had the idea to read the person attributes directly from the Person entity, which is already stored scattered on different database tables. To go this way we need a single point in code where we can take control of which process variables are read or stored as usual and which must be read from or written to a Person entity and its tables. The method VariableScopeImpl.createVariablesLocal(Map<String, ? extends Object> variables) may be such a single point where all process variables go through.

By now we found that our idea has two disadvantages:
  • Since the count of open processes is probably constant, the gain of free tablespace will also be only constant and small compared to the space needed by history data.
  • Our Persons possibly remain changed even if a process is aborted before its successful completion. This is not always what our users expect.
Therefore we accepted that our idea was interesting but not the best 🙂

Kind regards,
Markus Müller

mmaker1234
Champ in-the-making
Champ in-the-making
Hello Markus,

What about keeping in the process instance only a reference (token) to the Person entity (for example DB ID) and to call your business logic to load whatever (Person) data whenever you need it? If you need to track the changes in that data you can still keep the changes in your own DB and store in the process instance only a token to track these changes. When you need your data you just call your business logic with the token to load that data for you.

frederikherema1
Star Contributor
Star Contributor
Take a look at the https://github.com/Activiti/Activiti/blob/master/modules/activiti-engine/src/main/java/org/activiti/... for an example of storing only an identifier and fetching the data when needed in the process from you're services.