Drools 5.1 M2 release notes

We’re proud to announce the second milestone release of Drools 5.1. It includes a lot of new features, as described below. So try them out and let us know what you think.

Knowledge Agent

Incremental change-set processing

The new version of the Knowledge Agent supports newInstance = false in its configuration (incremental change-set build). When setting this property to false, the kbase instance of the agent is reused when changes in the monitored resources are detected.

Now Knowledge Agent can process monitored resources modifications in an incremental way.
Modified definitions are compiled and compared against the original version. According to definition’s type, the behaves in different ways:
  • Rules: For rules, the Agent searches for modifications in its attributes, LHS and RHS.
  • Queries: queries are always replaced on kbase wether they are modified or not.
  • Other definitions: All other definitions are always replaced in kbase (like if they were modified). We expect to add better support for definition’s modification detection in further versions.

The current implementation only supports the deletion of rules and functions definitions. For further information please take a look at:

Live Querries

Drools has always had query support, but the result was returned as an iterable set; this makes it hard to monitor changes over time. Live Querries have a listener attached instead of returning an iterable result set. These live querries stay open creating a view and publish change events for the contents of this view.

ViewChangedEventListener listener = new ViewChangedEventListener() {       
public void rowUpdated(Row row) {
updated.add( row.get( "$price" ) );
}

public void rowRemoved(Row row) {
removed.add( row.get( "$price" ) );
}

public void rowAdded(Row row) {
added.add( row.get( "$price" ) );
}
};

// Open the LiveQuery
LiveQuery query = ksession.openLiveQuery( "cheeses",
new Object[] { "cheddar", "stilton" },
listener );

Timers and Calendars

Rule’s now suport both interval and cron based timers, which replace the now deprecated duration attribute.

timer ( int: <initial delay> <repeat interval>? )
timer ( int: 30s )
timer ( int: 30s 5m )

timer ( cron: <cron expression> )
timer ( cron:* 0/15 * * * ? )

Calendars can now controll when rules can fire. The Calendar api is modelled on Quartz :

public interface Calendar { 
boolean isTimeIncluded(long timestamp);
}

Quartz provides several good Calendar implementations, so it makes sense to leverage those, for this we we provide an adapter helper method:

Calendar QuartzHelper.quartzCalendarAdapter(org.quartz.Calendar quartzCal)

Calendars are registered with the StatefulKnowledgeSession:

ksession.getCalendars().set( "week day", weekDayCal );

Which means they can now be used in rules. They can be used in conjunction with normal rules and rules including timers.

The rule calendar attribute can have one or more calendar names.
calendars “calname”
calendars “calname1”, “calname2”

Drools Spring integration

Drools Flow easy configuration

We keep improving the integration with Spring Framework. We added support for configuring a Drools Flow JPA session for using it with a local transaction manager.
(Now if you don’t need to configure variable persisters the jpaSessionServiceFactory is only one line! :))
More info and usage examples in: http://blog.bauna.com.ar/index.php/2010/05/drools-flow-configuration-using-spring/

Drools Camel Integration:

The Apache Camel integration let us interact with a Drools stateless or stateful session. The interaction is achieved using a pipeline that transforms the input command (right now an XML representation of the command) into an executable one. Also Apache Camel let us implement more advanced enterprise integration patterns than a simple transformation pipeline.

So, you can use any of the out-of-the-box Camel Components as a Drools commands producer, which allow to create more powerful services interactions. At this moment, we provide out-of-the-box marshallers for XStream & JAXB.

If you want to read more about how to configure and use the Drools Camel endpoint take a look at the following link:
http://lucazamador.wordpress.com/2010/05/28/drools-apache-camel-integration/

Drools Execution Server:

A new version of Drools Server is included in this release. This version add the support for Stateful Knowledge Sessions. Internally, for this new version, we use drools-camel, drools-spring and drools-grid to provide the following list of new features:

  • Stateful/Stateless Knowledge session support
  • RestWS & SOAP services to interact with the sessions
  • Spring configuration
  • JAXB/XStream XML commands support (using the out-of-the-box provided marshallers in drools-camel)

You can read more about this in the following blog post: http://lucazamador.wordpress.com/2010/05/27/drools-server-spring-configuration/

Extensive BPMN 2.0 support

As we already announced earlier, the Drools team has decided to support the use of the upcoming BPMN 2.0 specification for specifying business processes using XML. This milestone includes a significant extension of the BPMN2 parser to support more of the BPMN2 features using Drools Flow. More specifically:
  • more extensive event support: much more combinations of event types (start, intermediate and end) and event triggers (including for example error, escalation, timer, conditional and signal events), have been included, as well as (interrupting and non-interrupting) boundary events
  • sub-process parameters
  • diverging inclusive gateway
  • etc.
BPMN2 processes have also been integrated in the entire Drools tool chain, to support the entire life cycle of the business process. This includes
  • the ability to use BPMN2 processes in combination with our Eclipse tooling
  • Guvnor as process repository
  • web-based management using the BPM console
  • auditing and debugging
  • domain-specific processes
  • etc.

As a result, Drools Flow is not only the first open-source process engine that supports such a significant set of BPMN2 constructs natively, our knowledge-oriented approach also allows you to easily combine your BPMN2 processes with business rules and complex event processing, all using the same APIs and tools.

Installation script

The Drools build now contains an install folder that simplifies installing the Eclipse plugin, Guvnor and the gwt-console. It creates and copies the necessary jars and wars and deploys them to the JBoss AS. It also includes a simple evaluation process example you can use to test your setup. For more info, take a look at the readme in the install folder.

JMX Monitoring improvements

The JMX monitoring framework was improved to include process related statistics. JOPR plugin was also updated to show such data.

Session Inspection and Reporting framework

A new API based framework for runtime session inspection and reporting was introduced, allowing for better data gathering during debugging or profiling of the application. This inspection framework will become the basis of the tooling features to help providing more detailed information about the contents of each session.

To inspect a session, one can use the following API calls:

        StatefulKnowledgeSession ksession = ...

// ... insert facts, fire rules, etc

SessionInspector inspector = new SessionInspector( ksession );
StatefulKnowledgeSessionInfo info = inspector.getSessionInfo();

The StatefulKnowledgeSessionInfo instance will contain a lot of relevant data gathered during the analysis of the session. A simple example report template is provided and can be generated with the following API call:

        String report = SessionReporter.generateReport( "simple", info, null );

Guvnor

Updated to GWT 2.0

GWT was updated, making Guvnor faster.

Build in selector

The built in selector allows user to choose what assets to build according to:
1. Status (eg, Dev, QA etc)
2. Category
3. Metadata

Single asset verification

It is possible to verify just the asset you are working on ( ruleflow, rule, decision table ). Verification finds issues like conflicting restrictions in a rule or redundant rows in decision tables.

Global area

Assets stored in Global area can be shared to all packages.

Diff check between snapshots

Lists the changes between two snapshots.

Viewing multiple assets in one tab

Makes it possible to open more than one asset into one view. All the assets can be saved and edited as a group.

Pattern order

Guided Editor supports Pattern reordering in LHS and RHS sections. New Patterns can be inserted in any order (and not always at the end). For further information: http://ilesteban.wordpress.com/2010/05/28/guvnor-patternaction-ordering-in-guided-editor/

From/Collect/Accumulate support

Guided Editor has basic support for From, Accumulate and Collect Patterns. You can add any of these structures as regular Patterns.

New expression builder component was created to add support for nested method calls of a variable.
The following link contains a more detailed explanation about these improvements:

http://ilesteban.wordpress.com/2010/05/28/guvnor-guided-editor-suuport-for-fromcollectaccumulate-elements/

Templates

There is a new knowledge you can add to the base. You can create rules based on a data grid attached to a rule template. This will allow the user to don’t write repetitive rules who only changes the value of the facts.
A screencast showing Templates in action can be found here: http://locademiaz.wordpress.com/2010/05/28/new-guvnor-feature-rules-templates/

Working Sets

Working Sets are a mean for grouping Facts and then defining constraints on them. You can create groups of Facts and only those Facts will be visible when authoring rules using the Guided Editor.

Fact Constraints

Once you have grouped facts in a Working Set you can define restrictions on those facts’ fields. The restrictions that you define will be used to validate what you can write on rules.
For further information you can read:

Author

Comments are closed.