Java Code Examples for org.camunda.bpm.engine.impl.cfg.ProcessEngineConfigurationImpl#setDbMetricsReporterActivate()

The following examples show how to use org.camunda.bpm.engine.impl.cfg.ProcessEngineConfigurationImpl#setDbMetricsReporterActivate() . 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: InvoiceProcessApplication.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
/**
 * In a @PostDeploy Hook you can interact with the process engine and access
 * the processes the application has deployed.
 */
@PostDeploy
public void startFirstProcess(ProcessEngine processEngine) {
  createUsers(processEngine);

  //enable metric reporting
  ProcessEngineConfigurationImpl processEngineConfiguration = (ProcessEngineConfigurationImpl) processEngine.getProcessEngineConfiguration();
  processEngineConfiguration.setDbMetricsReporterActivate(true);
  processEngineConfiguration.getDbMetricsReporter().setReporterId("REPORTER");

  startProcessInstances(processEngine, "invoice", 1);
  startProcessInstances(processEngine, "invoice", null);

  //disable reporting
  processEngineConfiguration.setDbMetricsReporterActivate(false);
}
 
Example 2
Source File: DatabaseTableSchemaTest.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
public void testPerformDatabaseSchemaOperationCreateTwice() throws Exception {

    // both process engines will be using this datasource.
    PooledDataSource pooledDataSource = new PooledDataSource(ReflectUtil.getClassLoader(), "org.h2.Driver",
        "jdbc:h2:mem:DatabaseTablePrefixTest;DB_CLOSE_DELAY=1000", "sa", "");

    Connection connection = pooledDataSource.getConnection();
    connection.createStatement().execute("drop schema if exists " + SCHEMA_NAME);
    connection.createStatement().execute("create schema " + SCHEMA_NAME);
    connection.close();

    ProcessEngineConfigurationImpl config1 = createCustomProcessEngineConfiguration().setProcessEngineName("DatabaseTablePrefixTest-engine1")
    // disable auto create/drop schema
        .setDataSource(pooledDataSource).setDatabaseSchemaUpdate("NO_CHECK");
    config1.setDatabaseTablePrefix(SCHEMA_NAME + ".");
    config1.setDatabaseSchema(SCHEMA_NAME);
    config1.setDbMetricsReporterActivate(false);
    ProcessEngine engine1 = config1.buildProcessEngine();

    // create the tables for the first time
    connection = pooledDataSource.getConnection();
    connection.createStatement().execute("set schema " + SCHEMA_NAME);
    engine1.getManagementService().databaseSchemaUpgrade(connection, "", SCHEMA_NAME);
    connection.close();
    // create the tables for the second time; here we shouldn't crash since the
    // session should tell us that the tables are already present and
    // databaseSchemaUpdate is set to noop
    connection = pooledDataSource.getConnection();
    connection.createStatement().execute("set schema " + SCHEMA_NAME);
    engine1.getManagementService().databaseSchemaUpgrade(connection, "", SCHEMA_NAME);
    engine1.close();
  }
 
Example 3
Source File: DatabaseTableSchemaTest.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
public void testTablePresentWithSchemaAndPrefix() throws SQLException {
  PooledDataSource pooledDataSource = new PooledDataSource(ReflectUtil.getClassLoader(), "org.h2.Driver",
      "jdbc:h2:mem:DatabaseTablePrefixTest;DB_CLOSE_DELAY=1000", "sa", "");

  Connection connection = pooledDataSource.getConnection();
  connection.createStatement().execute("drop schema if exists " + SCHEMA_NAME);
  connection.createStatement().execute("create schema " + SCHEMA_NAME);
  connection.createStatement().execute("create table " + SCHEMA_NAME + "." + PREFIX_NAME + "SOME_TABLE(id varchar(64));");
  connection.close();

  ProcessEngineConfigurationImpl config1 = createCustomProcessEngineConfiguration().setProcessEngineName("DatabaseTablePrefixTest-engine1")
  // disable auto create/drop schema
      .setDataSource(pooledDataSource).setDatabaseSchemaUpdate("NO_CHECK");
  config1.setDatabaseTablePrefix(SCHEMA_NAME + "." + PREFIX_NAME);
  config1.setDatabaseSchema(SCHEMA_NAME);
  config1.setDbMetricsReporterActivate(false);
  ProcessEngine engine = config1.buildProcessEngine();
  CommandExecutor commandExecutor = config1.getCommandExecutorTxRequired();

  commandExecutor.execute(new Command<Void>(){
    public Void execute(CommandContext commandContext) {
      DbSqlSession sqlSession = commandContext.getSession(DbSqlSession.class);
      assertTrue(sqlSession.isTablePresent("SOME_TABLE"));
      return null;
    }
  });

  engine.close();

}