Information Technology Reference
In-Depth Information
RuntimeEngine engine = manager.getRuntimeEngine(
EmtpyContext.get());
ProcessInstance inst1 = engine.getKieSession().
startProcess("procId");
Long oldProcInstId = inst1.getId();
manager.disposeRuntimeEngine(engine);
RuntimeEngine reuseEngine =
manager.getRuntimeEngine(ProcessInstanceIdContext.get(oldProcInstId));
ProcessInstance inst2 = reuseEngine.getKieSession().
startProcess("procId");
This allows for a greater control over which process instances are executed in each ses-
sion. We can have several groups of process instances running in parallel in multiple KIE
sessions that can run in multiple threads, which allows for better performance and scalab-
ility. Process instances inside the same session can share events and rule data between
each other.
However, we must understand that process instances residing in a different KIE session
will not have this data available unless we explicitly share it through our own code. We
must explicitly search for KIE sessions using process instance IDs, which means that we
must store other details associated to the mapping we want to keep elsewhere. The Per
Process Instance Runtime Manager is a component that sacrifices a little of this ease of
use in exchange for better performance (by providing the possibility of having multiple
sessions).
The CDI injection
CDI annotations are provided as well for PerProcessInstanceRuntimeManager .
To distinguish it from other types of runtime managers, you should mark it with both the
@javax.inject.Inject annotation and the
@org.kie.internal.runtime.manager.cdi.qualifier.PerProcessInstance
annotation. CDI initialization will inject a PerProcessInstanceRuntimeManager
instance without having to declare its specific type. It can mark a RuntimeEnviron-
ment instance as well:
@Inject @PerProcessInstance
RuntimeManager manager;
@Inject @PerProcessInstance
RuntimeEnvironment environment;
Search WWH ::




Custom Search