Java Code Examples for org.camunda.bpm.engine.impl.cfg.StandaloneInMemProcessEngineConfiguration#buildProcessEngine()

The following examples show how to use org.camunda.bpm.engine.impl.cfg.StandaloneInMemProcessEngineConfiguration#buildProcessEngine() . 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: StandaloneDebugWebsocketBootstrap.java    From camunda-bpm-workbench with GNU Affero General Public License v3.0 6 votes vote down vote up
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 2
Source File: TelemetryConfigurationTest.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
@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 3
Source File: DmnDisabledTest.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
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 4
Source File: DatabaseTableSchemaTest.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
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 5
Source File: DatabaseTableSchemaTest.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
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 6
Source File: TelemetryConfigurationTest.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
@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 7
Source File: TelemetryConfigurationTest.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
@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 8
Source File: TelemetryConfigurationTest.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
@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: CamundaEngineHelper.java    From flowing-retail-old with Apache License 2.0 4 votes vote down vote up
public static ProcessEngine startUpEngineAndInit() {
  Server h2Server = null;

  StandaloneInMemProcessEngineConfiguration config = new StandaloneInMemProcessEngineConfiguration();
  config.setHistoryLevel(HistoryLevel.HISTORY_LEVEL_FULL);
  config.setJdbcUsername("sa");
  config.setJdbcPassword("sa");

  // if the DB was already started (by another engine in another Microservice)
  // connect to this DB instead of starting an own one
  if (isH2DbAlreadyRunning()) {
    config.setJdbcUrl(h2DbJdbcUrl);
    config.setDatabaseSchemaUpdate("false");
  } else {
    // use in memory DB, but expose as server
    config.setJdbcUrl(h2DbServerJdbcUrl);
    h2Server = startH2Server();
  }
  ProcessEngine engine = config.buildProcessEngine();

  // create Demo users and add enterprise license (if existent in file
  // ~/.camunda/build.properties)
  LicenseHelper.setLicense(engine);
  UserGenerator.createDefaultUsers(engine);
      
  final Server h2 = h2Server;
  Runtime.getRuntime().addShutdownHook(new Thread() {
    @Override
    public void run() {
      try {
        engine.close();
        if (h2!=null) {
          h2.stop();
        }
      } catch (Exception e) {
        throw new RuntimeException("Could not disconnect: " + e.getMessage(), e);
      }
    }
  });
  
  return engine;
}
 
Example 10
Source File: CamundaEngineHelper.java    From flowing-retail-old with Apache License 2.0 4 votes vote down vote up
public static ProcessEngine startUpEngineAndInit() {
  Server h2Server = null;

  StandaloneInMemProcessEngineConfiguration config = new StandaloneInMemProcessEngineConfiguration();
  config.setHistoryLevel(HistoryLevel.HISTORY_LEVEL_FULL);
  config.setJdbcUsername("sa");
  config.setJdbcPassword("sa");

  // if the DB was already started (by another engine in another Microservice)
  // connect to this DB instead of starting an own one
  if (isH2DbAlreadyRunning()) {
    config.setJdbcUrl(h2DbJdbcUrl);
    config.setDatabaseSchemaUpdate("false");
  } else {
    // use in memory DB, but expose as server
    config.setJdbcUrl(h2DbServerJdbcUrl);
    h2Server = startH2Server();
  }
  ProcessEngine engine = config.buildProcessEngine();

  // create Demo users and add enterprise license (if existent in file
  // ~/.camunda/build.properties)
  LicenseHelper.setLicense(engine);
  UserGenerator.createDefaultUsers(engine);
      
  final Server h2 = h2Server;
  Runtime.getRuntime().addShutdownHook(new Thread() {
    @Override
    public void run() {
      try {
        engine.close();
        if (h2!=null) {
          h2.stop();
        }
      } catch (Exception e) {
        throw new RuntimeException("Could not disconnect: " + e.getMessage(), e);
      }
    }
  });
  
  return engine;
}
 
Example 11
Source File: MultiEngineCommandContextTest.java    From camunda-bpm-platform with Apache License 2.0 4 votes vote down vote up
private ProcessEngine createProcessEngine(String name) {
  StandaloneInMemProcessEngineConfiguration processEngineConfiguration = new StandaloneInMemProcessEngineConfiguration();
  processEngineConfiguration.setProcessEngineName(name);
  processEngineConfiguration.setJdbcUrl(String.format("jdbc:h2:mem:%s", name));
  return processEngineConfiguration.buildProcessEngine();
}