Search in sources :

Example 1 with QuartzSchedulerService

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");
    }
}
Also used : RuntimeEnvironment(org.kie.api.runtime.manager.RuntimeEnvironment) QuartzSchedulerService(org.jbpm.process.core.timer.impl.QuartzSchedulerService) JBossUserGroupCallbackImpl(org.jbpm.services.task.identity.JBossUserGroupCallbackImpl) NodeLeftCountDownProcessEventListener(org.jbpm.test.listener.NodeLeftCountDownProcessEventListener) ProcessEventListener(org.kie.api.event.process.ProcessEventListener) DefaultProcessEventListener(org.kie.api.event.process.DefaultProcessEventListener) ArrayList(java.util.ArrayList) Properties(java.util.Properties) NodeLeftCountDownProcessEventListener(org.jbpm.test.listener.NodeLeftCountDownProcessEventListener) DefaultProcessEventListener(org.kie.api.event.process.DefaultProcessEventListener) ProcessNodeLeftEvent(org.kie.api.event.process.ProcessNodeLeftEvent) Before(org.junit.Before)

Example 2 with QuartzSchedulerService

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();
    }
}
Also used : SimpleRuntimeEnvironment(org.jbpm.runtime.manager.impl.SimpleRuntimeEnvironment) QuartzSchedulerService(org.jbpm.process.core.timer.impl.QuartzSchedulerService) EntityManagerFactory(javax.persistence.EntityManagerFactory) After(org.junit.After)

Example 3 with QuartzSchedulerService

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();
}
Also used : QuartzSchedulerService(org.jbpm.process.core.timer.impl.QuartzSchedulerService) Before(org.junit.Before)

Example 4 with QuartzSchedulerService

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();
}
Also used : QuartzSchedulerService(org.jbpm.process.core.timer.impl.QuartzSchedulerService) Before(org.junit.Before)

Example 5 with QuartzSchedulerService

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();
}
Also used : RuntimeEngine(org.kie.api.runtime.manager.RuntimeEngine) QuartzSchedulerService(org.jbpm.process.core.timer.impl.QuartzSchedulerService) ProcessEventListener(org.kie.api.event.process.ProcessEventListener) DefaultProcessEventListener(org.kie.api.event.process.DefaultProcessEventListener) NodeLeftCountDownProcessEventListener(org.jbpm.test.listener.NodeLeftCountDownProcessEventListener) AbstractRuntimeManager(org.jbpm.runtime.manager.impl.AbstractRuntimeManager) ArrayList(java.util.ArrayList) ProcessStartedEvent(org.kie.api.event.process.ProcessStartedEvent) NodeLeftCountDownProcessEventListener(org.jbpm.test.listener.NodeLeftCountDownProcessEventListener) DefaultProcessEventListener(org.kie.api.event.process.DefaultProcessEventListener) KieSession(org.kie.api.runtime.KieSession) Test(org.junit.Test)

Aggregations

QuartzSchedulerService (org.jbpm.process.core.timer.impl.QuartzSchedulerService)6 Before (org.junit.Before)4 ArrayList (java.util.ArrayList)2 NodeLeftCountDownProcessEventListener (org.jbpm.test.listener.NodeLeftCountDownProcessEventListener)2 DefaultProcessEventListener (org.kie.api.event.process.DefaultProcessEventListener)2 ProcessEventListener (org.kie.api.event.process.ProcessEventListener)2 Properties (java.util.Properties)1 EntityManagerFactory (javax.persistence.EntityManagerFactory)1 AbstractRuntimeManager (org.jbpm.runtime.manager.impl.AbstractRuntimeManager)1 SimpleRuntimeEnvironment (org.jbpm.runtime.manager.impl.SimpleRuntimeEnvironment)1 JBossUserGroupCallbackImpl (org.jbpm.services.task.identity.JBossUserGroupCallbackImpl)1 After (org.junit.After)1 Test (org.junit.Test)1 ProcessNodeLeftEvent (org.kie.api.event.process.ProcessNodeLeftEvent)1 ProcessStartedEvent (org.kie.api.event.process.ProcessStartedEvent)1 KieSession (org.kie.api.runtime.KieSession)1 RuntimeEngine (org.kie.api.runtime.manager.RuntimeEngine)1 RuntimeEnvironment (org.kie.api.runtime.manager.RuntimeEnvironment)1