Sunday, September 09, 2012

Drools Spring Enhancements in the 5.x releases

Version 5.3 of Drools introduced the ability to declare Knowledge Listeners via the Spring XML. You could declare 3 types of listeners to be added to the KnowledgeSessions - AgendaListener,  WorkingMemoryListener, ProcessEventListener.

The drools-spring module allowed configuration of these listeners to KnowledgeSessions using XML tags. These tags have identical names as the actual listener interfaces i.e., <drools:agendaEventListener....>, <drools:workingMemoryEventListener....> and <drools:processEventListener....>.

The upcoming 5.5.0.Beta1 would include the following enhancements to the drools-spring module

Support declarative configuration for knowledge runtime loggers (console, file, threaded-file)
With this addition, all the requisite loggers can be defined declaratively and attached to the Knowledge Sessions. All the logger types supported by Drools Expert can be configured via XML.
   <drools:ksession id="…" type="…" kbase="…">

    <drools:ksession id="…" type="…" kbase="…">
        <drools:fileLogger id="…" file="[path]"/>

    <drools:ksession id="…" type="…" kbase="…">
        <drools:fileLogger id="…" file="[path]" threaded="true" interval="5"/>

You can find more information on the options and the corresponding Java Code here:

  Defining an environment (org.drools.runtime.Environment)
 <drools:environment id="drools-env">
    <drools:entity-manager-factory ref="myEmf"/>
    <drools:transaction-manager ref="txManager"/>
    <drools:globals ref="my-globals"/>
    <drools:date-formats ref="my-date-formats"/>
    <drools:calendars ref="my-calendars"/>

      <drools:serializable-placeholder-resolver-strategy strategy-acceptor-ref=".."/>
      <drools:identity-placeholder-resolver-strategy strategy-acceptor-ref=".."/>
      <drools:jpa-placeholder-resolver-strategy env-ref=".." />

        <drools:scoped-entity-manager scope="app" >
You can find more information on the configuration options and the corresponding Java Code here:

Vinod Kiran
BRMS Practice Lead with ValueMomentum Software Services Pvt. Ltd


No comments:

Post a comment