Information Technology Reference
In-Depth Information
uses persistence, the reference is kept on a JPA-managed table called ContextMap-
pingInfo as well, but is cached internally to minimize database use.
The PerProcessInstanceRuntimeManager will require a context parameter to
retrieve the RuntimeEngine instance associated to a specific process instance ID. If we
want to start using a new KIE session, we can request a runtime engine with a fresh ses-
sion by using the EmptyContext instance. This is usually the practice to start a new
process:
RuntimeEngine engine =
manager.getRuntimeEngine(EmptyContext.get());
ProcessInstance pInst =
engine.getKieSession().startProcess("procId");
Long procInstId = pInst.getId();
manager.disposeRuntimeEngine(engine);
However, if we want to retrieve the same session that started a previous process instance,
we can retrieve it with the process instance ID and the help of a context class called Pro-
cessInstanceIdContext :
Long procInstId = ... // process instance ID provided by
code
RuntimeEngine engine2 = manager.getRuntimeEngine(
ProcessInstanceIdContext.get(procInstId));
engine2.getKieSession().getProcessInstance(procInstId);
Even if the PerProcessInstanceRuntimeManager object can return a new ses-
sion for each process instance we manually start, this is not mandatory. There is no limita-
tion to the number of process instances a KIE session could use. Also, process instances
started by internal process signaling and subprocesses will end up sharing the same KIE
session. Nevertheless, each new process instance will register a new mapping between the
KIE session and the new process instance, which means that you can use the Pro-
cessInstanceIdContext to retrieve the specific KIE session.
Also, if you wanted to explicitly create a process instance in the same session where an-
other one resides, you could just get the RuntimeEngine instance using the process in-
stance ID of the previous process instance and start the new process in its session:
Search WWH ::




Custom Search