snippets/dynamic-multi-tenancy/tenantdemo-shared-lib/src/main/java/com/camunda/demo/tenant/manager/TenantManager.java
private ProcessEngine startProcessEngine(String tenant) {
    ProcessEngineConfigurationImpl configuration = new StandaloneProcessEngineConfiguration();
    configuration.setIdGenerator(new StrongUuidGenerator());

    configureCustomRetryStrategy(configuration);

    configuration.setProcessEngineName(tenant);

    configuration.setJdbcDriver("org.h2.Driver");
    configuration.setJdbcUrl("jdbc:h2:./camunda-h2-dbs/process-engine-" + tenant + ";MVCC=TRUE;TRACE_LEVEL_FILE=0;DB_CLOSE_ON_EXIT=FALSE");
    configuration.setDatabaseSchemaUpdate(StandaloneProcessEngineConfiguration.DB_SCHEMA_UPDATE_TRUE);
    // configuration.setDataSourceJndiName("jdbc/ProcessEngine-"+tenant);
    configuration.setJobExecutorDeploymentAware(true);
    configuration.setHistory(StandaloneProcessEngineConfiguration.HISTORY_FULL);

    // instantiate plugins:
    // * <plugins> <!-- plugin enabling Process Application event listener
    // support
    // * --> <plugin> <class>org.camunda.bpm.application.impl.event.
    // * ProcessApplicationEventListenerPlugin</class> </plugin> </plugins>
    // */
    // configurePlugins(configuration, processEngineXml, classLoader);

    JobExecutor jobExecutor = getServiceContainer().getServiceValue(ServiceTypes.JOB_EXECUTOR, jobAcquisitionName);
    if (jobExecutor == null) {
      throw new ProcessEngineException("Cannot find referenced job executor with name '" + jobAcquisitionName + "'");
    }

    // set JobExecutor on process engine
    configuration.setJobExecutor(jobExecutor);

    ProcessEngine processEngine = configuration.buildProcessEngine();

    // start the process engine inside the container.
    RuntimeContainerDelegate.INSTANCE.get().registerProcessEngine(processEngine);

    return processEngine;
  }
private ProcessEngine startProcessEngine(String tenant) {
    ProcessEngineConfigurationImpl configuration = new StandaloneProcessEngineConfiguration();
    configuration.setIdGenerator(new StrongUuidGenerator());

    configureCustomRetryStrategy(configuration);

    configuration.setProcessEngineName(tenant);

    configuration.setJdbcDriver("org.h2.Driver");
    configuration.setJdbcUrl("jdbc:h2:./camunda-h2-dbs/process-engine-" + tenant + ";MVCC=TRUE;TRACE_LEVEL_FILE=0;DB_CLOSE_ON_EXIT=FALSE");
    configuration.setDatabaseSchemaUpdate(StandaloneProcessEngineConfiguration.DB_SCHEMA_UPDATE_TRUE);
    // configuration.setDataSourceJndiName("jdbc/ProcessEngine-"+tenant);
    configuration.setJobExecutorDeploymentAware(true);
    configuration.setHistory(StandaloneProcessEngineConfiguration.HISTORY_FULL);

    // instantiate plugins:
    // * <plugins> <!-- plugin enabling Process Application event listener
    // support
    // * --> <plugin> <class>org.camunda.bpm.application.impl.event.
    // * ProcessApplicationEventListenerPlugin</class> </plugin> </plugins>
    // */
    // configurePlugins(configuration, processEngineXml, classLoader);

    JobExecutor jobExecutor = getServiceContainer().getServiceValue(ServiceTypes.JOB_EXECUTOR, jobAcquisitionName);
    if (jobExecutor == null) {
      throw new ProcessEngineException("Cannot find referenced job executor with name '" + jobAcquisitionName + "'");
    }

    // set JobExecutor on process engine
    configuration.setJobExecutor(jobExecutor);

    ProcessEngine processEngine = configuration.buildProcessEngine();

    // start the process engine inside the container.
    RuntimeContainerDelegate.INSTANCE.get().registerProcessEngine(processEngine);

    return processEngine;
  }
private ProcessEngine startProcessEngine ( String tenant ) { ProcessEngineConfigurationImpl configuration = new StandaloneProcessEngineConfiguration ( ) ; configuration . setIdGenerator ( new StrongUuidGenerator ( ) ) ; configureCustomRetryStrategy ( configuration ) ; configuration . setProcessEngineName ( tenant ) ; configuration . setJdbcDriver ( "org.h2.Driver" ) ; configuration . setJdbcUrl ( "jdbc:h2:./camunda-h2-dbs/process-engine-" + tenant + ";MVCC=TRUE;TRACE_LEVEL_FILE=0;DB_CLOSE_ON_EXIT=FALSE" ) ; configuration . setDatabaseSchemaUpdate ( StandaloneProcessEngineConfiguration . DB_SCHEMA_UPDATE_TRUE ) ; // configuration.setDataSourceJndiName("jdbc/ProcessEngine-"+tenant); configuration . setJobExecutorDeploymentAware ( true ) ; configuration . setHistory ( StandaloneProcessEngineConfiguration . HISTORY_FULL ) ; // instantiate plugins: // * <plugins> <!-- plugin enabling Process Application event listener // support // * --> <plugin> <class>org.camunda.bpm.application.impl.event. // * ProcessApplicationEventListenerPlugin</class> </plugin> </plugins> // */ // configurePlugins(configuration, processEngineXml, classLoader); JobExecutor jobExecutor = getServiceContainer ( ) . getServiceValue ( ServiceTypes . JOB_EXECUTOR , jobAcquisitionName ) ; if ( jobExecutor == null ) { throw new ProcessEngineException ( "Cannot find referenced job executor with name '" + jobAcquisitionName + "'" ) ; } // set JobExecutor on process engine configuration . setJobExecutor ( jobExecutor ) ; ProcessEngine processEngine = configuration . buildProcessEngine ( ) ; // start the process engine inside the container. RuntimeContainerDelegate . INSTANCE . get ( ) . registerProcessEngine ( processEngine ) ; return processEngine ; }
}
}