AnsweredAssumed Answered

Problem in multi-instances and subprocess.

Question asked by olivierlaporte on Jan 5, 2017
Latest reply on Jan 9, 2017 by gdharley

For a customer i have to create a multi instancied call-activiti that call a subprocess witch call an other subprocess and echange with an asynchronous webservice.


When the webservice responds a lot of optimistic locking exceptions occure because the exclusive flag does not apply for child processes.


When I see the source-code, indeed, the exclusive flag operate only for the current process instance not for childs :


 AcquiredJobs acquiredJobs = new AcquiredJobs();
    List<JobEntity> jobs = commandContext
      .findNextJobsToExecute(new Page(0, maxNonExclusiveJobsPerAcquisition));
    for (JobEntity job: jobs) {
      List<String> jobIds = new ArrayList<String>();
      if (job != null && !acquiredJobs.contains(job.getId())) {
        if (job instanceof MessageEntity && job.isExclusive() && job.getProcessInstanceId() != null) {
          // wait to get exclusive jobs within 100ms
          try {
          } catch (InterruptedException e) {}
          // acquire all exclusive jobs in the same process instance
          // (includes the current job)
          List<JobEntity> exclusiveJobs = commandContext.getJobEntityManager()
          for (JobEntity exclusiveJob : exclusiveJobs) {
            if (exclusiveJob != null) {
              lockJob(commandContext, exclusiveJob, lockOwner, lockTimeInMillis);
        } else {
          lockJob(commandContext, job, lockOwner, lockTimeInMillis);
If i see the request it's seems ok :
  public List<JobEntity> findExclusiveJobsToExecute(String processInstanceId) {
    Map<String,Object> params = new HashMap<String, Object>();
    params.put("pid", processInstanceId);
    params.put("now", Context.getProcessEngineConfiguration().getClock().getCurrentTime());
    return getDbSqlSession().selectList("selectExclusiveJobsToExecute", params);
But according to BPMN 2.0 specifications i don't think that is a correct behaviour.
Do you think correct it in next v 5.xx versions ?