cancel
Showing results for 
Search instead for 
Did you mean: 

storing non-serializable object into process variables map

workflowuser2
Champ in-the-making
Champ in-the-making
Hi,

I need to store result of a bean invocation back into the process variable map using: activiti:resultVariable.
The result object is not serializable. I get the error message that VariableType is not supported.

I do not have access to the result object class and therefore cannot modify it to be serializable.

Is it possible to cache non-serializable object into the map? I do not need it to be stored in the db (activiti:async="false"). It can be cached in the memory.

If possible, do I need to create another VariableType? Any example of a VariableType that is not serializable?

Thanks
activiti newbie
1 REPLY 1

naag
Champ in-the-making
Champ in-the-making
A VariableType needs some way to save/restore the state of the object you're about to store with it, e.g. if a process reaches a wait state. In case the result of the bean call is reproducible, maybe you can save something like a query parameter and upon loading the variable again, just call the bean again with that same parameter? Activiti provides you with two VARCHAR(4000) fields called TEXT_ and TEXT2_ in ACT_RU_VARIABLE that you can use in combination with your own VariableType. I believe a good example of such a VariableType would be JPAEntityVariableType.

Or maybe it's possible to implement a custom VariableType but leave the setValue() / getValue() methods to do nothing. Then you would need to have VariableType.isCachable() return true and the value would only be stored in memory (questions is for how long? Certainly not after wait states, but maybe it even expires before that?)

Hope it helps.