org.camunda.bpm.engine.impl.cfg.StandaloneInMemProcessEngineConfiguration Java Examples
The following examples show how to use
org.camunda.bpm.engine.impl.cfg.StandaloneInMemProcessEngineConfiguration.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: TelemetryConfigurationTest.java From camunda-bpm-platform with Apache License 2.0 | 6 votes |
@Test @WatchLogger(loggerNames = {"org.camunda.bpm.engine.persistence"}, level = "DEBUG") public void shouldLogTelemetryPersistenceLog() { // given boolean telemetryInitialized = true; processEngineConfiguration = new StandaloneInMemProcessEngineConfiguration(); processEngineConfiguration .setInitializeTelemetry(telemetryInitialized) .setJdbcUrl("jdbc:h2:mem:camunda" + getClass().getSimpleName()); // when processEngineConfiguration.buildProcessEngine(); // then assertThat(loggingRule.getFilteredLog("No telemetry property found in the database").size()).isOne(); assertThat(loggingRule.getFilteredLog("Creating the telemetry property in database with the value: " + telemetryInitialized).size()).isOne(); }
Example #2
Source File: StandaloneDebugWebsocketBootstrap.java From camunda-bpm-workbench with GNU Affero General Public License v3.0 | 6 votes |
public static void main(String[] args) { // start process engine StandaloneInMemProcessEngineConfiguration processEngineConfiguration = new StandaloneInMemProcessEngineConfiguration(); processEngineConfiguration.setProcessEngineName(ProcessEngines.NAME_DEFAULT); // add plugins List<ProcessEnginePlugin> processEnginePlugins = processEngineConfiguration.getProcessEnginePlugins(); processEnginePlugins.add(new DebuggerPlugin()); processEnginePlugins.add(new SpinProcessEnginePlugin()); processEnginePlugins.add(new ConnectProcessEnginePlugin()); processEngineConfiguration.buildProcessEngine(); DebugSessionFactory.getInstance().setSuspend(false); // start debug server DebugWebsocket debugWebsocket = null; try { // configure & start the server debugWebsocket = new DebugWebsocketConfiguration() .port(9090) .startServer(); // block debugWebsocket.waitForShutdown(); } finally { if(debugWebsocket != null) { debugWebsocket.shutdown(); } } }
Example #3
Source File: ForceCloseMybatisConnectionPoolTest.java From camunda-bpm-platform with Apache License 2.0 | 6 votes |
@Test public void testForceCloseMybatisConnectionPoolTrue() { // given // that the process engine is configured with forceCloseMybatisConnectionPool = true ProcessEngineConfigurationImpl configurationImpl = new StandaloneInMemProcessEngineConfiguration() .setJdbcUrl("jdbc:h2:mem:camunda-forceclose") .setProcessEngineName("engine-forceclose") .setForceCloseMybatisConnectionPool(true); ProcessEngine processEngine = configurationImpl .buildProcessEngine(); PooledDataSource pooledDataSource = (PooledDataSource) configurationImpl.getDataSource(); PoolState state = pooledDataSource.getPoolState(); // then // if the process engine is closed processEngine.close(); // the idle connections are closed Assert.assertTrue(state.getIdleConnectionCount() == 0); }
Example #4
Source File: FallbackSerializerFactoryTest.java From camunda-bpm-platform with Apache License 2.0 | 6 votes |
@Test public void testFallbackSerializer() { // given // that the process engine is configured with a fallback serializer factory ProcessEngineConfigurationImpl engineConfiguration = new StandaloneInMemProcessEngineConfiguration() .setJdbcUrl("jdbc:h2:mem:camunda-forceclose") .setProcessEngineName("engine-forceclose"); engineConfiguration.setFallbackSerializerFactory(new ExampleSerializerFactory()); processEngine = engineConfiguration.buildProcessEngine(); deployOneTaskProcess(processEngine); // when setting a variable that no regular serializer can handle ObjectValue objectValue = Variables.objectValue("foo").serializationDataFormat(ExampleSerializer.FORMAT).create(); ProcessInstance pi = processEngine.getRuntimeService().startProcessInstanceByKey("oneTaskProcess", Variables.createVariables().putValueTyped("var", objectValue)); ObjectValue fetchedValue = processEngine.getRuntimeService().getVariableTyped(pi.getId(), "var", true); // then the fallback serializer is used Assert.assertNotNull(fetchedValue); Assert.assertEquals(ExampleSerializer.FORMAT, fetchedValue.getSerializationDataFormat()); Assert.assertEquals("foo", fetchedValue.getValue()); }
Example #5
Source File: FallbackSerializerFactoryTest.java From camunda-bpm-platform with Apache License 2.0 | 5 votes |
@Test public void testFallbackSerializerDoesNotOverrideRegularSerializer() { // given // that the process engine is configured with a serializer for a certain format // and a fallback serializer factory for the same format ProcessEngineConfigurationImpl engineConfiguration = new StandaloneInMemProcessEngineConfiguration() .setJdbcUrl("jdbc:h2:mem:camunda-forceclose") .setProcessEngineName("engine-forceclose"); engineConfiguration.setCustomPreVariableSerializers(Arrays.<TypedValueSerializer>asList(new ExampleConstantSerializer())); engineConfiguration.setFallbackSerializerFactory(new ExampleSerializerFactory()); processEngine = engineConfiguration.buildProcessEngine(); deployOneTaskProcess(processEngine); // when setting a variable that no regular serializer can handle ObjectValue objectValue = Variables.objectValue("foo").serializationDataFormat(ExampleSerializer.FORMAT).create(); ProcessInstance pi = processEngine.getRuntimeService().startProcessInstanceByKey("oneTaskProcess", Variables.createVariables().putValueTyped("var", objectValue)); ObjectValue fetchedValue = processEngine.getRuntimeService().getVariableTyped(pi.getId(), "var", true); // then the fallback serializer is used Assert.assertNotNull(fetchedValue); Assert.assertEquals(ExampleSerializer.FORMAT, fetchedValue.getSerializationDataFormat()); Assert.assertEquals(ExampleConstantSerializer.DESERIALIZED_VALUE, fetchedValue.getValue()); }
Example #6
Source File: DetermineHistoryLevelCmdTest.java From camunda-bpm-platform with Apache License 2.0 | 5 votes |
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; }
Example #7
Source File: SequentialJobAcquisitionTest.java From camunda-bpm-platform with Apache License 2.0 | 5 votes |
@Test public void testExecuteJobsForSingleEngine() { // configure and build a process engine StandaloneProcessEngineConfiguration standaloneProcessEngineConfiguration = new StandaloneInMemProcessEngineConfiguration(); standaloneProcessEngineConfiguration.setProcessEngineName(getClass().getName() + "-engine1"); standaloneProcessEngineConfiguration.setJdbcUrl("jdbc:h2:mem:jobexecutor-test-engine"); standaloneProcessEngineConfiguration.setJobExecutorActivate(false); standaloneProcessEngineConfiguration.setJobExecutor(jobExecutor); standaloneProcessEngineConfiguration.setDbMetricsReporterActivate(false); ProcessEngine engine = standaloneProcessEngineConfiguration.buildProcessEngine(); createdProcessEngines.add(engine); engine.getRepositoryService().createDeployment() .addClasspathResource(PROCESS_RESOURCE) .deploy(); jobExecutor.shutdown(); engine.getRuntimeService() .startProcessInstanceByKey("intermediateTimerEventExample"); Assert.assertEquals(1, engine.getManagementService().createJobQuery().count()); Calendar calendar = Calendar.getInstance(); calendar.add(Field.DAY_OF_YEAR.getCalendarField(), 6); ClockUtil.setCurrentTime(calendar.getTime()); jobExecutor.start(); waitForJobExecutorToProcessAllJobs(10000, 100, jobExecutor, engine.getManagementService(), true); Assert.assertEquals(0, engine.getManagementService().createJobQuery().count()); }
Example #8
Source File: TelemetryConfigurationTest.java From camunda-bpm-platform with Apache License 2.0 | 5 votes |
@Test public void shouldStartEngineWithChangedTelemetryEndpoint() { // given String telemetryEndpoint = "http://localhost:8081/pings"; processEngineConfiguration = new StandaloneInMemProcessEngineConfiguration(); processEngineConfiguration .setTelemetryEndpoint(telemetryEndpoint) .setJdbcUrl("jdbc:h2:mem:camunda" + getClass().getSimpleName()); // when processEngineConfiguration.buildProcessEngine(); // then assertThat(processEngineConfiguration.getTelemetryEndpoint()).isEqualTo(telemetryEndpoint); }
Example #9
Source File: TelemetryConfigurationTest.java From camunda-bpm-platform with Apache License 2.0 | 5 votes |
@Test public void shouldStartEngineWithTelemetryEnabled() { // given processEngineConfiguration = new StandaloneInMemProcessEngineConfiguration(); processEngineConfiguration .setInitializeTelemetry(true) .setJdbcUrl("jdbc:h2:mem:camunda" + getClass().getSimpleName()); // when processEngineConfiguration.buildProcessEngine(); // then assertThat(processEngineConfiguration.isInitializeTelemetry()).isTrue(); assertThat(processEngineConfiguration.getManagementService().isTelemetryEnabled()).isTrue(); }
Example #10
Source File: TelemetryConfigurationTest.java From camunda-bpm-platform with Apache License 2.0 | 5 votes |
@Test public void shouldHaveDisabledTelemetryByDefault() { // given processEngineConfiguration = new StandaloneInMemProcessEngineConfiguration(); processEngineConfiguration .setJdbcUrl("jdbc:h2:mem:camunda" + getClass().getSimpleName()); // when processEngineConfiguration.buildProcessEngine(); // then assertThat(processEngineConfiguration.isInitializeTelemetry()).isFalse(); assertThat(processEngineConfiguration.getManagementService().isTelemetryEnabled()).isFalse(); }
Example #11
Source File: ForceCloseMybatisConnectionPoolTest.java From camunda-bpm-platform with Apache License 2.0 | 5 votes |
@Test public void testForceCloseMybatisConnectionPoolFalse() { // given // that the process engine is configured with forceCloseMybatisConnectionPool = false ProcessEngineConfigurationImpl configurationImpl = new StandaloneInMemProcessEngineConfiguration() .setJdbcUrl("jdbc:h2:mem:camunda-forceclose") .setProcessEngineName("engine-forceclose") .setForceCloseMybatisConnectionPool(false); ProcessEngine processEngine = configurationImpl .buildProcessEngine(); PooledDataSource pooledDataSource = (PooledDataSource) configurationImpl.getDataSource(); PoolState state = pooledDataSource.getPoolState(); int idleConnections = state.getIdleConnectionCount(); // then // if the process engine is closed processEngine.close(); // the idle connections are not closed Assert.assertEquals(state.getIdleConnectionCount(), idleConnections); pooledDataSource.forceCloseAll(); Assert.assertTrue(state.getIdleConnectionCount() == 0); }
Example #12
Source File: DatabaseHistoryPropertyAutoTest.java From camunda-bpm-platform with Apache License 2.0 | 5 votes |
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; }
Example #13
Source File: HistoryLevelTest.java From camunda-bpm-platform with Apache License 2.0 | 5 votes |
protected ProcessEngineConfigurationImpl createConfig() { StandaloneInMemProcessEngineConfiguration configuration = new StandaloneInMemProcessEngineConfiguration(); configuration.setProcessEngineName("process-engine-HistoryTest"); configuration.setDbMetricsReporterActivate(false); configuration.setJdbcUrl("jdbc:h2:mem:HistoryTest"); return configuration; }
Example #14
Source File: DatabaseTableSchemaTest.java From camunda-bpm-platform with Apache License 2.0 | 5 votes |
public void testCreateConfigurationWithMissingDotInSchemaAndPrefix() { try { StandaloneInMemProcessEngineConfiguration configuration = new StandaloneInMemProcessEngineConfiguration(); configuration.setDatabaseSchema("foo"); configuration.setDatabaseTablePrefix("foo"); configuration.buildProcessEngine(); fail("Should throw exception"); } catch (ProcessEngineException e) { // as expected assertTrue(e.getMessage().contains("When setting a schema the prefix has to be schema + '.'")); } }
Example #15
Source File: DatabaseTableSchemaTest.java From camunda-bpm-platform with Apache License 2.0 | 5 votes |
public void testCreateConfigurationWithMismatchtingSchemaAndPrefix() { try { StandaloneInMemProcessEngineConfiguration configuration = new StandaloneInMemProcessEngineConfiguration(); configuration.setDatabaseSchema("foo"); configuration.setDatabaseTablePrefix("bar"); configuration.buildProcessEngine(); fail("Should throw exception"); } catch (ProcessEngineException e) { // as expected assertTrue(e.getMessage().contains("When setting a schema the prefix has to be schema + '.'")); } }
Example #16
Source File: DmnDisabledTest.java From camunda-bpm-platform with Apache License 2.0 | 5 votes |
protected static ProcessEngineImpl createProcessEngineImpl(boolean dmnEnabled) { StandaloneInMemProcessEngineConfiguration config = (StandaloneInMemProcessEngineConfiguration) new CustomStandaloneInMemProcessEngineConfiguration() .setProcessEngineName("database-dmn-test-engine") .setDatabaseSchemaUpdate("false") .setHistory(ProcessEngineConfiguration.HISTORY_FULL) .setJdbcUrl("jdbc:h2:mem:DatabaseDmnTest"); config.setDmnEnabled(dmnEnabled); return (ProcessEngineImpl) config.buildProcessEngine(); }
Example #17
Source File: SpringBootProcessEnginePluginTest.java From camunda-bpm-platform with Apache License 2.0 | 5 votes |
@Test public void no_delegate_for_standaloneConfig() throws Exception { ProcessEngineConfigurationImpl c = new StandaloneInMemProcessEngineConfiguration(); DummySpringPlugin plugin = new DummySpringPlugin(); plugin.preInit(c); plugin.postInit(c); assertThat(plugin.preInit).isFalse(); assertThat(plugin.postInit).isFalse(); }
Example #18
Source File: BundleClassloaderAwareProcessEngineControllerTest.java From camunda-bpm-platform-osgi with Apache License 2.0 | 5 votes |
@SuppressWarnings("unchecked") @Test public void stop(){ BundleContext context = mock(BundleContext.class); when(context.getBundle()).thenReturn(mock(Bundle.class)); TestBundleClassloaderAwareProcessEngineController controller = new TestBundleClassloaderAwareProcessEngineController(new StandaloneInMemProcessEngineConfiguration(), context); ServiceRegistration<ProcessEngine> reg = mock(ServiceRegistration.class); controller.setRegistration(reg); controller.stop(null); verify(reg, atLeastOnce()).unregister(); verify(controller.getFactory(), atLeastOnce()).destroy(); }
Example #19
Source File: BundleClassloaderAwareProcessEngineControllerTest.java From camunda-bpm-platform-osgi with Apache License 2.0 | 5 votes |
@SuppressWarnings("unchecked") @Test public void start(){ BundleContext context = mock(BundleContext.class); when(context.getBundle()).thenReturn(mock(Bundle.class)); BundleClassloaderAwareProcessEngineController controller = new TestBundleClassloaderAwareProcessEngineController(new StandaloneInMemProcessEngineConfiguration(), context); controller.start(mock(PlatformServiceContainer.class)); verify(context, atLeastOnce()).registerService(eq(ProcessEngine.class), any(ProcessEngine.class), any(Hashtable.class)); }
Example #20
Source File: OSGiEventBridgeIntegrationTest.java From camunda-bpm-platform-osgi with Apache License 2.0 | 5 votes |
private ProcessEngine createProcessEngine() { StandaloneInMemProcessEngineConfiguration configuration = new StandaloneInMemProcessEngineConfiguration(); configuration.setCustomPreBPMNParseListeners(Collections.<BpmnParseListener> singletonList(eventBridgeActivator)); configuration.setDatabaseSchemaUpdate(ProcessEngineConfiguration.DB_SCHEMA_UPDATE_TRUE); ProcessEngineFactoryWithELResolver engineFactory = new ProcessEngineFactoryWithELResolver(); engineFactory.setProcessEngineConfiguration(configuration); engineFactory.setBundle(bundleContext.getBundle()); engineFactory.setExpressionManager(new OSGiExpressionManager()); engineFactory.init(); return engineFactory.getObject(); }
Example #21
Source File: SpringBootProcessEnginePluginTest.java From camunda-bpm-spring-boot-starter with Apache License 2.0 | 5 votes |
@Test public void no_delegate_for_standaloneConfig() throws Exception { ProcessEngineConfigurationImpl c = new StandaloneInMemProcessEngineConfiguration(); DummySpringPlugin plugin = new DummySpringPlugin(); plugin.preInit(c); plugin.postInit(c); assertThat(plugin.preInit).isFalse(); assertThat(plugin.postInit).isFalse(); }
Example #22
Source File: CamundaReactorTest.java From camunda-bpm-reactor with Apache License 2.0 | 5 votes |
@Test public void fails_to_get_eventBus_from_engine() { ProcessEngine engine = new StandaloneInMemProcessEngineConfiguration(){{ setDatabaseSchemaUpdate(ProcessEngineConfigurationImpl.DB_SCHEMA_UPDATE_DROP_CREATE); }}.buildProcessEngine(); try { thrown.expect(IllegalStateException.class); thrown.expectMessage("No eventBus found. Make sure the Reactor plugin is configured correctly."); CamundaReactor.eventBus(engine); } finally { engine.close(); } }
Example #23
Source File: PlatformJobExecutorActivateTest.java From camunda-bpm-platform with Apache License 2.0 | 5 votes |
private ProcessEngineXmlImpl defineProcessEngine() { ProcessEngineXmlImpl processEngineXml = new ProcessEngineXmlImpl(); HashMap<String, String> properties = new HashMap<String, String>(); properties.put("jdbcUrl", "jdbc:h2:mem:PlatformJobExecutorActivateTest-db"); processEngineXml.setProperties(properties); processEngineXml.setPlugins(new ArrayList<ProcessEnginePluginXml>()); processEngineXml.setName(ENGINE_NAME); processEngineXml.setJobAcquisitionName(ACQUISITION_NAME); processEngineXml.setConfigurationClass(StandaloneInMemProcessEngineConfiguration.class.getName()); processEngineXml.setDefault(true); return processEngineXml; }
Example #24
Source File: SequentialJobAcquisitionTest.java From camunda-bpm-platform with Apache License 2.0 | 4 votes |
@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()); }
Example #25
Source File: ExampleConfiguration.java From camunda-bpm-platform with Apache License 2.0 | 4 votes |
@Bean public ProcessEngineConfiguration processEngineConfiguration() { return new StandaloneInMemProcessEngineConfiguration().setJobExecutorDeploymentAware(true); }
Example #26
Source File: SequentialJobAcquisitionTest.java From camunda-bpm-platform with Apache License 2.0 | 4 votes |
@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()); }
Example #27
Source File: JobPrioritizationBpmnExpressionValueTest.java From camunda-bpm-platform with Apache License 2.0 | 4 votes |
public void testDefaultEngineConfigurationSetting() { ProcessEngineConfigurationImpl config = new StandaloneInMemProcessEngineConfiguration(); assertTrue(config.isEnableGracefulDegradationOnContextSwitchFailure()); }
Example #28
Source File: TripBookingSaga.java From trip-booking-saga-java with Apache License 2.0 | 4 votes |
public static void main(String[] args) { // Configure and startup (in memory) engine ProcessEngine camunda = new StandaloneInMemProcessEngineConfiguration() .buildProcessEngine(); // define saga as BPMN process ProcessBuilder flow = Bpmn.createExecutableProcess("trip"); // - flow of activities and compensating actions flow.startEvent() .serviceTask("car").name("Reserve car").camundaClass(ReserveCarAdapter.class) .boundaryEvent().compensateEventDefinition().compensateEventDefinitionDone() .compensationStart().serviceTask("CancelCar").camundaClass(CancelCarAdapter.class).compensationDone() .serviceTask("hotel").name("Book hotel").camundaClass(BookHotelAdapter.class) .boundaryEvent().compensateEventDefinition().compensateEventDefinitionDone() .compensationStart().serviceTask("CancelHotel").camundaClass(CancelHotelAdapter.class).compensationDone() .serviceTask("flight").name("Book flight").camundaClass(BookFlightAdapter.class) .boundaryEvent().compensateEventDefinition().compensateEventDefinitionDone() .compensationStart().serviceTask("CancelFlight").camundaClass(CancelFlightAdapter.class).compensationDone() .endEvent(); // - trigger compensation in case of any exception (other triggers are possible) flow.eventSubProcess() .startEvent().error("java.lang.Throwable") .intermediateThrowEvent().compensateEventDefinition().compensateEventDefinitionDone() .endEvent(); // ready BpmnModelInstance saga = flow.done(); // optional: Write to file to be able to open it in Camunda Modeler //Bpmn.writeModelToFile(new File("trip.bpmn"), saga); // finish Saga and deploy it to Camunda camunda.getRepositoryService().createDeployment() // .addModelInstance("trip.bpmn", saga) // .deploy(); // now we can start running instances of our saga - its state will be persisted camunda.getRuntimeService().startProcessInstanceByKey("trip", Variables.putValue("name", "trip1")); camunda.getRuntimeService().startProcessInstanceByKey("trip", Variables.putValue("name", "trip2")); }
Example #29
Source File: MultiEngineCommandContextTest.java From camunda-bpm-platform with Apache License 2.0 | 4 votes |
private ProcessEngine createProcessEngine(String name) { StandaloneInMemProcessEngineConfiguration processEngineConfiguration = new StandaloneInMemProcessEngineConfiguration(); processEngineConfiguration.setProcessEngineName(name); processEngineConfiguration.setJdbcUrl(String.format("jdbc:h2:mem:%s", name)); return processEngineConfiguration.buildProcessEngine(); }
Example #30
Source File: RuntimeServiceTest.java From camunda-bpm-platform with Apache License 2.0 | 4 votes |
@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(); }