AnsweredAssumed Answered

historyService: variables have revision # 0 all the time

Question asked by gant on Aug 19, 2011
Latest reply on Aug 19, 2011 by ronald.van.kuijk

I have a simple process with two script task in sequence. At process start, I pass in a variable x with value 4, in the first task, my script is x=x+1, in the second task x=x+2. If I look up the variable with historyService after the execution, revision is 0 at anytime:

ProcessInstance procInst = runtimeService.startProcessInstanceByKey(processDefinitionId, variables);
   List<HistoricDetail> variablesUpdateList = historyService.createHistoricDetailQuery().processInstanceId(procInst.getProcessInstanceId()).list();
      for (HistoricDetail histDet : variablesUpdateList){
         HistoricVariableUpdate var = (HistoricVariableUpdate) histDet;
         System.out.println("Name: " + var.getVariableName() +" * Value: "+ var.getValue()+" * Revision: "+ var.getRevision() +" * Time: "+ var.getTime().getTime());

has following output:

Name: x * Wert: 4 * Revision: 0 * Time: 1313752726000
Name: x * Wert: 5.0 * Revision: 0 * Time: 1313752727000
Name: x * Wert: 7.0 * Revision: 0 * Time: 1313752727000

I set the history level to 'full' in my config-file. If I query the database, history level is set to 3, which is correct in my opinion.

Why is the timestamp always the same? Even if the process is very short-running, in my point of view, the timestamps should differ a little, or when is the timestamp set?

I need to query for the last value of my variables, so if the revision is always 0, is the returned list ordered? So the last list entry would always hold the latest value of the variable. What I want to achieve is to get the "output-variables" of my process this way, is there another solution for that?