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
.getJobEntityManager()
.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 {
Thread.sleep(100);
} catch (InterruptedException e) {}
// acquire all exclusive jobs in the same process instance
// (includes the current job)
List<JobEntity> exclusiveJobs = commandContext.getJobEntityManager()
.findExclusiveJobsToExecute(job.getProcessInstanceId());
for (JobEntity exclusiveJob : exclusiveJobs) {
if (exclusiveJob != null) {
lockJob(commandContext, exclusiveJob, lockOwner, lockTimeInMillis);
jobIds.add(exclusiveJob.getId());
}
}
} else {
lockJob(commandContext, job, lockOwner, lockTimeInMillis);
jobIds.add(job.getId());
}
}
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 ?