Search in sources :

Example 26 with DeploymentDescriptorImpl

use of org.jbpm.runtime.manager.impl.deploy.DeploymentDescriptorImpl in project jbpm by kiegroup.

the class MultipleDeploymentsProcessServiceEJBIntegrationTest method testStartProcessFromDifferentDeployments.

@Test
public void testStartProcessFromDifferentDeployments() {
    assertNotNull(deploymentService);
    DeploymentDescriptor customDescriptor = new DeploymentDescriptorImpl("org.jbpm.domain");
    customDescriptor.getBuilder().runtimeStrategy(RuntimeStrategy.PER_PROCESS_INSTANCE);
    KModuleDeploymentUnit deploymentUnit = new KModuleDeploymentUnit(GROUP_ID, ARTIFACT_ID, VERSION);
    deploymentUnit.setDeploymentDescriptor(customDescriptor);
    deploymentService.deploy(deploymentUnit);
    units.add(deploymentUnit);
    DeploymentDescriptor customDescriptor2 = new DeploymentDescriptorImpl("org.jbpm.domain");
    customDescriptor.getBuilder().runtimeStrategy(RuntimeStrategy.PER_PROCESS_INSTANCE);
    KModuleDeploymentUnit deploymentUnit2 = new KModuleDeploymentUnit(GROUP_ID2, ARTIFACT_ID2, VERSION2);
    deploymentUnit2.setDeploymentDescriptor(customDescriptor2);
    deploymentService.deploy(deploymentUnit2);
    units.add(deploymentUnit2);
    boolean isDeployed = deploymentService.isDeployed(deploymentUnit.getIdentifier());
    assertTrue(isDeployed);
    isDeployed = deploymentService.isDeployed(deploymentUnit2.getIdentifier());
    assertTrue(isDeployed);
    assertNotNull(processService);
    // first process from deployment 1
    long processInstanceId = processService.startProcess(deploymentUnit.getIdentifier(), "Import");
    assertNotNull(processInstanceId);
    try {
        ProcessInstance pi = processService.getProcessInstance(processInstanceId);
        assertNull(pi);
    } catch (EJBException e) {
        if (e.getCause() instanceof SessionNotFoundException) {
        // ignore as this is expected when per process instance is used
        } else {
            throw e;
        }
    }
    // second process from deployment 2
    long processInstanceId2 = processService.startProcess(deploymentUnit2.getIdentifier(), "customtask");
    assertNotNull(processInstanceId2);
    try {
        ProcessInstance pi2 = processService.getProcessInstance(processInstanceId2);
        assertNull(pi2);
    } catch (EJBException e) {
        if (e.getCause() instanceof SessionNotFoundException) {
        // ignore as this is expected when per process instance is used
        } else {
            throw e;
        }
    }
}
Also used : DeploymentDescriptor(org.kie.internal.runtime.conf.DeploymentDescriptor) DeploymentDescriptorImpl(org.jbpm.runtime.manager.impl.deploy.DeploymentDescriptorImpl) ProcessInstance(org.kie.api.runtime.process.ProcessInstance) KModuleDeploymentUnit(org.jbpm.kie.services.impl.KModuleDeploymentUnit) EJBException(javax.ejb.EJBException) SessionNotFoundException(org.kie.internal.runtime.manager.SessionNotFoundException) Test(org.junit.Test)

Example 27 with DeploymentDescriptorImpl

use of org.jbpm.runtime.manager.impl.deploy.DeploymentDescriptorImpl in project jbpm by kiegroup.

the class DefaultRegisterableItemsFactoryTest method testJmsAuditCacheInstance.

@Test
public void testJmsAuditCacheInstance() throws Exception {
    KieServices ks = KieServices.Factory.get();
    ReleaseId releaseId = ks.newReleaseId("org.jbpm.test.jms", "kjar-jms-audit", "1.0.0");
    DeploymentDescriptor customDescriptor = new DeploymentDescriptorImpl("org.jbpm.persistence.jpa");
    customDescriptor.getBuilder().auditMode(AuditMode.JMS);
    Map<String, String> resources = new HashMap<String, String>();
    resources.put("src/main/resources/" + DeploymentDescriptor.META_INF_LOCATION, customDescriptor.toXml());
    InternalKieModule kJar1 = createKieJar(ks, releaseId, resources);
    installKjar(releaseId, kJar1);
    RuntimeEnvironment environment = RuntimeEnvironmentBuilder.Factory.get().newDefaultBuilder(releaseId).classLoader(this.getClass().getClassLoader()).get();
    manager = RuntimeManagerFactory.Factory.get().newPerProcessInstanceRuntimeManager(environment);
    assertNotNull(manager);
    RuntimeEngine engine = manager.getRuntimeEngine(ProcessInstanceIdContext.get());
    assertNotNull(engine);
    AsyncAuditLogProducer asyncAuditLogProducer = null;
    KieSession kieSession = engine.getKieSession();
    for (ProcessEventListener listener : kieSession.getProcessEventListeners()) {
        if (listener instanceof AsyncAuditLogProducer) {
            asyncAuditLogProducer = (AsyncAuditLogProducer) listener;
            break;
        }
    }
    assertNotNull(asyncAuditLogProducer);
    manager.close();
    manager = RuntimeManagerFactory.Factory.get().newPerProcessInstanceRuntimeManager(environment);
    assertNotNull(manager);
    RuntimeEngine engine2 = manager.getRuntimeEngine(ProcessInstanceIdContext.get());
    KieSession kieSession2 = engine2.getKieSession();
    AsyncAuditLogProducer asyncAuditLogProducer2 = null;
    for (ProcessEventListener listener : kieSession2.getProcessEventListeners()) {
        if (listener instanceof AsyncAuditLogProducer) {
            asyncAuditLogProducer2 = (AsyncAuditLogProducer) listener;
            break;
        }
    }
    assertNotNull(asyncAuditLogProducer2);
    // check if the instance is the same (cached)
    assertEquals(asyncAuditLogProducer, asyncAuditLogProducer2);
}
Also used : RuntimeEngine(org.kie.api.runtime.manager.RuntimeEngine) RuntimeEnvironment(org.kie.api.runtime.manager.RuntimeEnvironment) HashMap(java.util.HashMap) DeploymentDescriptor(org.kie.internal.runtime.conf.DeploymentDescriptor) ProcessEventListener(org.kie.api.event.process.ProcessEventListener) DeploymentDescriptorImpl(org.jbpm.runtime.manager.impl.deploy.DeploymentDescriptorImpl) KieServices(org.kie.api.KieServices) ReleaseId(org.kie.api.builder.ReleaseId) AsyncAuditLogProducer(org.jbpm.process.audit.jms.AsyncAuditLogProducer) KieSession(org.kie.api.runtime.KieSession) InternalKieModule(org.drools.compiler.kie.builder.impl.InternalKieModule) AbstractDeploymentDescriptorTest(org.jbpm.runtime.manager.impl.deploy.AbstractDeploymentDescriptorTest) Test(org.junit.Test)

Aggregations

DeploymentDescriptorImpl (org.jbpm.runtime.manager.impl.deploy.DeploymentDescriptorImpl)27 DeploymentDescriptor (org.kie.internal.runtime.conf.DeploymentDescriptor)26 KModuleDeploymentUnit (org.jbpm.kie.services.impl.KModuleDeploymentUnit)19 KieServices (org.kie.api.KieServices)15 ReleaseId (org.kie.api.builder.ReleaseId)15 File (java.io.File)14 InternalKieModule (org.drools.compiler.kie.builder.impl.InternalKieModule)14 HashMap (java.util.HashMap)13 FileOutputStream (java.io.FileOutputStream)12 KieMavenRepository (org.kie.scanner.KieMavenRepository)12 KieMavenRepository.getKieMavenRepository (org.kie.scanner.KieMavenRepository.getKieMavenRepository)12 ArrayList (java.util.ArrayList)11 Test (org.junit.Test)11 AbstractKieServicesBaseTest (org.jbpm.kie.test.util.AbstractKieServicesBaseTest)9 Before (org.junit.Before)8 DeployedUnit (org.jbpm.services.api.model.DeployedUnit)7 NamedObjectModel (org.kie.internal.runtime.conf.NamedObjectModel)7 ObjectModel (org.kie.internal.runtime.conf.ObjectModel)7 ProcessInstanceNotFoundException (org.jbpm.services.api.ProcessInstanceNotFoundException)6 ProcessInstance (org.kie.api.runtime.process.ProcessInstance)5