Information Technology Reference
In-Depth Information
runtime engine is disposed of. This doesn't make much sense unless you run fully-syn-
chronous, automatic processes that will be completed the moment they return from the
startProcess method invocation, or in a single code block.
However, if you are in a persistent environment, all references to long-lived process in-
stances will be kept in the database, as well as any process instance reference that is wait-
ing for a specific signal. In these cases, the Per Request Runtime Manager provides the
most isolation regarding execution of processes and rules. All rules will be fired with only
the data that is present in the process instance or explicitly added to the working memory
before calling a process related invocation in the KIE session.
The Per Request Runtime Manager will require a context parameter to retrieve the
RuntimeEngine instance associated to a specific process instance ID. However, in the
same way as the Singleton Runtime Manager, it will not condition the KIE Session to be
used (in this case, it will always be a new one), so we can use the EmptyContext in-
stance:
RuntimeEngine engine =
manager.getRuntimeEngine(EmptyContext.get());
ProcessInstance pInst =
engine.getKieSession().startProcess("procId");
Long procInstId = pInst.getId();
manager.disposeRuntimeEngine(engine);
The PerRequestRuntimeManager injection provides enough isolation of processes
to guarantee the highest scalability possible, but the rules associated with the process exe-
cution cannot take advantage of gathering cross-process instance information. Information
that could be used in cross referencing complex events fired by different process instances
will not be available, because every time a new KIE session is created, the working
memory is initialized from scratch.
The CDI injection
The jBPM6 project provides CDI annotations for the PerRequestRuntimeManager
injection in managed beans. 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.PerRequest
annotation. CDI initialization will inject a runtime manager instance per request without
Search WWH ::




Custom Search