Writing the Rules
The rules engine that's best for your business
JBoss's Rules technologies are part of its JEMS (JBoss Enterprise Middleware Suite) SOA platform, and are already in wide use. JBoss sees customers using the tools to help implement service architectures, as rules can be used to link and orchestrate services. Version 3.0.5 was released in November 2006, and while it may not have all the features of some of its competitors, it has the advantage of offering a range of interfaces and is small enough to be embedded in existing applications – rather than requiring its own server. It's also open source, so you can tailor it to work just the way you want. There are some useful publications on the technologies used in JBoss Rules here.
Developing new rules is relatively easy, and JBoss provides an Eclipse plug-in to add rules development features to existing IDEs. As JBoss Rules is an extension of the Drools project [the Drools project voted to join forces with JBoss at the end of 2005 – Ed], you'll need to become familiar with JBoss' Drools business engine language (and you'll find plenty of references to Drools in the copious online documentation). Drools provides forward chaining, using fact propagation to provide a conclusion which is then acted on by an application. The Eclipse IDE hides Drools' XML syntax, providing a more readable UI; you can still edit the XML by hand, but we&'d recommend using the IDE tools. You can use the JBoss site as an update server, making sure you always have the latest version of the IDE installed in your copy of Eclipse.
While it may not be as business-user-friendly as ILOG's JRules, JBoss Rules can be used by non-developers. Its business language offers BASIC-like functions, and hides the Java and XML code needed to implement rules in your applications. The application is JSR 94 compliant, simplifying integration with existing applications and application servers. One significant omission is a rule repository. While you can use existing source control tools, like CVS, to manage rules, this approach adds an extra layer of complexity, and could discourage business users.
Building rules is relatively easy. Like languages on other rules engines, the Drools language is declarative, and decouples business logic from data. Left hand and right hand sides link facts to actions. Rule sets are delivered as packages, and include declarations, variables, functions and rule definitions.
While Drools uses the Rete algorithm to execute rules, developers don't need to be familiar with the approach – though it can help in defining rule sets when filtering facts. There's also support for Leaps, an algorithm which can speed up rules processing. You can define activation groups in JRules, which will group several rules so that if one fires, the rest will be ignored; an approach which works well when managing rule priorities. JBoss's documentation shows the open source nature of the project, with lots of theoretical detail alongside sample code.
Rules are first authored, and then parsed to ensure the rule grammar is correct. Once parsed, the rules are packaged and can be deployed in a runtime RuleBase. You can access the resulting RuleBase from your Java code: facts are delivered as Java objects, and can be asserted or retracted. If you're using decision tables, you can build them in Excel or other spreadsheets – a useful approach which helps business users get to grips with rule definitions in a familiar environment.
Like most JBoss tools, JBoss Rules is free to download. Community support is available online and through a wiki. If you need more support, you can purchase support from JBoss, which will give you access to the development team. If you're customising JBoss Rules or building it into your applications, you'll probably need this level of support.
Development is fast, with new versions released regularly. The next major update, JBoss Rules 3.2 will be released in Q1 2007, and will add new elements to JBoss' rules language, as well as improving the IDE and adding new debugging tools. Future versions will add the missing rule repository, along with a web-based rule development UI.
The ultimate aim of the JBoss team is to deliver a full business management suite. JBoss Rules is part of this vision, though it still falls short of delivering the whole picture. While the current rules engine may not have as many features as its competition, JBoss Rules is a powerful tool, and one that can be used by any Java developer who wants to add a rules engine to an existing application without significant investment. JBoss Rules isn't quite ready for enterprise heavy-lifting, but it certainly packs a hefty middleweight punch.
Sponsored: Magic Quadrant for Client Management Tools