Storing Process and Task Variables

Hi,

Good day!

We have around 20 to 30 process variables in our workflow. All of them are stored in variables table each one per row. This is impacting the performance much. Is there any better way to customize and store process variables in better way.

Thanks & Regards,
Devakumar J

You could combine multiple variables into an object and serialize that as JSON. See also: https://docs.camunda.org/manual/7.4/user-guide/data-formats/json/#serializing-process-variables

Hi Daniel,

Thanks for your reply. Is it possible possible to serialize variable map itself instead of using object. For e.g) runtimeService.startProcessInstanceById(processId, Map<String,Object). Here instead of storing each key in variables table, serialize and persist/load whole map. Only the difference should be the way of storing variables. Can we acheive this without impacting the way the variables are accessed by process execution/task execution.

Thanks & Regars,
Devakumar J

Hi,

Not sure I understand the question, but you can put a map into the variable map and then you have one variable that contains all the others.

Cheers,
Thorben

Hi Thorben,

Sorry my full text is not reflecting here. Let me create new topic.

Hi Thorben,

Thanks for your reply. Here the full text. Is it possible possible to serialize variable map itself instead of using object. For e.g) runtimeService.startProcessInstanceById(processId, Map(String,Object)). Here instead of storing each key in variables table, serialize and persist/load whole map. Only the difference should be the way of storing variables. Can we acheive this without impacting the way the variables are accessed by process execution/task execution.

Thanks & Regars,
Devakumar J

Hi @Devakumar_Jayaraman,

If you are looking for something like

Map<String, Object> variables = new HashMap<String, Object>();
variables.put("var1", "val1");
variables.put("var2", "val2");

runtimeService.startProcessInstanceByKey("process", variables);

String value = (String) runtimeService.getVariable("var1");

and having all the variables in a single blob in the database, then the answer is: No, you can’t do that.

Cheers,
Thorben

What is your motivation behind that?

Hi Thorben,

I Just wanted to make sure that the way of accessing variables during execution should not be impacted. No other motive. If i put complex object as part of variable map, how can i use any attribute of that object in expression??. For example, ${assignee} in userTask. Will it be ${obj.assignee} ??