02-13-2014 09:17 AM
@Bean
public SpringProcessEngineConfiguration processEngineConfiguration() {
final SpringProcessEngineConfiguration engineConfiguration = new SpringProcessEngineConfiguration();
final DataSource dataSource = activitiDataSource();
engineConfiguration.setDataSource(dataSource);
engineConfiguration.setTransactionManager(transactionManager);
engineConfiguration.setDatabaseSchemaUpdate("drop-create");
engineConfiguration.setJobExecutorActivate(true);
return engineConfiguration;
}
02-14-2014 02:51 AM
02-17-2014 01:39 PM
02-18-2014 02:39 AM
de.wps.activiti.process.TransactionExceptionThrowingProcessTest2Async#transactionManagementTest test.
@Test
@Deployment(resources = { PROCESS_BPMN })
public void transactionManagementTest() throws Exception {
try {
runtimeService.startProcessInstanceByKey(PROCESS_KEY, key);
} catch (Exception ex) {
LOGGER.error("#### Catched exception ####", ex);
}
TimeUnit.SECONDS.sleep(15);
assertThat(countHistoricProcessesByBusinessKey(key), is(1L));
List<Foo> findAll = fooRepository.findAll();
assertThat(findAll, containsInAnyOrder(hasProperty("bar", is("FooBar1")), hasProperty("bar", is("FooBar2"))));
assertThat(findAll.size(), is(2));
}
TimeUnit.SECONDS.sleep(15) waits for job executor to process all jobs. JobExecutor is invoked periodically, that's why we have to wait on it to be executed. changeDBValueTo3
public void waitForJobExecutorToProcessAllJobs(long maxMillisToWait, long intervalMillis) {
JobExecutor jobExecutor = processEngineConfiguration.getJobExecutor();
jobExecutor.start();
try {
Timer timer = new Timer();
InteruptTask task = new InteruptTask(Thread.currentThread());
timer.schedule(task, maxMillisToWait);
boolean areJobsAvailable = true;
try {
while (areJobsAvailable && !task.isTimeLimitExceeded()) {
Thread.sleep(intervalMillis);
try {
areJobsAvailable = areJobsAvailable();
} catch(Throwable t) {
// Ignore, possible that exception occurs due to locking/updating of table on MSSQL when
// isolation level doesn't allow READ of the table
}
}
} catch (InterruptedException e) {
// ignore
} finally {
timer.cancel();
}
if (areJobsAvailable) {
throw new ActivitiException("time limit of " + maxMillisToWait + " was exceeded");
}
} finally {
jobExecutor.shutdown();
}
}
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.