此内容没有您所选择的语言版本。

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.

Expand
AttributeDescription

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:

Expand
AttributeDescription

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 kbase as default. Set to false by default.

scope

Possible values: prototype or singleton. Set to singleton by default.

eventProcessingMode

Event Processing Mode. Possible values: STREAM or CLOUD.

equalsBehavior

Possible values: IDENTITY or EQUALITY.

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>
Copy to Clipboard Toggle word wrap

When you define a kbase or a ksession, you can set the bean scope:

  • Set scope to prototype to instantiate a new bean instance every time the bean is called.
  • Set scope to singleton 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:

Expand
AttributeDescription

name

The name of the KieSession. This attribute is required.

type

Possible values: stateful or stateless. Set to stateful by default.

default

A Boolean. Sets the ksession as default. Set to false by default.

scope

Possible values: prototype or singleton. Set to singleton by default.

clockType

Possible values: REALTIME or PSEUDO.

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: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>
Copy to Clipboard Toggle word wrap

Kie:ReleaseId

The kie:releaseId element represents Maven GAV (Group ID, Artifact ID, and Version). kie:releaseId requires the following properties:

Expand
AttributeDescription

id

The name to which other beans refer. Blueprint ID semantics applies.

groupId

Maven groupId.

artifactId

Maven artifactId.

version

Maven version.

Example 11.3. releaseId Definition Example

<kie:releaseId id="beanId" groupId="org.kie.blueprint"
            artifactId="named-artifactId" version="1.0.0-SNAPSHOT"/>
Copy to Clipboard Toggle word wrap

Kie:Import

Red Hat JBoss BRMS now supports kie-aries-blueprint importing KIE objects from KJARs. The kie:import element supports the following attributes:

Expand
AttributeDescription

releaseId

Reference to a bean ID. Standard Blueprint ID semantics applies.

enableScanner

Enable Scanner. This attribute is used only if releaseId is specified.

scannerInterval

Scanning Interval in milliseconds. This attribute is used only if releaseId is specified.

Red Hat JBoss BRMS supports two modes of importing KIE objects:

Global Import

The kie:import element uses the KieServices.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 />
Copy to Clipboard Toggle word wrap

Specific Import - ReleaseId

When using the releaseId-ref attribute on the import tag, only KIE objects identified by the referenced releaseId 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}"/>
Copy to Clipboard Toggle word wrap

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}"/>
Copy to Clipboard Toggle word wrap

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();
Copy to Clipboard Toggle word wrap

Note

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:

Expand
AttributeDescription

ref

A reference to a bean.

Example 11.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>
Copy to Clipboard Toggle word wrap

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.

<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>
Copy to Clipboard Toggle word wrap

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:

Expand
AttributeDescription

ID

Unique identifier

Possible children:

  • kie:agendaEventListener
  • kie:ruleRuntimeEventListener
  • kie:processEventListener
Note

The declaration order does not matter. Only one declaration of each type is allowed in a group.

Example 11.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>
Copy to Clipboard Toggle word wrap

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

<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>
Copy to Clipboard Toggle word wrap

Defining a File Logger

The <kie:fileLogger/> element supports the following attributes:

Expand
AttributeDescription

ID

Unique identifier. This attribute is required.

file

Path to the log file on the disk. This attribute is required.

threaded

Possible values: true or false. Set to false by default.

interval

An Integer. Specifies the interval for flushing the contents from memory to the disk.

Example 11.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>
Copy to Clipboard Toggle word wrap

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();
Copy to Clipboard Toggle word wrap

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

<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>
Copy to Clipboard Toggle word wrap
返回顶部
Red Hat logoGithubredditYoutubeTwitter

学习

尝试、购买和销售

社区

关于红帽文档

通过我们的产品和服务,以及可以信赖的内容,帮助红帽用户创新并实现他们的目标。 了解我们当前的更新.

让开源更具包容性

红帽致力于替换我们的代码、文档和 Web 属性中存在问题的语言。欲了解更多详情,请参阅红帽博客.

關於紅帽

我们提供强化的解决方案,使企业能够更轻松地跨平台和环境(从核心数据中心到网络边缘)工作。

Theme

© 2025 Red Hat