Information Technology Reference
In-Depth Information
already created. This session ID is later on retrieved from the database, or if persistence is
not being used, from an in-memory HashMap .
Each time a runtime engine is created, a reference to a TaskService instance is also
created. Since the TaskService instance acts as a stateless service with only the per-
sistence keeping state information, no distinction is made between the different built-in
runtime managers when it comes to creating the Human task component.
The Singleton Runtime Manager will require a context parameter to retrieve the
RuntimeEngine instance. Since there is no distinction required between different en-
vironments (because they all share the same KIE session), we can use an EmptyCon-
text instance or null parameters to retrieve the runtime engine:
RuntimeEngine engine = manager.getRuntimeEngine(
EmptyContext.get() );
With SingletonRuntimeManager , every RuntimeEngine instance returned will
have the same KIE session object. This has its own advantages and disadvantages.
On the one hand, all processes that will be running on the same session can interact with
each other through the rule engine memory, and feed combined rule executions with data.
This allows you to have many processes interacting with each other as well as with rules,
letting the processes remain simple enough, and complex decisions being handled by
rules. Also, it allows for performance monitoring rules to be written and executed on the
same environment as the processes are running.
On the other hand, having rules sharing information between different process instances
can also lead to complications, particularly if we want to write rules that take into account
only the objects of a specific process instance in a Business Rule task. Also, when persist-
ence and concurrent invocations of process instances are being used, all of them will be
derived form the same session that will have to execute them one at a time. This could
lead to performance degradation.
The CDI injection
The jBPM6 project provides CDI annotations to directly inject a
SingletonRuntimeManager instance in your managed beans. To distinguish it from
other types of runtime managers, you should mark it with both the
@javax.inject.Inject annotation and the
Search WWH ::




Custom Search