Hi,i have tryed a very simple process with parallel gateway and two user task an each path:
<process id="concurency">
<startEvent id="start" />
<parallelGateway id="fork" />
<userTask name="task_1" id="task_1" />
<parallelGateway id="join" />
<userTask name="task_2" id="task_2" />
<userTask name="ready" id="ready" />
<endEvent id="end" />
<sequenceFlow sourceRef="start" targetRef="fork"/>
<sequenceFlow sourceRef="fork" targetRef="task_1"/>
<sequenceFlow sourceRef="fork" targetRef="task_2"/>
<sequenceFlow sourceRef="task_1" targetRef="join"/>
<sequenceFlow sourceRef="task_2" targetRef="join"/>
<sequenceFlow sourceRef="join" targetRef="ready"/>
<sequenceFlow sourceRef="ready" targetRef="end"/>
</process>
My point was, to see the behaviour of activity by asynchronous completing the user tasks. Each user task will be completed in own thread. After joining parallel pathes i am expecting to get the "ready" task but it get no task at all. Activiti use the database for synchronisation and in this case is seems doesnt to work.Probably is misunderstood the manier in which i have to use the activiti for such tasks…Any idea?Thanks,VladimirThe junit is:
public class CuncurencyTest {
@Rule
public LogInitializer logSetup = new LogInitializer();
@Rule
public ProcessDeployer deployer = new ProcessDeployer();
private ScheduledExecutorService executor;
@Before
public void setUp() throws Exception {
this.executor = Executors.newScheduledThreadPool(10);
}
@After
public void tearDown() throws Exception {
this.executor.shutdownNow();
this.executor.awaitTermination(10, TimeUnit.SECONDS);
}
@Test
@ProcessDeclared
public void testConcurency() throws Exception {
ProcessInstance pi = this.deployer.getProcessService().startProcessInstanceByKey(
"concurency");
TaskQuery query = this.deployer.getTaskService().createTaskQuery().processInstance(
pi.getId());
List<Task> tasks = query.list();
List<Callable<Object>> taskWorkers = new ArrayList();
// complete user tasks asynchronously
for (final Task task : tasks) {
taskWorkers.add(new Callable() {
@Override
public Object call() throws Exception {
CuncurencyTest.this.deployer.getTaskService().complete(task.getId());
return null;
}
});
}
List<Future<Object>> futures = this.executor.invokeAll(taskWorkers);
// Wait for process finished
for (final Future<Object> future : futures) {
future.get();
}
tasks = query.list();
// I would expect here the usertask "ready"!
assertEquals(1, tasks.size());
assertEquals("ready", tasks.get(0).getName());
}
}