Please take some time to read through the official documentation of
jBPM’s Core Engine API before proceeding here.
RuntimeManager
Magnolia’s jBPM integration takes advantage of the new Runtime Manager
concept.
_The runtime manager manages the KIE session according to a predefined strategy. The following strategies are available:
Singleton: The runtime manager maintains a single KieSession and uses it for all the requested processes.
Per Request: The runtime manager creates a new KieSession for every request.
Per Process Instance: The runtime manager maintains mapping between process instance and KieSession and always provides the same KieSession whenever working with a given process instance.
Magnolia uses the singleton strategy, which means the RuntimeManager maintains a single instance of
RuntimeEngine and in turn a single instance of KieSession (and
TaskService). This is the easiest approach and how it used to work in
jBPM 5.x. But it comes with a performance penalty because of the
synchronized access to the RuntimeEngine.
An alternative to this would be the per
process strategy, where the RuntimeManager maintains a strict
relationship between KieSession and ProcessInstance. Currently, the
underlying JCR persistence is lacking the possibility to store this
relationship using the so called Correlation Key.
RuntimeEnvironment
In jBPM the Runtime Environment is used by the RuntimeManager and
encapsulates all important configuration that it requires for execution.
It has to be fully instantiated and configured before the manager gets
started and should not be altered afterwards.
Magnolia has its own implementation of the RuntimeEnvironment which
takes care of the following during initialization:
Configure JCR persistence related classes.
Load process definitions
Provide the necessary implementations used by the runtime (see
Magnolia’s implementation of RegisterableItemsFactory) such as:
The most important classes involved in setting up the jBPM Runtime and
communicating with the engine.
Starting the jBPM engine
This sequence diagram illustrates how the Runtime is initialized during
module startup. After startup the WorkflowManager has a fully
initialized RuntimeManager which allows communicating with the engine.
Launching a process
This sequence diagram shows how a process gets launched using the
LaunchWorkflowCommand.