use of org.jbpm.process.core.timer.impl.QuartzSchedulerService in project jbpm by kiegroup.
the class GlobalTimerServiceVolumeTest method setup.
@Before
public void setup() {
Properties properties = new Properties();
properties.setProperty("mary", "HR");
properties.setProperty("john", "HR");
userGroupCallback = new JBossUserGroupCallbackImpl(properties);
System.setProperty("org.quartz.properties", "quartz-db.properties");
testCreateQuartzSchema();
globalScheduler = new QuartzSchedulerService();
emf = Persistence.createEntityManagerFactory("org.jbpm.test.persistence");
countDownListener = new NodeLeftCountDownProcessEventListener("timer", numberOfProcesses);
// prepare listener to assert results
final List<Long> timerExporations = new ArrayList<Long>();
ProcessEventListener listener = new DefaultProcessEventListener() {
@Override
public void afterNodeLeft(ProcessNodeLeftEvent event) {
if (event.getNodeInstance().getNodeName().equals("timer")) {
timerExporations.add(event.getProcessInstance().getId());
}
}
};
RuntimeEnvironment environment = RuntimeEnvironmentBuilder.Factory.get().newDefaultBuilder().entityManagerFactory(emf).userGroupCallback(userGroupCallback).addAsset(ResourceFactory.newClassPathResource("org/jbpm/test/functional/timer/IntermediateCatchEventTimerCycleWithHT3.bpmn2"), ResourceType.BPMN2).schedulerService(globalScheduler).registerableItemsFactory(new TestRegisterableItemsFactory(listener, countDownListener)).get();
if ("processinstance".equals(strategy)) {
manager = RuntimeManagerFactory.Factory.get().newPerProcessInstanceRuntimeManager(environment, "first");
} else if ("request".equals(strategy)) {
manager = RuntimeManagerFactory.Factory.get().newPerRequestRuntimeManager(environment, "first");
} else if ("case".equals(strategy)) {
manager = RuntimeManagerFactory.Factory.get().newPerCaseRuntimeManager(environment, "first");
} else {
throw new RuntimeException("Unknow type of runtime strategy");
}
}
use of org.jbpm.process.core.timer.impl.QuartzSchedulerService in project jbpm by kiegroup.
the class MultipleTimerServicesTest method cleanup.
@After
public void cleanup() {
System.clearProperty("org.quartz.properties");
((QuartzSchedulerService) globalScheduler1).forceShutdown();
((QuartzSchedulerService) globalScheduler2).forceShutdown();
managerM1.close();
managerM2.close();
EntityManagerFactory emf = ((SimpleRuntimeEnvironment) environmentM1).getEmf();
if (emf != null) {
emf.close();
}
emf = ((SimpleRuntimeEnvironment) environmentM2).getEmf();
if (emf != null && emf.isOpen()) {
emf.close();
}
}
use of org.jbpm.process.core.timer.impl.QuartzSchedulerService in project jbpm by kiegroup.
the class MultipleTimerServicesTest method setup.
@Before
public void setup() {
Collection<String> runtimeManagerIds = RuntimeManagerRegistry.get().getRegisteredIdentifiers();
if (runtimeManagerIds != null) {
for (String id : runtimeManagerIds) {
RuntimeManagerRegistry.get().remove(id);
}
}
System.setProperty("org.quartz.properties", "quartz-db.properties");
testCreateQuartzSchema();
cleanupSingletonSessionId();
emf = Persistence.createEntityManagerFactory("org.jbpm.test.persistence");
emf2 = Persistence.createEntityManagerFactory("org.jbpm.test.persistence");
globalScheduler1 = new QuartzSchedulerService();
globalScheduler2 = new QuartzSchedulerService();
((QuartzSchedulerService) globalScheduler1).forceShutdown();
((QuartzSchedulerService) globalScheduler2).forceShutdown();
}
use of org.jbpm.process.core.timer.impl.QuartzSchedulerService in project jbpm by kiegroup.
the class GlobalQuartzDBTimerServiceTest method setUp.
@Before
public void setUp() {
cleanupSingletonSessionId();
emf = Persistence.createEntityManagerFactory("org.jbpm.test.persistence");
System.setProperty("org.quartz.properties", "quartz-db.properties");
testCreateQuartzSchema();
globalScheduler = new QuartzSchedulerService();
((QuartzSchedulerService) globalScheduler).forceShutdown();
}
use of org.jbpm.process.core.timer.impl.QuartzSchedulerService in project jbpm by kiegroup.
the class GlobalQuartzDBTimerServiceTest method testTimerStartManagerClose.
@Test(timeout = 20000)
public void testTimerStartManagerClose() throws Exception {
NodeLeftCountDownProcessEventListener countDownListener = new NodeLeftCountDownProcessEventListener("StartProcess", 3);
QuartzSchedulerService additionalCopy = new QuartzSchedulerService();
additionalCopy.initScheduler(null);
// prepare listener to assert results
final List<Long> timerExporations = new ArrayList<Long>();
ProcessEventListener listener = new DefaultProcessEventListener() {
@Override
public void beforeProcessStarted(ProcessStartedEvent event) {
timerExporations.add(event.getProcessInstance().getId());
}
};
environment = RuntimeEnvironmentBuilder.Factory.get().newDefaultBuilder().entityManagerFactory(emf).addAsset(ResourceFactory.newClassPathResource("org/jbpm/test/functional/timer/TimerStart2.bpmn2"), ResourceType.BPMN2).schedulerService(globalScheduler).registerableItemsFactory(new TestRegisterableItemsFactory(listener, countDownListener)).get();
manager = getManager(environment, false);
RuntimeEngine runtime = manager.getRuntimeEngine(ProcessInstanceIdContext.get());
KieSession ksession = runtime.getKieSession();
assertEquals(0, timerExporations.size());
countDownListener.waitTillCompleted();
manager.disposeRuntimeEngine(runtime);
int atDispose = timerExporations.size();
assertTrue(atDispose > 0);
((AbstractRuntimeManager) manager).close(true);
countDownListener.reset(1);
countDownListener.waitTillCompleted(3000);
assertEquals(atDispose, timerExporations.size());
additionalCopy.shutdown();
}
Aggregations