AnsweredAssumed Answered

Update process variable from

Question asked by kaihuener on May 6, 2015
Latest reply on May 26, 2015 by jbarrez
Dear all,

I am struggling with updating a process variable from a java delegate that is called by an asynchronously executed multi-instance service task.
My setting:
  • Simple process with a multi-instance service task
    st
    that is to be executed for a given collection of java beans and a following user task
    ut
    .
  • st
    is marked as
    async="true"
    .
  • A java delegate
    jd
    that does some work with a bean from the collection and
  • A process variable
    progress
    that SHOULD be update by each
    jd
    call with the progress of processing the bean collection (i.e.
    nrOfCompletedInstances/nrOfInstances
    ) and that SHOULD be accessible from "outside" of
    jd
    execution.
My problem:
Setting
progress
within
jd
works fine by

int completed = (int) execution.getVariable("nrOfCompletedInstances") + 1;
int total = (int) execution.getVariable("nrOfInstances");
float progress = (float) completed / (float) total;
execution.setVariable("progress", progress)

but when I read
progress
during process execution by

getProcessEngine().getRuntimeService().getVariable(processInstanceId, "progress");

I always get the initial value and not the value that was set by
jd
.

Any hints what I am missing or how to "update" process variables from "inner" asynchronous executions?

Thank you in advance and best regards,
kai

Outcomes