Java Code Examples for org.camunda.bpm.engine.ProcessEngineConfiguration#createStandaloneInMemProcessEngineConfiguration()

The following examples show how to use org.camunda.bpm.engine.ProcessEngineConfiguration#createStandaloneInMemProcessEngineConfiguration() . 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: HistoryCleanupOnEngineBootstrapTest.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
@Test
public void testHistoryCleanupJobScheduled() throws ParseException {

  final ProcessEngineConfigurationImpl standaloneInMemProcessEngineConfiguration = (ProcessEngineConfigurationImpl)ProcessEngineConfiguration.createStandaloneInMemProcessEngineConfiguration();
  standaloneInMemProcessEngineConfiguration.setHistoryCleanupBatchWindowStartTime("23:00");
  standaloneInMemProcessEngineConfiguration.setHistoryCleanupBatchWindowEndTime("01:00");
  standaloneInMemProcessEngineConfiguration.setJdbcUrl("jdbc:h2:mem:camunda" + getClass().getSimpleName() + "testHistoryCleanupJobScheduled");

  ProcessEngine engine = standaloneInMemProcessEngineConfiguration
    .buildProcessEngine();

  try {
    final List<Job> historyCleanupJobs = engine.getHistoryService().findHistoryCleanupJobs();
    assertFalse(historyCleanupJobs.isEmpty());
    final ProcessEngineConfigurationImpl processEngineConfiguration = (ProcessEngineConfigurationImpl) engine.getProcessEngineConfiguration();
    for (Job historyCleanupJob : historyCleanupJobs) {
      assertEquals(processEngineConfiguration.getBatchWindowManager().getCurrentOrNextBatchWindow(ClockUtil.getCurrentTime(), processEngineConfiguration).getStart(), historyCleanupJob.getDuedate());
    }
  } finally {
    closeProcessEngine(engine);
  }
}
 
Example 2
Source File: HistoryCleanupOnEngineBootstrapTest.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
@Test
public void shouldCreateHistoryCleanupJobLogs() {

  final ProcessEngineConfigurationImpl standaloneInMemProcessEngineConfiguration =
      (ProcessEngineConfigurationImpl)ProcessEngineConfiguration
          .createStandaloneInMemProcessEngineConfiguration();
  standaloneInMemProcessEngineConfiguration.setHistoryCleanupBatchWindowStartTime("23:00");
  standaloneInMemProcessEngineConfiguration.setHistoryCleanupBatchWindowEndTime("01:00");
  standaloneInMemProcessEngineConfiguration
      .setJdbcUrl("jdbc:h2:mem:camunda" + getClass().getSimpleName() + "testHistoryCleanupJobScheduled");

  ProcessEngine engine = standaloneInMemProcessEngineConfiguration.buildProcessEngine();
  try {
    List<HistoricJobLog> historicJobLogs = engine.getHistoryService()
                                                 .createHistoricJobLogQuery()
                                                 .jobDefinitionType(HistoryCleanupJobHandler.TYPE)
                                                 .list();
    for (HistoricJobLog historicJobLog : historicJobLogs) {
      assertNotNull(historicJobLog.getHostname());
    }
  } finally {
    closeProcessEngine(engine);
  }
}
 
Example 3
Source File: HostnameProviderTest.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
@Before
public void setUp() {
  configuration =
      (ProcessEngineConfigurationImpl) ProcessEngineConfiguration
          .createStandaloneInMemProcessEngineConfiguration();

  configuration
      .setJdbcUrl("jdbc:h2:mem:camunda" + getClass().getSimpleName() + "testHostnameProvider")
      .setProcessEngineName(ENGINE_NAME)
      .setHostname(hostname)
      .setHostnameProvider(hostnameProvider)
      .setMetricsReporterIdProvider(reporterProvider);

  engine = configuration.buildProcessEngine();
  configuration.getMetricsRegistry().markOccurrence("TEST", 1L);
  configuration.getDbMetricsReporter().reportNow();

  managementService = configuration.getManagementService();
}
 
Example 4
Source File: HistoryCleanupOnEngineBootstrapTest.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
@Test
public void testBatchWindowOneDayOfWeek() throws ParseException {
  ClockUtil.setCurrentTime(sdf.parse("2018-05-14T22:00:00"));       //monday
  //given
  final ProcessEngineConfigurationImpl configuration = (ProcessEngineConfigurationImpl)ProcessEngineConfiguration.createStandaloneInMemProcessEngineConfiguration();
  //we have batch window only once per week - Monday afternoon
  configuration.getHistoryCleanupBatchWindows().put(Calendar.MONDAY, new BatchWindowConfiguration("18:00", "20:00"));
  configuration.setJdbcUrl("jdbc:h2:mem:camunda" + getClass().getSimpleName() + "testBatchWindowOneDayOfWeek");

  //when
  //we're on Monday evening
  //and we bootstrap the engine
  ProcessEngine engine = configuration.buildProcessEngine();

  //then
  //job is scheduled for next week Monday
  List<Job> historyCleanupJobs = engine.getHistoryService().findHistoryCleanupJobs();
  assertFalse(historyCleanupJobs.isEmpty());
  assertEquals(1, historyCleanupJobs.size());
  assertEquals(sdf.parse("2018-05-21T18:00:00"), historyCleanupJobs.get(0).getDuedate());     //monday next week
  assertEquals(false, historyCleanupJobs.get(0).isSuspended());

  //when
  //we're on Monday evening next week, right aftre the end of batch window
  ClockUtil.setCurrentTime(sdf.parse("2018-05-21T20:00:01"));       //monday
  //we force history job to be rescheduled
  engine.getManagementService().executeJob(historyCleanupJobs.get(0).getId());

  //then
  //job is scheduled for next week Monday
  historyCleanupJobs = engine.getHistoryService().findHistoryCleanupJobs();
  assertFalse(historyCleanupJobs.isEmpty());
  assertEquals(1, historyCleanupJobs.size());
  assertEquals(sdf.parse("2018-05-28T18:00:00"), historyCleanupJobs.get(0).getDuedate());     //monday next week
  assertEquals(false, historyCleanupJobs.get(0).isSuspended());

  closeProcessEngine(engine);
}
 
Example 5
Source File: HistoryCleanupOnEngineBootstrapTest.java    From camunda-bpm-platform with Apache License 2.0 4 votes vote down vote up
@Test
public void testBatchWindow24Hours() throws ParseException {
  //given
  final ProcessEngineConfigurationImpl configuration = (ProcessEngineConfigurationImpl)ProcessEngineConfiguration.createStandaloneInMemProcessEngineConfiguration();
  //we have batch window for 24 hours
  configuration.getHistoryCleanupBatchWindows().put(Calendar.MONDAY, new BatchWindowConfiguration("06:00", "06:00"));
  configuration.setJdbcUrl("jdbc:h2:mem:camunda" + getClass().getSimpleName() + "testBatchWindow24Hours");

  //when
  //we're on Monday early morning
  ClockUtil.setCurrentTime(sdf.parse("2018-05-14T05:00:00"));       //monday
  //and we bootstrap the engine
  ProcessEngine engine = configuration.buildProcessEngine();

  //then
  //job is scheduled for Monday 06 AM
  List<Job> historyCleanupJobs = engine.getHistoryService().findHistoryCleanupJobs();
  assertFalse(historyCleanupJobs.isEmpty());
  assertEquals(1, historyCleanupJobs.size());
  assertEquals(sdf.parse("2018-05-14T06:00:00"), historyCleanupJobs.get(0).getDuedate());
  assertEquals(false, historyCleanupJobs.get(0).isSuspended());

  //when
  //we're on Monday afternoon
  ClockUtil.setCurrentTime(sdf.parse("2018-05-14T15:00:00"));
  //we force history job to be rescheduled
  engine.getManagementService().executeJob(historyCleanupJobs.get(0).getId());

  //then
  //job is still within current batch window
  historyCleanupJobs = engine.getHistoryService().findHistoryCleanupJobs();
  assertFalse(historyCleanupJobs.isEmpty());
  assertEquals(1, historyCleanupJobs.size());
  assertTrue(sdf.parse("2018-05-15T06:00:00").after(historyCleanupJobs.get(0).getDuedate()));
  assertEquals(false, historyCleanupJobs.get(0).isSuspended());

  //when
  //we're on Tuesday early morning close to the end of batch window
  ClockUtil.setCurrentTime(sdf.parse("2018-05-15T05:59:00"));
  //we force history job to be rescheduled
  engine.getManagementService().executeJob(historyCleanupJobs.get(0).getId());

  //then
  //job is still within current batch window
  historyCleanupJobs = engine.getHistoryService().findHistoryCleanupJobs();
  assertFalse(historyCleanupJobs.isEmpty());
  assertEquals(1, historyCleanupJobs.size());
  assertTrue(sdf.parse("2018-05-15T06:00:00").after(historyCleanupJobs.get(0).getDuedate()));
  assertEquals(false, historyCleanupJobs.get(0).isSuspended());

  //when
  //we're on Tuesday early morning shortly after the end of batch window
  ClockUtil.setCurrentTime(sdf.parse("2018-05-15T06:01:00"));
  //we force history job to be rescheduled
  engine.getManagementService().executeJob(historyCleanupJobs.get(0).getId());

  //then
  //job is rescheduled till next Monday
  historyCleanupJobs = engine.getHistoryService().findHistoryCleanupJobs();
  assertFalse(historyCleanupJobs.isEmpty());
  assertEquals(1, historyCleanupJobs.size());
  assertEquals(sdf.parse("2018-05-21T06:00:00"), historyCleanupJobs.get(0).getDuedate());
  assertEquals(false, historyCleanupJobs.get(0).isSuspended());

  closeProcessEngine(engine);
}
 
Example 6
Source File: JobExecutorTest.java    From camunda-bpm-platform with Apache License 2.0 4 votes vote down vote up
public void testJobExecutorHintConfiguration() {
  ProcessEngineConfiguration engineConfig1 =
      ProcessEngineConfiguration.createStandaloneInMemProcessEngineConfiguration();

  assertTrue("default setting is true", engineConfig1.isHintJobExecutor());

  ProcessEngineConfiguration engineConfig2 =
      ProcessEngineConfiguration.createStandaloneInMemProcessEngineConfiguration().setHintJobExecutor(false);

  assertFalse(engineConfig2.isHintJobExecutor());

  ProcessEngineConfiguration engineConfig3 =
      ProcessEngineConfiguration.createStandaloneInMemProcessEngineConfiguration().setHintJobExecutor(true);

  assertTrue(engineConfig3.isHintJobExecutor());
}