use of org.kie.internal.runtime.manager.SessionNotFoundException in project jbpm by kiegroup.
the class ProcessServiceImpl method setProcessVariables.
@Override
public void setProcessVariables(String deploymentId, Long processInstanceId, Map<String, Object> variables) {
DeployedUnit deployedUnit = deploymentService.getDeployedUnit(deploymentId);
if (deployedUnit == null) {
throw new DeploymentNotFoundException("No deployments available for " + deploymentId);
}
RuntimeManager manager = deployedUnit.getRuntimeManager();
variables = process(variables, ((InternalRuntimeManager) manager).getEnvironment().getClassLoader());
RuntimeEngine engine = manager.getRuntimeEngine(ProcessInstanceIdContext.get(processInstanceId));
try {
KieSession ksession = engine.getKieSession();
ProcessInstance pi = ksession.getProcessInstance(processInstanceId);
if (pi == null) {
throw new ProcessInstanceNotFoundException("Process instance with id " + processInstanceId + " was not found");
}
ksession.execute(new SetProcessInstanceVariablesCommand(processInstanceId, variables));
} catch (SessionNotFoundException e) {
throw new ProcessInstanceNotFoundException("Process instance with id " + processInstanceId + " was not found", e);
} finally {
disposeRuntimeEngine(manager, engine);
}
}
use of org.kie.internal.runtime.manager.SessionNotFoundException 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;
}
}
}
use of org.kie.internal.runtime.manager.SessionNotFoundException in project jbpm by kiegroup.
the class TimerInitFailureRuntimeManagerTest method testPerProcessInstanceRuntimeManager.
@Test(timeout = 15000)
@BMScript(value = "byteman-scripts/failOnRuntimeManagerInitRules.btm")
public void testPerProcessInstanceRuntimeManager() throws Exception {
final NodeLeftCountDownProcessEventListener countDownListener = new NodeLeftCountDownProcessEventListener("Intermediate Catch Event 1", 1);
RuntimeEnvironment environment = createEnvironment(countDownListener);
manager = RuntimeManagerFactory.Factory.get().newPerProcessInstanceRuntimeManager(environment, "first");
assertNotNull(manager);
RuntimeEngine runtime = manager.getRuntimeEngine(ProcessInstanceIdContext.get());
KieSession ksession = runtime.getKieSession();
// start a new process instance
Map<String, Object> params = new HashMap<>();
ProcessInstance pi = ksession.startProcess("TimerInitFailure", params);
assertEquals(ProcessInstance.STATE_ACTIVE, pi.getState());
manager.disposeRuntimeEngine(runtime);
countDownListener.waitTillCompleted();
// User access
runtime = manager.getRuntimeEngine(ProcessInstanceIdContext.get(pi.getId()));
runtime.getKieSession();
TaskService taskService = runtime.getTaskService();
List<TaskSummary> list = taskService.getTasksAssignedAsPotentialOwner("john", "en-UK");
assertEquals(1, list.size());
long taskId = list.get(0).getId();
taskService.start(taskId, "john");
taskService.complete(taskId, "john", null);
manager.disposeRuntimeEngine(runtime);
try {
runtime = manager.getRuntimeEngine(ProcessInstanceIdContext.get(pi.getId()));
runtime.getKieSession();
fail("ProcessInstance should already be completed");
} catch (SessionNotFoundException e) {
// expected
}
}
Aggregations