Chapter 15. Integration with Aries Blueprint
This chapter explains the integration elements of Red Hat JBoss BPM Suite specific to Apache Aries Blueprint.
15.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 15.1. kbase Definition Example
<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
scopetoprototypeto instantiate a new bean instance every time the bean is called. -
Set
scopetosingletonto 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 15.2. ksession definition example
<kie:kmodule id="sample-kmodule">
<kie:kbase name="drl_kiesample3" packages="drl_kiesample3">
<kie:ksession name="ksession1" type="stateless"/>
<kie:ksession name="ksession2"/>
</kie:kbase>
</kie:kmodule>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 15.3. releaseId Definition Example
<kie:releaseId id="beanId" groupId="org.kie.blueprint"
artifactId="named-artifactId" version="1.0.0-SNAPSHOT"/>Kie:Import
Red Hat JBoss BPM Suite 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 BPM Suite supports two modes of importing KIE objects:
- Global Import
The
kie:importelement 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 />
- Specific Import - ReleaseId
When using the
releaseId-refattribute on the import tag, only KIE objects identified by the referencedreleaseIdelement 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}"/>
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}"/>
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();
kie-ci must be available on the classpath for the releaseId importing feature to work.
15.2. Event Listeners
Red Hat JBoss BPM Suite 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 15.4. Listener Configuration Using bean:ref
<bean id="mock-agenda-listener" class="mocks.MockAgendaEventListener"/>
<bean id="mock-rr-listener" class="mocks.MockRuleRuntimeEventListener"/>
<bean id="mock-process-listener" class="mocks.MockProcessEventListener"/>
<kie:kmodule id="listeners_kmodule">
<kie:kbase name="drl_kiesample" packages="drl_kiesample">
<kie:ksession name="ksession2">
<kie:agendaEventListener ref="mock-agenda-listener"/>
<kie:processEventListener ref="mock-process-listener"/>
<kie:ruleRuntimeEventListener ref="mock-rr-listener"/>
</kie:ksession>
</kie:kbase>
</kie:kmodule>Defining Multiple Listeners of One Type
You can also define multiple listeners of one type for a KIE session.
Example 15.5. Listener Configuration: Multiple Listeners of One Type.
<bean id="mock-agenda-listener1" class="mocks.MockAgendaEventListener"/>
<bean id="mock-agenda-listener2" class="mocks.MockAgendaEventListener"/>
<kie:kmodule id="listeners_module">
<kie:kbase name="drl_kiesample" packages="drl_kiesample">
<kie:ksession name="ksession1">
<kie:agendaEventListener ref="mock-agenda-listener1"/>
<kie:agendaEventListener ref="mock-agenda-listener2"/>
</kie:ksession>
</kie:kbase>
</kie:kmodule>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 15.6. Group of Listeners
<bean id="mock-agenda-listener" class="mocks.MockAgendaEventListener"/>
<bean id="mock-rr-listener" class="mocks.MockRuleRuntimeEventListener"/>
<bean id="mock-process-listener" class="mocks.MockProcessEventListener"/>
<kie:kmodule id="listeners_module">
<kie:kbase name="drl_kiesample" packages="drl_kiesample">
<kie:ksession name="statelessWithGroupedListeners" type="stateless"
listeners-ref="debugListeners"/>
</kie:kbase>
</kie:kmodule>
<kie:eventListeners id="debugListeners">
<kie:agendaEventListener ref="mock-agenda-listener"/>
<kie:processEventListener ref="mock-process-listener"/>
<kie:ruleRuntimeEventListener ref="mock-rr-listener"/>
</kie:eventListeners>15.3. Loggers
Red Hat JBoss BPM Suite 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 15.7. Defining a Console Logger
<kie:kmodule id="loggers_module">
<kie:kbase name="drl_kiesample" packages="drl_kiesample">
<kie:ksession name="ConsoleLogger-statefulSession" type="stateful">
<kie:consoleLogger/>
</kie:ksession>
</kie:kbase>
</kie:kmodule>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 15.8. Defining a File Logger
<kie:kmodule id="loggers_module">
<kie:kbase name="drl_kiesample" packages="drl_kiesample">
<kie:ksession name="ConsoleLogger-statefulSession" type="stateful">
<kie:fileLogger id="fl_logger" file="#{ systemProperties['java.io.tmpdir'] }/log1"/>
<kie:fileLogger id="tfl_logger" file="#{ systemProperties['java.io.tmpdir'] }/log2"
threaded="true" interval="5"/>
</kie:ksession>
</kie:kbase>
</kie:kmodule>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();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 15.9. Batch Commands Example
<kie:kmodule id="batch_commands_module">
<kie:kbase name="drl_kiesample" packages="drl_kiesample">
<kie:ksession name="ksessionForCommands" type="stateful">
<kie:batch>
<kie:insert-object ref="person2"/>
<kie:set-global identifier="persons" ref="personsList"/>
<kie:fire-all-rules max="10"/>
</kie:batch>
</kie:ksession>
</kie:kbase>
</kie:kmodule>
Where did the comment section go?
Red Hat's documentation publication system recently went through an upgrade to enable speedier, more mobile-friendly content. We decided to re-evaluate our commenting platform to ensure that it meets your expectations and serves as an optimal feedback mechanism. During this redesign, we invite your input on providing feedback on Red Hat documentation via the discussion platform.