I have a class that stores some metadata. I pass this variable as ProcessInstanceVariable at the process start. My process has only service tasks and each service task updates the metadata variable.
This is how I start the process:
Map<String, Object> processVariables = new HashMap<>();
processVariables.put("metadata", metadata);
runtimeService.startProcessInstanceByKey("myprocess", "mybusinesskey", processVariables);
Then, on each serviceTask, I get the variable, update the content and put it back to the execution:
@Override
public void execute(DelegateExecution execution) {
Metadata metadata = (Metadata) execution.getVariable("metadata");
metadata.foo = "new value";
execution.setVariable(metadata);
}
When the process finishes, I am able to retrieve the variable by processId and variableName from the historic variables table (through the historyService). However, if the process is not yet finished and I try to get the variable using the runtimeService, the variable content is the initial and NOT the desired up-to-date content.
Is there any way I can get the variable with the up-to-date state when the process is still running?