Process variable are not getting saved in database

Hi
I have developed a process model using flowable and made a http request using http task which returns me an object

processVariables = runtimeService.getVariables(processInstance.getId());
using this I can retrieve the object in my java class
processVariables2 = processInstance.getProcessVariables();
but when I did this it gives me null value

Also object doesn’t get saved in database

even I have marked save response as json true

I even tried
runtimeService.setVariables(processInstance.getId(), processVariables);
taskService.setVariables(task.getId(), processVariables);

flowable2

Hi @sagaraa

How do you fetch processInstance ?

processInstance = runtimeService.startProcessInstanceByKey(myProcessId);

Try this one:

runtimeService.createProcessInstanceQuery().includeProcessVariables().processInstanceId(processInstance.getId())).singleResult();

If your process is completed:

historyService.createHistoricVariableInstanceQuery().processInstanceId(processInstance.getId()).list()

For running process you can also use this one:

runtimeService.getVariables(processInstance.getId())

runtimeService.createProcessInstanceQuery().includeProcessVariables().processInstanceId(processInstance.getId())).singleResult();

it is returning me a processInsatance

Yep. Now call getProcessVariables() on this object.

it gave me the result I wanted but still the variables are not getting stored in the database,
I want to know why it is happening, what mistake I am committing

I am looking the right table
TestDB.dbo.ACT_RU_VARIABLE
right???

Yes. For active processes.
But for completed processes you should check ACT_HI_VARINST

My bad,
So you mean whatever variables I have in ACT_RU_VARIABLE are for the only active/ incomplete processInstances
and ACT_HI_VARINST contains variables for completed processes.
is it???

I am using it for testing purpose it maybe possible my processInstances may stopped due to some error now I want to know, if it is true(that those are incomplete processes) then, how can I access those incomplete variables and continue them where they stopped due to some error because I have to access those process Instances.

Thanks that was really helpful.

Almost. The history table will also contain the runtime variables. Variables will be removed from the runtime table once the process instance has finished.

They should be in the historic variables table. Variables there never get removed.