08-23-2010 05:33 AM
<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>
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());
}
}
08-24-2010 02:44 AM
08-24-2010 03:54 AM
08-24-2010 06:08 AM
What is needed is activiti engine synchronize the joinig parallel paths over an java monitor object or a semaphore. Is it realistic in any way?
08-24-2010 08:09 AM
08-25-2010 11:40 AM
08-26-2010 09:11 AM
Tags
Find what you came for
We want to make your experience in Hyland Connect as valuable as possible, so we put together some helpful links.