此内容没有您所选择的语言版本。
Chapter 11. Integration with Aries Blueprint
This chapter explains the integration elements of Red Hat JBoss BRMS specific to Apache Aries Blueprint.
11.1. KIE Namespace 复制链接链接已复制到粘贴板!
KieModule
The <kie:kmodule>
element defines a collection of a KieBase and its associated KieSessions.
Attribute | Description |
---|---|
id | The name to which other beans refer. Blueprint ID semantics applies. This attribute is required. |
Possible children:
-
kie:kbase
KieBase
The <kie:kbase>
element has the following attributes:
Attribute | Description |
---|---|
name | The name of the KieBase. This attribute is required. |
packages | A comma-separated list of the resource packages to be included in the KieBase. |
includes | KieBase names to be included. All resources from the corresponding KieBases are included in the parent KieBase. |
default |
A Boolean. Sets the |
scope |
Possible values: |
eventProcessingMode |
Event Processing Mode. Possible values: |
equalsBehavior |
Possible values: |
Possible children:
-
kie:ksession
The kmodule
element can contain multiple kbase
elements.
Example 11.1. kbase Definition Example
<kie:kmodule id="sample_module"> <kie:kbase name="kbase1" packages="org.drools.blueprint.sample"> ... </kie:kbase> </kie:kmodule>
<kie:kmodule id="sample_module">
<kie:kbase name="kbase1" packages="org.drools.blueprint.sample">
...
</kie:kbase>
</kie:kmodule>
When you define a kbase
or a ksession
, you can set the bean scope:
-
Set
scope
toprototype
to instantiate a new bean instance every time the bean is called. -
Set
scope
tosingleton
to use the same bean instance every time the bean is called.
KieSession
The <kie:ksession>
element defines both stateful and stateless KieSessions. It has the following parameters:
Attribute | Description |
---|---|
name | The name of the KieSession. This attribute is required. |
type |
Possible values: |
default |
A Boolean. Sets the |
scope |
Possible values: |
clockType |
Possible values: |
listeners-ref | Specifies the reference to the event listeners group. For more information, see the section called “Defining a Group of Listeners”. |
Example 11.2. ksession definition example
Kie:ReleaseId
The kie:releaseId
element represents Maven GAV (Group ID, Artifact ID, and Version). kie:releaseId
requires the following properties:
Attribute | Description |
---|---|
id | The name to which other beans refer. Blueprint ID semantics applies. |
groupId |
Maven |
artifactId |
Maven |
version |
Maven |
Example 11.3. releaseId Definition Example
<kie:releaseId id="beanId" groupId="org.kie.blueprint" artifactId="named-artifactId" version="1.0.0-SNAPSHOT"/>
<kie:releaseId id="beanId" groupId="org.kie.blueprint"
artifactId="named-artifactId" version="1.0.0-SNAPSHOT"/>
Kie:Import
Red Hat JBoss BRMS now supports kie-aries-blueprint
importing KIE objects from KJARs. The kie:import
element supports the following attributes:
Attribute | Description |
---|---|
releaseId | Reference to a bean ID. Standard Blueprint ID semantics applies. |
enableScanner |
Enable Scanner. This attribute is used only if |
scannerInterval |
Scanning Interval in milliseconds. This attribute is used only if |
Red Hat JBoss BRMS supports two modes of importing KIE objects:
- Global Import
The
kie:import
element uses theKieServices.getKieClasspathContainer()
method to import KIE objects. For further information about KIE methods, see the KIE Api section of the Red Hat JBoss BPM Suite Development Guide.Global Import
<kie:import />
<kie:import />
Copy to Clipboard Copied! Toggle word wrap Toggle overflow - Specific Import - ReleaseId
When using the
releaseId-ref
attribute on the import tag, only KIE objects identified by the referencedreleaseId
element are initialized and imported into the Blueprint context.KIE Objects Import Using releaseId
<kie:import releaseId-ref="namedKieSession"/> <kie:releaseId id="namedKieSession" groupId="org.drools" artifactId="named-kiesession" version="{revnumber}"/>
<kie:import releaseId-ref="namedKieSession"/> <kie:releaseId id="namedKieSession" groupId="org.drools" artifactId="named-kiesession" version="{revnumber}"/>
Copy to Clipboard Copied! Toggle word wrap Toggle overflow
You can enable the KIE scanning feature, enableScanner
, for KieBases imported with a specific releaseId. This feature is currently not available for global imports.
Import KIE Objects using a releaseId - Enable Scanner
<kie:import releaseId-ref="namedKieSession" enableScanner="true" scannerInterval="1000"/> <kie:releaseId id="namedKieSession" groupId="org.drools" artifactId="named-kiesession" version="{revnumber}"/>
<kie:import releaseId-ref="namedKieSession"
enableScanner="true" scannerInterval="1000"/>
<kie:releaseId id="namedKieSession" groupId="org.drools"
artifactId="named-kiesession" version="{revnumber}"/>
If you define and enable a scanner, a KieScanner
object is created with default values and inserted into the Blueprint container. You can get the KieScanner
object from the Blueprint container using the -scanner
suffix.
Retriving the KieScanner from a Blueprint Container
// the implicit name would be releaseId-scanner KieScanner releaseIdScanner = (KieScanner)container.getComponentInstance("namedKieSession-scanner"); releaseIdScanner.scanNow();
// the implicit name would be releaseId-scanner
KieScanner releaseIdScanner = (KieScanner)container.getComponentInstance("namedKieSession-scanner");
releaseIdScanner.scanNow();
kie-ci
must be available on the classpath for the releaseId importing feature to work.
11.2. Event Listeners 复制链接链接已复制到粘贴板!
Red Hat JBoss BRMS supports adding 3 types of listeners to KieSessions:
-
AgendaListener
-
WorkingMemoryListener
-
ProcessEventListener
The kie-aries-blueprint
module allows you to configure the listeners for KIE sessions using XML tags. The tags have identical names to the listener interfaces:
-
<kie:agendaEventListener>
-
<kie:ruleRuntimeEventListener>
-
<kie:processEventListener>
The kie-aries-blueprint
module allows you to define listeners as standalone listeners or as a group.
Defining Standalone Listeners
Standalone listeners support the following parameters:
Attribute | Description |
---|---|
ref | A reference to a bean. |
Example 11.4. Listener Configuration Using bean:ref
Defining Multiple Listeners of One Type
You can also define multiple listeners of one type for a KIE session.
Example 11.5. Listener Configuration: Multiple Listeners of One Type.
Defining a Group of Listeners
The kie-aries-blueprint
module allows you to group listeners. This is useful when you define a set of listeners that you want to attach to multiple sessions, or when switching from testing to production use. The following attribute is required:
Attribute | Description |
---|---|
ID | Unique identifier |
Possible children:
-
kie:agendaEventListener
-
kie:ruleRuntimeEventListener
-
kie:processEventListener
The declaration order does not matter. Only one declaration of each type is allowed in a group.
Example 11.6. Group of Listeners
11.3. Loggers 复制链接链接已复制到粘贴板!
Red Hat JBoss BRMS supports the following loggers:
-
ConsoleLogger
-
FileLogger
The kie-aries-blueprint
module allows you to configure the loggers using XML tags with identical names:
-
<kie:consoleLogger>
-
<kie:fileLogger>
Defining a Console Logger
The <kie:consoleLogger/>
element has no attributes and must be present directly under a <kie:ksession>
element.
Example 11.7. Defining a Console Logger
Defining a File Logger
The <kie:fileLogger/>
element supports the following attributes:
Attribute | Description |
---|---|
ID | Unique identifier. This attribute is required. |
file | Path to the log file on the disk. This attribute is required. |
threaded |
Possible values: |
interval | An Integer. Specifies the interval for flushing the contents from memory to the disk. |
Example 11.8. Defining a File Logger
Closing a FileLogger
It is recommended to close the <kie:fileLogger>
logger to prevent memory leaks:
LoggerAdaptor adaptor = (LoggerAdaptor) container.getComponentInstance("fl_logger"); adaptor.close();
LoggerAdaptor adaptor = (LoggerAdaptor) container.getComponentInstance("fl_logger");
adaptor.close();
Defining Batch Commands
The <kie:batch>
element allows you to define a set of batch commands for a given KIE session. The <kie:batch>
element has no attributes and must be placed under a <kie:ksession>
element.
Supported Parameters for Initialization Batch Commands
insert-object
-
ref
: String. This parameter is optional. -
Anonymous bean
.
-
set-global
-
identifier
: String. This parameter is required. -
reg
: String. This parameter is optional. -
Anonymous bean
.
-
fire-all-rules
-
max
: Integer.
-
-
fire-until-halt
start-process
-
identifier
: String. This parameter is required. -
ref
: String. This parameter is optional. -
Anonymous bean
.
-
signal-event
-
ref
: String. This parameter is optional. -
event-type
: String. This parameter is required. -
process-instance-id
: Integer. This parameter is optional.
-
Example 11.9. Batch Commands Example