public void shutdown() { jobExecutor.shutdown(); }
public void shutdown() { jobExecutor.shutdown(); }
public synchronized void unregisterProcessEngine(ProcessEngineImpl processEngine) { processEngines.remove(processEngine); // if we unregister the last process engine, auto-shutdown the jobexecutor if(processEngines.isEmpty() && isActive) { shutdown(); } }
public synchronized void unregisterProcessEngine(ProcessEngineImpl processEngine) { processEngines.remove(processEngine); // if we unregister the last process engine, auto-shutdown the jobexecutor if(processEngines.isEmpty() && isActive) { shutdown(); } }
@After public void tearDown() { jobExecutor.shutdown(); }
@After public void stopJobExecutor() { jobExecutor.shutdown(); }
public static void waitForJobExecutorToProcessAllJobs(ProcessEngineConfigurationImpl processEngineConfiguration, long maxMillisToWait, long intervalMillis) { JobExecutor jobExecutor = processEngineConfiguration.getJobExecutor(); jobExecutor.start(); try { Timer timer = new Timer(); InteruptTask task = new InteruptTask(Thread.currentThread()); timer.schedule(task, maxMillisToWait); boolean areJobsAvailable = true; try { while (areJobsAvailable && !task.isTimeLimitExceeded()) { Thread.sleep(intervalMillis); areJobsAvailable = areJobsAvailable(processEngineConfiguration); } } catch (InterruptedException e) { } finally { timer.cancel(); } if (areJobsAvailable) { throw new ProcessEngineException("time limit of " + maxMillisToWait + " was exceeded"); } } finally { jobExecutor.shutdown(); } }
public static void waitForJobExecutorToProcessAllJobs(ProcessEngineConfigurationImpl processEngineConfiguration, long maxMillisToWait, long intervalMillis) { JobExecutor jobExecutor = processEngineConfiguration.getJobExecutor(); jobExecutor.start(); try { Timer timer = new Timer(); InteruptTask task = new InteruptTask(Thread.currentThread()); timer.schedule(task, maxMillisToWait); boolean areJobsAvailable = true; try { while (areJobsAvailable && !task.isTimeLimitExceeded()) { Thread.sleep(intervalMillis); areJobsAvailable = areJobsAvailable(processEngineConfiguration); } } catch (InterruptedException e) { } finally { timer.cancel(); } if (areJobsAvailable) { throw new ProcessEngineException("time limit of " + maxMillisToWait + " was exceeded"); } } finally { jobExecutor.shutdown(); } }
public void waitForJobExecutorOnCondition(long maxMillisToWait, Callable<Boolean> condition) { JobExecutor jobExecutor = processEngineConfiguration.getJobExecutor(); jobExecutor.start(); long intervalMillis = 500; if(maxMillisToWait < (jobExecutor.getWaitTimeInMillis()*2)) { maxMillisToWait = (jobExecutor.getWaitTimeInMillis()*2); } try { Timer timer = new Timer(); InterruptTask task = new InterruptTask(Thread.currentThread()); timer.schedule(task, maxMillisToWait); boolean conditionIsViolated = true; try { while (conditionIsViolated && !task.isTimeLimitExceeded()) { Thread.sleep(intervalMillis); conditionIsViolated = !condition.call(); } } catch (InterruptedException e) { } catch (Exception e) { throw new ProcessEngineException("Exception while waiting on condition: "+e.getMessage(), e); } finally { timer.cancel(); } if (conditionIsViolated) { throw new ProcessEngineException("time limit of " + maxMillisToWait + " was exceeded"); } } finally { jobExecutor.shutdown(); } }
public void waitForJobExecutorOnCondition(long maxMillisToWait, Callable<Boolean> condition) { JobExecutor jobExecutor = processEngineConfiguration.getJobExecutor(); jobExecutor.start(); long intervalMillis = 500; if(maxMillisToWait < (jobExecutor.getWaitTimeInMillis()*2)) { maxMillisToWait = (jobExecutor.getWaitTimeInMillis()*2); } try { Timer timer = new Timer(); InterruptTask task = new InterruptTask(Thread.currentThread()); timer.schedule(task, maxMillisToWait); boolean conditionIsViolated = true; try { while (conditionIsViolated && !task.isTimeLimitExceeded()) { Thread.sleep(intervalMillis); conditionIsViolated = !condition.call(); } } catch (InterruptedException e) { } catch (Exception e) { throw new ProcessEngineException("Exception while waiting on condition: "+e.getMessage(), e); } finally { timer.cancel(); } if (conditionIsViolated) { throw new ProcessEngineException("time limit of " + maxMillisToWait + " was exceeded"); } } finally { jobExecutor.shutdown(); } }
jobExecutor.shutdown();
jobExecutor.shutdown();
private void moveByHours(int hours) throws Exception { ClockUtil.setCurrentTime(new Date(ClockUtil.getCurrentTime().getTime() + ((hours * 60 * 1000 * 60) + 5000))); JobExecutor jobExecutor = processEngineConfiguration.getJobExecutor(); jobExecutor.start(); Thread.sleep(1000); jobExecutor.shutdown(); }
public void waitForJobExecutorToProcessAllJobs(long maxMillisToWait, long intervalMillis, JobExecutor jobExecutor, ManagementService managementService, boolean shutdown) { try { Timer timer = new Timer(); InteruptTask task = new InteruptTask(Thread.currentThread()); timer.schedule(task, maxMillisToWait); boolean areJobsAvailable = true; try { while (areJobsAvailable && !task.isTimeLimitExceeded()) { Thread.sleep(intervalMillis); areJobsAvailable = areJobsAvailable(managementService); } } catch (InterruptedException e) { } finally { timer.cancel(); } if (areJobsAvailable) { throw new ProcessEngineException("time limit of " + maxMillisToWait + " was exceeded"); } } finally { if (shutdown) { jobExecutor.shutdown(); } } }
public void waitForJobExecutorToProcessAllJobs(JobExecutor jobExecutor, long maxMillisToWait) { int checkInterval = 1000; jobExecutor.start(); try { Timer timer = new Timer(); InterruptTask task = new InterruptTask(Thread.currentThread()); timer.schedule(task, maxMillisToWait); boolean areJobsAvailable = true; try { while (areJobsAvailable && !task.isTimeLimitExceeded()) { Thread.sleep(checkInterval); areJobsAvailable = areJobsAvailable(); } } catch (InterruptedException e) { } finally { timer.cancel(); } if (areJobsAvailable) { throw new RuntimeException("time limit of " + maxMillisToWait + " was exceeded (still " + numberOfJobsAvailable() + " jobs available)"); } } finally { jobExecutor.shutdown(); } }
jobExecutor.shutdown();
@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()); }
@Before public void setupBeforeTest() { processEngineService = BpmPlatform.getProcessEngineService(); processEngine = processEngineService.getDefaultProcessEngine(); processEngineConfiguration = ((ProcessEngineImpl)processEngine).getProcessEngineConfiguration(); processEngineConfiguration.getJobExecutor().shutdown(); // make sure the job executor is down formService = processEngine.getFormService(); historyService = processEngine.getHistoryService(); identityService = processEngine.getIdentityService(); managementService = processEngine.getManagementService(); repositoryService = processEngine.getRepositoryService(); runtimeService = processEngine.getRuntimeService(); taskService = processEngine.getTaskService(); caseService = processEngine.getCaseService(); decisionService = processEngine.getDecisionService(); }
jobExecutor.shutdown();
jobExecutor.shutdown();