use of org.camunda.bpm.engine.impl.cfg.StandaloneInMemProcessEngineConfiguration in project camunda-bpm-platform by camunda.
the class RuntimeServiceTest method testStartProcessInstanceByIdAfterReboot.
// Test for a bug: when the process engine is rebooted the
// cache is cleaned and the deployed process definition is
// removed from the process cache. This led to problems because
// the id wasnt fetched from the DB after a redeploy.
@Test
public void testStartProcessInstanceByIdAfterReboot() {
// In case this test is run in a test suite, previous engines might
// have been initialized and cached. First we close the
// existing process engines to make sure that the db is clean
// and that there are no existing process engines involved.
ProcessEngines.destroy();
// Creating the DB schema (without building a process engine)
ProcessEngineConfigurationImpl processEngineConfiguration = new StandaloneInMemProcessEngineConfiguration();
processEngineConfiguration.setProcessEngineName("reboot-test-schema");
processEngineConfiguration.setJdbcUrl("jdbc:h2:mem:activiti-reboot-test;DB_CLOSE_DELAY=1000");
ProcessEngine schemaProcessEngine = processEngineConfiguration.buildProcessEngine();
// Create process engine and deploy test process
ProcessEngine processEngine = new StandaloneProcessEngineConfiguration().setProcessEngineName("reboot-test").setDatabaseSchemaUpdate(ProcessEngineConfiguration.DB_SCHEMA_UPDATE_FALSE).setJdbcUrl("jdbc:h2:mem:activiti-reboot-test;DB_CLOSE_DELAY=1000").setJobExecutorActivate(false).buildProcessEngine();
processEngine.getRepositoryService().createDeployment().addClasspathResource("org/camunda/bpm/engine/test/api/oneTaskProcess.bpmn20.xml").deploy();
// verify existence of process definition
List<ProcessDefinition> processDefinitions = processEngine.getRepositoryService().createProcessDefinitionQuery().list();
assertEquals(1, processDefinitions.size());
// Start a new Process instance
ProcessInstance processInstance = processEngine.getRuntimeService().startProcessInstanceById(processDefinitions.get(0).getId());
String processInstanceId = processInstance.getId();
assertNotNull(processInstance);
// Close the process engine
processEngine.close();
assertNotNull(processEngine.getRuntimeService());
// Reboot the process engine
processEngine = new StandaloneProcessEngineConfiguration().setProcessEngineName("reboot-test").setDatabaseSchemaUpdate(org.camunda.bpm.engine.ProcessEngineConfiguration.DB_SCHEMA_UPDATE_FALSE).setJdbcUrl("jdbc:h2:mem:activiti-reboot-test;DB_CLOSE_DELAY=1000").setJobExecutorActivate(false).buildProcessEngine();
// Check if the existing process instance is still alive
processInstance = processEngine.getRuntimeService().createProcessInstanceQuery().processInstanceId(processInstanceId).singleResult();
assertNotNull(processInstance);
// Complete the task. That will end the process instance
TaskService taskService = processEngine.getTaskService();
Task task = taskService.createTaskQuery().list().get(0);
taskService.complete(task.getId());
// Check if the process instance has really ended. This means that the process definition has
// re-loaded into the process definition cache
processInstance = processEngine.getRuntimeService().createProcessInstanceQuery().processInstanceId(processInstanceId).singleResult();
assertNull(processInstance);
// Extra check to see if a new process instance can be started as well
processInstance = processEngine.getRuntimeService().startProcessInstanceById(processDefinitions.get(0).getId());
assertNotNull(processInstance);
// close the process engine
processEngine.close();
// Cleanup schema
schemaProcessEngine.close();
}
use of org.camunda.bpm.engine.impl.cfg.StandaloneInMemProcessEngineConfiguration in project camunda-bpm-platform by camunda.
the class JobPrioritizationBpmnExpressionValueTest method testDefaultEngineConfigurationSetting.
public void testDefaultEngineConfigurationSetting() {
ProcessEngineConfigurationImpl config = new StandaloneInMemProcessEngineConfiguration();
assertTrue(config.isEnableGracefulDegradationOnContextSwitchFailure());
}
use of org.camunda.bpm.engine.impl.cfg.StandaloneInMemProcessEngineConfiguration in project camunda-bpm-platform by camunda.
the class SequentialJobAcquisitionTest method testExecuteJobsForTwoEnginesSameAcquisition.
@Test
public void testExecuteJobsForTwoEnginesSameAcquisition() {
// configure and build a process engine
StandaloneProcessEngineConfiguration engineConfiguration1 = new StandaloneInMemProcessEngineConfiguration();
engineConfiguration1.setProcessEngineName(getClass().getName() + "-engine1");
engineConfiguration1.setJdbcUrl("jdbc:h2:mem:activiti1");
engineConfiguration1.setJobExecutorActivate(false);
engineConfiguration1.setJobExecutor(jobExecutor);
engineConfiguration1.setDbMetricsReporterActivate(false);
ProcessEngine engine1 = engineConfiguration1.buildProcessEngine();
createdProcessEngines.add(engine1);
// and a second one
StandaloneProcessEngineConfiguration engineConfiguration2 = new StandaloneInMemProcessEngineConfiguration();
engineConfiguration2.setProcessEngineName(getClass().getName() + "engine2");
engineConfiguration2.setJdbcUrl("jdbc:h2:mem:activiti2");
engineConfiguration2.setJobExecutorActivate(false);
engineConfiguration2.setJobExecutor(jobExecutor);
engineConfiguration2.setDbMetricsReporterActivate(false);
ProcessEngine engine2 = engineConfiguration2.buildProcessEngine();
createdProcessEngines.add(engine2);
// stop the acquisition
jobExecutor.shutdown();
// deploy the processes
engine1.getRepositoryService().createDeployment().addClasspathResource(PROCESS_RESOURCE).deploy();
engine2.getRepositoryService().createDeployment().addClasspathResource(PROCESS_RESOURCE).deploy();
// start one instance for each engine:
engine1.getRuntimeService().startProcessInstanceByKey("intermediateTimerEventExample");
engine2.getRuntimeService().startProcessInstanceByKey("intermediateTimerEventExample");
Assert.assertEquals(1, engine1.getManagementService().createJobQuery().count());
Assert.assertEquals(1, engine2.getManagementService().createJobQuery().count());
Calendar calendar = Calendar.getInstance();
calendar.add(Field.DAY_OF_YEAR.getCalendarField(), 6);
ClockUtil.setCurrentTime(calendar.getTime());
jobExecutor.start();
// assert task completed for the first engine
waitForJobExecutorToProcessAllJobs(10000, 100, jobExecutor, engine1.getManagementService(), true);
jobExecutor.start();
// assert task completed for the second engine
waitForJobExecutorToProcessAllJobs(10000, 100, jobExecutor, engine2.getManagementService(), true);
Assert.assertEquals(0, engine1.getManagementService().createJobQuery().count());
Assert.assertEquals(0, engine2.getManagementService().createJobQuery().count());
}
use of org.camunda.bpm.engine.impl.cfg.StandaloneInMemProcessEngineConfiguration in project camunda-bpm-platform by camunda.
the class SequentialJobAcquisitionTest method testJobAddedGuardForTwoEnginesSameAcquisition.
@Test
public void testJobAddedGuardForTwoEnginesSameAcquisition() throws InterruptedException {
// configure and build a process engine
StandaloneProcessEngineConfiguration engineConfiguration1 = new StandaloneInMemProcessEngineConfiguration();
engineConfiguration1.setProcessEngineName(getClass().getName() + "-engine1");
engineConfiguration1.setJdbcUrl("jdbc:h2:mem:activiti1");
engineConfiguration1.setJobExecutorActivate(false);
engineConfiguration1.setJobExecutor(jobExecutor);
engineConfiguration1.setDbMetricsReporterActivate(false);
ProcessEngine engine1 = engineConfiguration1.buildProcessEngine();
createdProcessEngines.add(engine1);
// and a second one
StandaloneProcessEngineConfiguration engineConfiguration2 = new StandaloneInMemProcessEngineConfiguration();
engineConfiguration2.setProcessEngineName(getClass().getName() + "engine2");
engineConfiguration2.setJdbcUrl("jdbc:h2:mem:activiti2");
engineConfiguration2.setJobExecutorActivate(false);
engineConfiguration2.setJobExecutor(jobExecutor);
engineConfiguration2.setDbMetricsReporterActivate(false);
ProcessEngine engine2 = engineConfiguration2.buildProcessEngine();
createdProcessEngines.add(engine2);
// stop the acquisition
jobExecutor.shutdown();
// deploy the processes
engine1.getRepositoryService().createDeployment().addClasspathResource(PROCESS_RESOURCE).deploy();
engine2.getRepositoryService().createDeployment().addClasspathResource(PROCESS_RESOURCE).deploy();
// start one instance for each engine:
engine1.getRuntimeService().startProcessInstanceByKey("intermediateTimerEventExample");
engine2.getRuntimeService().startProcessInstanceByKey("intermediateTimerEventExample");
Calendar calendar = Calendar.getInstance();
calendar.add(Field.DAY_OF_YEAR.getCalendarField(), 6);
ClockUtil.setCurrentTime(calendar.getTime());
Assert.assertEquals(1, engine1.getManagementService().createJobQuery().count());
Assert.assertEquals(1, engine2.getManagementService().createJobQuery().count());
// assert task completed for the first engine
jobExecutor.start();
waitForJobExecutorToProcessAllJobs(10000, 100, jobExecutor, engine1.getManagementService(), false);
// assert task completed for the second engine
jobExecutor.start();
waitForJobExecutorToProcessAllJobs(10000, 100, jobExecutor, engine2.getManagementService(), false);
Thread.sleep(2000);
Assert.assertFalse(((SequentialJobAcquisitionRunnable) jobExecutor.getAcquireJobsRunnable()).isJobAdded());
Assert.assertEquals(0, engine1.getManagementService().createJobQuery().count());
Assert.assertEquals(0, engine2.getManagementService().createJobQuery().count());
}
use of org.camunda.bpm.engine.impl.cfg.StandaloneInMemProcessEngineConfiguration in project camunda-bpm-platform by camunda.
the class DetermineHistoryLevelCmdTest method config.
private static ProcessEngineConfigurationImpl config(final String schemaUpdate, final String historyLevel) {
StandaloneInMemProcessEngineConfiguration engineConfiguration = new StandaloneInMemProcessEngineConfiguration();
engineConfiguration.setProcessEngineName(UUID.randomUUID().toString());
engineConfiguration.setDatabaseSchemaUpdate(schemaUpdate);
engineConfiguration.setHistory(historyLevel);
engineConfiguration.setDbMetricsReporterActivate(false);
engineConfiguration.setJdbcUrl("jdbc:h2:mem:DatabaseHistoryPropertyAutoTest");
return engineConfiguration;
}
Aggregations