Drools 4.0.2 Released

We just released Drools v4.0.2. This is a minor release with a few improvements on existing features and several bug fixes. We also included a lot of new documentation, specially in the examples section.
Important: there is one backward compatibility break when using Rule Flow. If you use Rule Flow, please check the section 1.2.5 of the manual for details.

We would like to really thanks all the contributors that helped on getting this release out. From those contributing patches and docs, to those testing and reporting bugs and providing feedback. The list is a bit long to post all names here and I may incur in a mistake forgetting someone, so our open public thank you to you all!

This is now the stable version of Drools and from now on, we expect to only release eventual bug fixes in this branch. We are starting now the development of the new major release of Drools and new features shall all be added to it.

For those curious about what is coming, please check previous posts on this blog. Mark’s slides presented at Synasc also talk about several things we want to do for the coming versions.

Follows the release notes.

Happy Drooling
Drools Team

Release Notes

Sub-task

 <ul><li>    [ <a href="http://jira.jboss.com/jira/browse/JBRULES-779">JBRULES-779</a> ]     Better error reporting in the GUI    </li><li>    [ <a href="http://jira.jboss.com/jira/browse/JBRULES-996">JBRULES-996</a> ]     Admin screen option to remove archive items    </li><li>    [ <a href="http://jira.jboss.com/jira/browse/JBRULES-1210">JBRULES-1210</a> ]     Implement support to multi-pattern accumulate to the XML parser.    </li></ul>     <h2><span style="font-size:100%;">Feature Request</span></h2>     <ul><li>    [ <a href="http://jira.jboss.com/jira/browse/JBRULES-910">JBRULES-910</a> ]     upgrade GWT to 1.4    </li><li>    [ <a href="http://jira.jboss.com/jira/browse/JBRULES-944">JBRULES-944</a> ]     Support in Rule Workbench for custom colors    </li><li>    [ <a href="http://jira.jboss.com/jira/browse/JBRULES-1040">JBRULES-1040</a> ]     Multi-pattern accumulate support    </li><li>    [ <a href="http://jira.jboss.com/jira/browse/JBRULES-1098">JBRULES-1098</a> ]     Add action support in ruleflow    </li><li>    [ <a href="http://jira.jboss.com/jira/browse/JBRULES-1107">JBRULES-1107</a> ]     Support for multiple pattern in accumulate source pattern    </li><li>    [ <a href="http://jira.jboss.com/jira/browse/JBRULES-1118">JBRULES-1118</a> ]     Add support for rf, xml and dsrl into drools-ant task     </li><li>    [ <a href="http://jira.jboss.com/jira/browse/JBRULES-1138">JBRULES-1138</a> ]     MVEL code completion does not work for nested expressions    </li><li>    [ <a href="http://jira.jboss.com/jira/browse/JBRULES-1155">JBRULES-1155</a> ]     In Decision Table actions, cannot reference variables that were not referenced in LHS    </li><li>    [ <a href="http://jira.jboss.com/jira/browse/JBRULES-1165">JBRULES-1165</a> ]     StatelessSessionResult should have getGlobal    </li><li>    [ <a href="http://jira.jboss.com/jira/browse/JBRULES-1175">JBRULES-1175</a> ]     soundslike operator    </li><li>    [ <a href="http://jira.jboss.com/jira/browse/JBRULES-1178">JBRULES-1178</a> ]     trivial jbrms issues    </li><li>    [ <a href="http://jira.jboss.com/jira/browse/JBRULES-1183">JBRULES-1183</a> ]     Add global support in ruleflow    </li><li>    [ <a href="http://jira.jboss.com/jira/browse/JBRULES-1184">JBRULES-1184</a> ]     Refresh snapshot binaries if needed    </li><li>    [ <a href="http://jira.jboss.com/jira/browse/JBRULES-1185">JBRULES-1185</a> ]     Add support to RuleBase events on the Event Support system    </li><li>    [ <a href="http://jira.jboss.com/jira/browse/JBRULES-1189">JBRULES-1189</a> ]     Auto coercion of String to date in MVEL actions    </li><li>    [ <a href="http://jira.jboss.com/jira/browse/JBRULES-1196">JBRULES-1196</a> ]     Cannot specify file and dir paths with spaces using RuleAgent properties file    </li><li>    [ <a href="http://jira.jboss.com/jira/browse/JBRULES-1198">JBRULES-1198</a> ]     Add a launch shortcut for debugging drools applications    </li><li>    [ <a href="http://jira.jboss.com/jira/browse/JBRULES-1201">JBRULES-1201</a> ]     Allow rule agent to pick up DRL files and compile as needed    </li><li>    [ <a href="http://jira.jboss.com/jira/browse/JBRULES-1227">JBRULES-1227</a> ]     Add drools-analytics support to drools-ant     </li><li>    [ <a href="http://jira.jboss.com/jira/browse/JBRULES-1228">JBRULES-1228</a> ]     Enums to allow reference to another fields value    </li><li>    [ <a href="http://jira.jboss.com/jira/browse/JBRULES-1236">JBRULES-1236</a> ]     Sort getters alphabetically in drop-down    </li><li>    [ <a href="http://jira.jboss.com/jira/browse/JBRULES-1241">JBRULES-1241</a> ]     Dynamic rules should be able to lock for a series of updates and fireAllRules should be optional    </li><li>    [ <a href="http://jira.jboss.com/jira/browse/JBRULES-1252">JBRULES-1252</a> ]     DrlDumper does not dump import functions    </li><li>    [ <a href="http://jira.jboss.com/jira/browse/JBRULES-1255">JBRULES-1255</a> ]     add alternating coloured rows for rule analysis reporting and allow for user provided css    </li><li>    [ <a href="http://jira.jboss.com/jira/browse/JBRULES-1256">JBRULES-1256</a> ]     publish source jars with maven    </li><li>    [ <a href="http://jira.jboss.com/jira/browse/JBRULES-1257">JBRULES-1257</a> ]     Add Banking Example from John Dunning    </li></ul>     <h2><span style="font-size:100%;">Bug</span></h2>     <ul><li>    [ <a href="http://jira.jboss.com/jira/browse/JBRULES-723">JBRULES-723</a> ]     Eclipse plugin detects error inconsistently and without location information    </li><li>    [ <a href="http://jira.jboss.com/jira/browse/JBRULES-1013">JBRULES-1013</a> ]     Two functions with Janino compiler end up with out of memory error    </li><li>    [ <a href="http://jira.jboss.com/jira/browse/JBRULES-1100">JBRULES-1100</a> ]     BRMS Bug on view source in weblogic    </li><li>    [ <a href="http://jira.jboss.com/jira/browse/JBRULES-1124">JBRULES-1124</a> ]     Code completion does not work for 'with' blocks    </li><li>    [ <a href="http://jira.jboss.com/jira/browse/JBRULES-1141">JBRULES-1141</a> ]     context assist no longer works for functions in the drl.    </li><li>    [ <a href="http://jira.jboss.com/jira/browse/JBRULES-1144">JBRULES-1144</a> ]     Toggling breakpoint gives an exception    </li><li>    [ <a href="http://jira.jboss.com/jira/browse/JBRULES-1145">JBRULES-1145</a> ]     Break points do not work at all    </li><li>    [ <a href="http://jira.jboss.com/jira/browse/JBRULES-1146">JBRULES-1146</a> ]     No variables are shown for Debug points    </li><li>    [ <a href="http://jira.jboss.com/jira/browse/JBRULES-1148">JBRULES-1148</a> ]     Out of memory exception asserting more than 100 facts    </li><li>    [ <a href="http://jira.jboss.com/jira/browse/JBRULES-1151">JBRULES-1151</a> ]     Bulding sources from root folder fails    </li><li>    [ <a href="http://jira.jboss.com/jira/browse/JBRULES-1152">JBRULES-1152</a> ]     my unit tests are hanging with drools 4.0.1    </li><li>    [ <a href="http://jira.jboss.com/jira/browse/JBRULES-1153">JBRULES-1153</a> ]     Accumulate/Collect can't be used in queries    </li><li>    [ <a href="http://jira.jboss.com/jira/browse/JBRULES-1154">JBRULES-1154</a> ]     ClassCastException retrieving query parameters    </li><li>    [ <a href="http://jira.jboss.com/jira/browse/JBRULES-1156">JBRULES-1156</a> ]     WorkingMemoryFileLogger is raising NPE for rules containing unbalanced OR CEs    </li><li>    [ <a href="http://jira.jboss.com/jira/browse/JBRULES-1157">JBRULES-1157</a> ]     threads using one ruleset throws exception    </li><li>    [ <a href="http://jira.jboss.com/jira/browse/JBRULES-1159">JBRULES-1159</a> ]     Function calls or static method calls do not work for the MVEL dialect    </li><li>    [ <a href="http://jira.jboss.com/jira/browse/JBRULES-1164">JBRULES-1164</a> ]     DSL is not working well when mapping includes ()    </li><li>    [ <a href="http://jira.jboss.com/jira/browse/JBRULES-1166">JBRULES-1166</a> ]     BRL not rendering inpattern eval() correctly (for a predicate)    </li><li>    [ <a href="http://jira.jboss.com/jira/browse/JBRULES-1169">JBRULES-1169</a> ]     PredicateConstraint and/or MVEL Constraint issue?    </li><li>    [ <a href="http://jira.jboss.com/jira/browse/JBRULES-1170">JBRULES-1170</a> ]     ClassCastException using dynamic salience    </li><li>    [ <a href="http://jira.jboss.com/jira/browse/JBRULES-1171">JBRULES-1171</a> ]     Nested accessors in "from" clause are not supported in depth more then 2    </li><li>    [ <a href="http://jira.jboss.com/jira/browse/JBRULES-1172">JBRULES-1172</a> ]     In nested accessors "this" keyword is required in front    </li><li>    [ <a href="http://jira.jboss.com/jira/browse/JBRULES-1174">JBRULES-1174</a> ]     debug steps into "when" statement     </li><li>    [ <a href="http://jira.jboss.com/jira/browse/JBRULES-1177">JBRULES-1177</a> ]     Problem when adding dynamic rules to networks with shared AlphaNodes    </li><li>    [ <a href="http://jira.jboss.com/jira/browse/JBRULES-1179">JBRULES-1179</a> ]     Premature rule execution    </li><li>    [ <a href="http://jira.jboss.com/jira/browse/JBRULES-1180">JBRULES-1180</a> ]     java.lang.ClassCastException: org.drools.reteoo.RightInputAdapterNode    </li><li>    [ <a href="http://jira.jboss.com/jira/browse/JBRULES-1182">JBRULES-1182</a> ]     serialized rules using MVEL depend on a compiler class    </li><li>    [ <a href="http://jira.jboss.com/jira/browse/JBRULES-1187">JBRULES-1187</a> ]     Bug in guided editor when you add a boolean restriction field    </li><li>    [ <a href="http://jira.jboss.com/jira/browse/JBRULES-1190">JBRULES-1190</a> ]     Can't use "=" in a DSL expression    </li><li>    [ <a href="http://jira.jboss.com/jira/browse/JBRULES-1191">JBRULES-1191</a> ]     compilation error when consequence has no space between rule mappings    </li><li>    [ <a href="http://jira.jboss.com/jira/browse/JBRULES-1193">JBRULES-1193</a> ]     Getting org.mvel.PropertyAccessException in rule flow actions when using class names without package    </li><li>    [ <a href="http://jira.jboss.com/jira/browse/JBRULES-1202">JBRULES-1202</a> ]     primitive types all return Longs for getValue    </li><li>    [ <a href="http://jira.jboss.com/jira/browse/JBRULES-1203">JBRULES-1203</a> ]     Shadow facts of final classes not working correctly    </li><li>    [ <a href="http://jira.jboss.com/jira/browse/JBRULES-1204">JBRULES-1204</a> ]     Problem with memberOf and/or eval used in collect statement    </li><li>    [ <a href="http://jira.jboss.com/jira/browse/JBRULES-1205">JBRULES-1205</a> ]     AND works in a rule, but OR gives a classCastException    </li><li>    [ <a href="http://jira.jboss.com/jira/browse/JBRULES-1207">JBRULES-1207</a> ]     RuleBase serialization does not handle the process field    </li><li>    [ <a href="http://jira.jboss.com/jira/browse/JBRULES-1208">JBRULES-1208</a> ]     Errors for some OR junctions in LHS conditional elements    </li><li>    [ <a href="http://jira.jboss.com/jira/browse/JBRULES-1211">JBRULES-1211</a> ]     Rules with accumulators cannot be serialized    </li><li>    [ <a href="http://jira.jboss.com/jira/browse/JBRULES-1212">JBRULES-1212</a> ]     Rete throws NoClassDefFoundError when asserting facts with classess loaded by inaccessible classloader.     </li><li>    [ <a href="http://jira.jboss.com/jira/browse/JBRULES-1217">JBRULES-1217</a> ]     RuleFlow Editor -> Constraint Editor -> Imports Editor context help    </li><li>    [ <a href="http://jira.jboss.com/jira/browse/JBRULES-1220">JBRULES-1220</a> ]     Integration with jBPM does not work    </li><li>    [ <a href="http://jira.jboss.com/jira/browse/JBRULES-1221">JBRULES-1221</a> ] org.drools.base.accumulators.CountAccumulateFunction error when building a package with rules including an accumulate construct in Drools BRMS 4.0.1 </li><li>    [ <a href="http://jira.jboss.com/jira/browse/JBRULES-1223">JBRULES-1223</a> ]     Concurrent problem in MVEL    </li><li>    [ <a href="http://jira.jboss.com/jira/browse/JBRULES-1224">JBRULES-1224</a> ]     regular expressions inside mvel expressions require escaping    </li><li>    [ <a href="http://jira.jboss.com/jira/browse/JBRULES-1231">JBRULES-1231</a> ]     Functions do not get added to new BRMS package when package imported from drl file    </li><li>    [ <a href="http://jira.jboss.com/jira/browse/JBRULES-1239">JBRULES-1239</a> ]     Fix class loaders so that creating multiple rulebase with separate class loader hirarchy works    </li><li>    [ <a href="http://jira.jboss.com/jira/browse/JBRULES-1240">JBRULES-1240</a> ]     Remove Dialect state from PackageBuilderConfiguration    </li><li>    [ <a href="http://jira.jboss.com/jira/browse/JBRULES-1244">JBRULES-1244</a> ]     Ruleflows should have a package name    </li><li>    [ <a href="http://jira.jboss.com/jira/browse/JBRULES-1245">JBRULES-1245</a> ]     class cast exception    </li><li>    [ <a href="http://jira.jboss.com/jira/browse/JBRULES-1248">JBRULES-1248</a> ]     <literal-restriction> requires an 'value' attribute, but it can't be null     </literal-restriction></li><li>    [ <a href="http://jira.jboss.com/jira/browse/JBRULES-1253">JBRULES-1253</a> ]     drools-examples-drl  does not work under Java 6 as-is    </li></ul>     <h2><span style="font-size:100%;">Task</span></h2>     <ul><li>    [ <a href="http://jira.jboss.com/jira/browse/JBRULES-683">JBRULES-683</a> ]     Document solver in the manual    </li><li>    [ <a href="http://jira.jboss.com/jira/browse/JBRULES-834">JBRULES-834</a> ]     Setup decent svn:ignore on all modules    </li><li>    [ <a href="http://jira.jboss.com/jira/browse/JBRULES-1082">JBRULES-1082</a> ]     minor changes to the drools documentation    </li><li>    [ <a href="http://jira.jboss.com/jira/browse/JBRULES-1160">JBRULES-1160</a> ]     Update DSL docs to include new features    </li><li>    [ <a href="http://jira.jboss.com/jira/browse/JBRULES-1162">JBRULES-1162</a> ]     Minor corrections in IDE documentation    </li><li>    [ <a href="http://jira.jboss.com/jira/browse/JBRULES-1163">JBRULES-1163</a> ]     Update ORG homepage to be more up to date with 4.0    </li><li>    [ <a href="http://jira.jboss.com/jira/browse/JBRULES-1200">JBRULES-1200</a> ]     Documentation for Number Guess Example    </li><li>    [ <a href="http://jira.jboss.com/jira/browse/JBRULES-1206">JBRULES-1206</a> ]     ParserException on misplaced parenthesis    </li><li>    [ <a href="http://jira.jboss.com/jira/browse/JBRULES-1233">JBRULES-1233</a> ]     Solver should use slf4j, like jbrms    </li><li>    [ <a href="http://jira.jboss.com/jira/browse/JBRULES-1237">JBRULES-1237</a> ]     Upgrade MVEL library to 1.2.final    </li><li>    [ <a href="http://jira.jboss.com/jira/browse/JBRULES-1238">JBRULES-1238</a> ]     Upgrade BRMS to use jboss seam version 2.0     </li></ul>

OSWorkflow Books and Drools Integration Chapter

Diego Adrian Naya Lazo has just published an OSWorkflowBook “OSWorkflow: A guide for Java developers and architects to integrating open-source Business Process Management”.

I’ve no idea if the book is any good or not but it has a whole chapter on Drools integration:
Chapter 5 introduces and integrates Rules engine and Drools open source rule engine.

So if anyone reads this book, please do post us a review we can place here. And Diego, any chance you could email me chapter 5, as a free sample ๐Ÿ™‚

What I found more interesting is that a non JBoss workflow engine put in a chapter about Drools integration, but the JBoss jBPM book “Business Process Management with JBoss jBPM” didn’t. I did notice that the book refers to us as just Drools, I hope somewhere prominently in the chapter that JBoss are given credit.

Relocation relocation & repository progress (Michael Neale)

Well I have had a great time in London, but it has gone fast. The entire purpose of this extended trip was to spend quality time with Mark so we could put our heads together and solve some of the hard design issues for the rules repository and version 3.2 (which who knows, may be called version 4?). I think we have achieved a lot.

So sad to be leaving, but also will be nice to be “home” again, still doing the same job of course ! (amazing how hard it is for people to understand that who have “real” jobs).

The rules repository has come along nicely (and we have of course been thinking about the often requested ability to package up process definitions a-la jBPM as well, but that’s another story).
So a quick update is in order I believe.

User driven categorisation is working out nicely:

They allow a simple hierarchical classification scheme (of your choice). Thanks to the magic of power arithmetic, you can manage a very large number of rules with a very shallow “tree” of categories. We don’t have user specified fields (yet) but its easy to add – initially we want to encourage people to manage rules in something of a standard way (of course, we are prone to being influenced by peoples opinions).

Dublin core makes for a kind of useful set of standard “content attributes” that people can attach meaning to (with the hope that external systems in the future will be able to report and examine the rule base in a meaningful way).

The rule modeller (UI) mentioned before is also working out nice.

Of course, all the meaty stuff has been happening under the covers, so not much time to work on Look and Feel, but that should be changing shortly. Other rule authoring paradigms are plugging in as well. Of course, and it is all being integrated to work with the IDE tooling as much as possible.

Efficient versioning: Every save action in the repository is version ed. This (default) behavior may cause some alarm, due to the number of versions created. Thankfully, the concept of “workspaces” for storage means that the version storage can (if needed) be configured to be on a separate larger device/database to the main repository, allowing for huge rule bases to scale, very handy.

In other news, the “mvel” integration (a simple expression language) is coming along, and should be in the M1 release (more about that in another blog).
We also now have effective dating of rules, which is a handy (and often asked for feature, but often forgotten about-to-implement).

The next steps for the repository (which is as much a list to remind me after I get over the wicket jetlag that is about to hit):
* Archiving of rules (not as easy as it sounds, at least to make it usable).
* Audit logging and reporting (a lot of audit ability is intrinsic to the repository, but still, I have seen many an audit log grow unusable over time).
* Efficient introspection of the rule object model (as we are still pojo based, requires some magic)
* Keeping configuration options under control ๐Ÿ˜‰ want it to be as “out of the box” as possible and not terrify people with the possibilities !
* Version browser (started this on Friday, ran out of time !)
* Package management
– packages are sets of rules, which are “baseline” versioned for deployment. This will provide a more technical view of the rule assets in a tree structure (so you can view rules either via categories, or packages). Need to make this as intuitive as possible with sensible defaults.

Comments.

Rules with no code – Michael Neale

Often you hear/read/see adds for tools (rules or workflow) that claim breathlessly “look ma ! no code” – “rules with out code” – giving control back to the business etc.

(if you haven’t, then you obviously have a good marketing detector, and are able to mentally filter out marketing messages). Some products live up to this impossible claim more then others (and some a despicable lies, of course never in the rules community !).

An impossible claim? What did you say?

I say “impossible” in the sense of the definition of “Code” as it appears in the adds. If you take code to mean “ascii or UTF-8 files written in a textual programming languages with file extensions like .java, .c, .rb, .py, in an IDE or programmer focused editor” then I would say its not impossible. But what is “code” really? Lets presume it means a programming language (as opposed to “The Davinci Code”). What is a programming language? Basically symbolic instructions for a machine to understand that makes it do something (I am sure many folks can come up with better definitions). Who said these instructions had to take ascii form? a visual graph (a la jBPM, a JRules decision tree or a Corticon “rule sheet” for instance) could be thought of as “code” itself.

To some this may be irritating semantics, but to less technical people its important to understand what they are getting into. So I should clarify, even when you are using “no code” you are still using “a code” – its just a higher level sort. In many cases this is a Good Thing ! But people do need to still think logically, without ambiguity or woolly headed-ness – machines just will not tolerate it !

I have seen great demos of tools by Corticon (they use clever techniques with a visual decision table metaphor, but its more then a decision table), and I hear good things about Haley Adviser for natural language. I saw great demonstrations of Rule Burst’s document based rule management, JRules supports multiple textual and visual rule metaphors with a myriad of smart editors. All really great tools of course, but in their own way, still “a code” is being authored, its just a code (programming language) that is higher level, and close to the domain and perhaps in a more natural or visual form then “ordinary code”. You can’t wave your hand at these tools and magically have consistent rules (maybe you can in the latest versions ;). You still need to be logical – the tools will do a lot of the heavy lifting, but precision is still required from you, the user, in your logic and intent, and design decisions.

To burst a few bubbles, no one will EVER have true free form natural language for rules. For starters, we don’t have exhaustive technology to make computers understand natural language without a very very narrow scope. But MORE SIGNIFICANTLY, even if we did, we would still not have NL rules. Why? because our human languages are deeply flawed, in terms of logic. So even if we technically could have NL rules, other then a few spectacular (and possibly dangerous) failures they would be abandoned in favour of a controlled language of some form.

Have you ever given detailed instructions to a builder for your house renovations, yet still been disappointed? (ask Mark !). Natural language is not a language of logic, or accurate specification of instructions.

As a kid I used to earn pocket money by typing up papers for my father (who is a lawyer) and became familiar with various styles of legal language, legislation (as well as my fathers handwriting, which was much harder). They are worded in a very very formal way, yet fail to come even close to the accuracy of logic that symbolic programming languages provide (and they are not readable other then by experts) – most legislation needs to be tested in courts to be workable, it needs Explanatory Memorandums to patch up the gaping holes etc. This is not what people want when they talk about natural language rules, or “rules with no code”.

In summary, whatever your tool of choice, you will still be using “a code” of sorts, and you will not be able to provide the vague sort of instructions to a rule document authoring system that you used to email to assistants, and hope it to work. That is not to devalue these tools at all, its just reality.

And happy new year ! Welcome to the world of tomorrow !

Comments.

Declarative Behavioural Modelling (DBM) and jBPM/JBoss Rules integration

Production Rule systems, such as JBoss Rules are just one form of declarative programming; I believe that to meet the challenges of tomorrows technology we need to be looking at a unified tooling and platform approach to declarative programming. Workflow/BPM has been the predominant declarative approach for a while and Production Rules are one of the first technologies from the AI family to go mainstream. One of the nice things about Production Rule systems is they can be expanded to handle a number of domains declaratively and a variety declarative tooling can be built on top – as shown in the diagram below. I hope to use JBoss Rules as a vehicle to bring more of these technologies into the mainstream – Event Stream/Management Processing, Backward chaining and Constraint Programming are all essential items to a modern enterprise and each allows you to model the different behaviours of your system – I see these as shorter term goals. Genetic Algorithms, GIS, Neural Networks and the Semantic Web are all interesting long term goals.

For now we need to focus on the two mainstream technologies rules and workflow and figure out how provide a much needed unified modelling environment.

Deployment
Declarative programming often involves the generation of content which can expose a whole heap of problems. The jBPM way is to own the control of this using their deployment tool to couple the process definition and the java classes. You write your process definition xml file and select its dependant class files which it then deploys as a PAR; which is a JAR containing the xml file and the compiled dependant classes. This gives you control over the java classes, making sure that a particular process definition always works with the correct version of the java classes. We can extend this to allow the process definition xml to reference one ore more drl files which it then makes available as a rulebase using variable reference in the jBPM context. There are two ways we can approach this. Either jBPM compiles the rulebase to a binary and serialises that to the PAR and reducing the runtime dependencies or it can add the drl to the PAR needing a runtime compilation of the drls into Rule Bases. Users can then easily look-up and reference the working memory from their own concrete handler implementations.

While this is an effective and simple way to solve the deployment problem it has a number of downsides. The PAR has ownership of those java classes and their versions, this may clash with existing deployed classes for other applications – so care needs to be taken here. While processes rarely change and many consider them to be code and thus more suited to the traditional development and deployment, rules on the other hand are both code and data and can have continual updates – this can make traditional deployment systems quite cumbersome. Further to this large organisations can have thousands of processes and tens of thousands of rules – suddenly maintaining this in a standard source control management system doesn’t sound so appetising.

The next release of JBoss Rules will include a BRMS which will allow a more enterprise approach to management of rules, please see my previous blog “JBoss Rules Server” for more details on this. The basic idea is that all rules are stored in the BRMS where they are versioned with full meta data and categorised, I can configure specific versions of those rules into a RuleBase that I can then make available – the rule base itself is also versioned. With this approach the jBPM process definition can specify a URI to the BRMS for the rule base it needs, which is lazy retrieved on first use. While this does provide better management for a large number of rules the key benefit this provides is that the application and the BRMS are now aware of each other and the BRMS can feed the application regular updates to the rule bases its using; allowing rules to live up to their role of being data.

If this approach proves successful we can look at managing other knowledge assets within the BRMS, such as the classes and the process definitions themselves. We can build versioned bundles which depend upon other versioned bundles which means that during deployment we can have a more fine grained way to solve the initial problem of the PAR owning the classes – with this approach it would be up to the server to manage versions and bundle dependencies. OSGi tries to solve some of these issues, and its something I want to explore as a long term solution to this.

Tooling
The previous section covered deployment; which is actually very boring and not of interest to most users. What they are really interested in is the tooling. Currently jBPM nodes are handler based; you create a concrete class that implements an interface and retrieves the variables it needs from the jBPM context, the jBPM node then specifies that class as its handler. While simple this concept is very powerful in its flexibility and is one of jBPM’s strong points and why it is favourite with BPM developers. However there are times when you want something a bit more integrated and declarative, especially when working hand in hand with business users. We can’t integrate DRLs any more than the previous deployment example provides; however as the above diagram shows Production Rule systems facilitate a number of very good ways to declaratively author rules, the most common of which are decision trees, decision tables, score cards, structured natural language, gui driven rule authoring and rule flow. What users really want is an ability to specify one of these authoring tools and apply them to a jBPM node so that they can declaratively control the decision or task node – this offers real value. Further more the “glue” to hold these together, i.e. the passing of the relevant variables from the jBPM context and the calling and execution of the rules must be handled seamlessly in the background. I expect that the actually author page should be embedded in one of the existing jBPM process tabs in eclipse.

Stateful
The above sections cover the stateless use of JBoss Rules with jBPM, this means that the life time of a working memory is for the execution of the current node, there are no long lived Working Memories. The reason for this is because jBPM supports the persistence of long lived processes, it is not generally expected that a Working Memory will be suspended and persisted else where. For this reason we currently consider it an exercise for the end user to manage, although we will try and provide a number of useful enhancements to enable JBoss Rules to play well in this environment.

DBM
So far I have only covered the unification of a Production Rule system and Workflow/BPM system; however this still only allows you to model a specific and limited set of problems. For a bit of background many of you may have heard of the AI Winter where AI was hyped and failed to deliver and has been relegated to mostly academic areas. Production Rules is one of the AI technologies now going mainstream, even though itโ€™s been around for 25 years – whatโ€™s enabling this? I think it’s mostly due to good tooling and better documentation, mere mortals are simply not able to work in shell environments and be productive, let alone decipher some cryptic paper on how to use and implement a specific technology. Many of the other technologies have worked in silos again with limited or no tooling. Both probability/uncertainty and genetic algorithms have had a number of papers showing how they can work well with a Production Rule system, yet this hasn’t had any real uptake. It is my hope that the introduction of those systems into JBoss Rules with good tooling and documentation can help take these technologies such as these mainstream and improve the way software is written. With the way that hardware is scaling with the move to multi core processors and grid computing existing procedural ways of programming will not be enough and we will need paradigms such as these and distributed agent computing to really make the most of these environments.

Post Comment

Just say no to DynaBeans

The subject of DynaBeans just came up on the mailing list, and it is one I’ve been asked about before – so I thought I would do a blog my answer.

Dynabeans was written as a solution for Struts back in 2000, they are not JavaBean compliant โ€“ thus they have no value outside of that provided with commons BeanUtils, thus coupling your enterprise system to BeanUtils forever โ€“ no other apps are aware of them, or able to script them like they can JavaBeans. They cannot be used with any database schema mapping tools, so you cannot easily leverage db schema generation tools. JBRules 3.0 has no support for mapping utilities thus youโ€™ll only be able to script those from within evals. If you only use evals you will have crippled the engine to work like a simple chain of command scripting engine โ€“ under no circumstances do I recommend this. Evals are a worst use case for conditions that cannot be expressed in field constraints, as field constraints and conditional elements become more powerful the dependency of evals is reduced. Further more DynaBeans are backed by a map, each read or write results in a hashmap read or write โ€“ this is not a scalable solution.

A much better solution that works now for JBRules 3.0 is to have runtime class generation. See this blog entry here: http://sixlegs.com/blog/java/death-to-dynabeans.html

Tools like cglib make this trivial now:


BeanGenerator bg = new BeanGenerator();
bg.addProperty("foo", Double.TYPE);
bg.addProperty("bar", String.class);
Object bean = bg.create();

That produced bean can have hibernate mappings generated at runtime, so youโ€™ll get runtime hibernate support. JBRules can compile drls at runtime using the classloader those beans where generated with thus providing full field constraint use of them and pojo like access in the consequence – much nicer ๐Ÿ™‚

For JBRules 3.2 we will provide a feature called FactTemplates โ€“ this is akin to jess/clips DefTemplates. These allow people to define Facts without the need for a compiled class, which is preferable to some who want complete encapsulation of their rules and business objects within the drl. FactTemplates are backed by an array and thus read/writes are much faster. FactTemplates support both named and int values to specify the field for the value; named set/get result in a HashMap lookup so have similar performance to DynaBean. However JBRules provides compile time optimisation of those named fields and swaps them to int lookups โ€“ we will have support for this in the JFDI language too, which we also hope will be support in jBPM. FactTemplates will also provide mapping facilities which means they can be mapped to any underlying structure โ€“ be it JavaBean, a Hashmap or a DynaBean.

Post Comment

Just say no to DynaBeans

The subject of DynaBeans just came up on the mailing list, and it is one I’ve been asked about before – so I thought I would do a blog my answer.

Dynabeans was written as a solution for Struts back in 2000, they are not JavaBean compliant โ€“ thus they have no value outside of that provided with commons BeanUtils, thus coupling your enterprise system to BeanUtils forever โ€“ no other apps are aware of them, or able to script them like they can JavaBeans. They cannot be used with any database schema mapping tools, so you cannot easily leverage db schema generation tools. JBRules 3.0 has no support for mapping utilities thus youโ€™ll only be able to script those from within evals. If you only use evals you will have crippled the engine to work like a simple chain of command scripting engine โ€“ under no circumstances do I recommend this. Evals are a worst use case for conditions that cannot be expressed in field constraints, as field constraints and conditional elements become more powerful the dependency of evals is reduced. Further more DynaBeans are backed by a map, each read or write results in a hashmap read or write โ€“ this is not a scalable solution.

A much better solution that works now for JBRules 3.0 is to have runtime class generation. See this blog entry here: http://sixlegs.com/blog/java/death-to-dynabeans.html

Tools like cglib make this trivial now:


BeanGenerator bg = new BeanGenerator();
bg.addProperty("foo", Double.TYPE);
bg.addProperty("bar", String.class);
Object bean = bg.create();

That produced bean can have hibernate mappings generated at runtime, so youโ€™ll get runtime hibernate support. JBRules can compile drls at runtime using the classloader those beans where generated with thus providing full field constraint use of them and pojo like access in the consequence – much nicer ๐Ÿ™‚

For JBRules 3.2 we will provide a feature called FactTemplates โ€“ this is akin to jess/clips DefTemplates. These allow people to define Facts without the need for a compiled class, which is preferable to some who want complete encapsulation of their rules and business objects within the drl. FactTemplates are backed by an array and thus read/writes are much faster. FactTemplates support both named and int values to specify the field for the value; named set/get result in a HashMap lookup so have similar performance to DynaBean. However JBRules provides compile time optimisation of those named fields and swaps them to int lookups โ€“ we will have support for this in the JFDI language too, which we also hope will be support in jBPM. FactTemplates will also provide mapping facilities which means they can be mapped to any underlying structure โ€“ be it JavaBean, a Hashmap or a DynaBean.

Post Comment

What is a Rule Engine

Drools is a Rule Engine but it is more correctly classified as a Production Rule System. The term “Production Rule” originates from formal grammer – where it is described as “an abstract structure that describes a formal language precisely, i.e., a set of rules that mathematically delineates a (usually infinite) set of finite-length strings over a (usually finite) alphabet”. Production Rules is a Rule Based approach to implementing an Expert System and is considered “applied artificial intilligence”.

The term Rule Engine is quite ambiguous in that it can be any system that uses rules, in any form, that can be applied to data to produce outcomes; which includes simple systems like form validation and dynamic expression engines: “How to Build a Business Rules Engine (2004)” by Malcolm Chisholm exemplifies this ambiguity. The book is actually about how to build and alter a database schema to hold validation rules which it then shows how to generate VB code from those validation rules to validate data entry – while a very valid and useful topic for some, it caused quite a suprise to this author, unaware at the time in the subtleties of Rules Engines differences, who was hoping to find some hidden secrets to help improve the Drools engine. jBPM uses expressions and delegates in its Decision nodes; which controls the transitions in a Workflow. At each node it evaluates a rule that dicates the transition to undertake – this is also a Rule Engine. While a Production Rule System is a kind of Rule Engine and also Expert System, the validation and expression evaluation Rule Engines mention previously are not Expert Systems.

A Production Rule System is turing complete with a focus on knowledge representation to expression propositional and first order logic in a concise, non ambigious and declarative manner. The brain of a Production Rules System is an Inference Engine that is able to scale to a large number of rules and facts; the engine is able to schedule many rules that are elegible for execution at the same time through the use of a “conflict resolution” strategy. There are two methods of execution for Rule-Based SystemsForward Chaining and Backward Chaining; systems that implement both are called Hybrid Production Rule Systems. Understanding these two modes of operation are key to understanding why a Production Rule System is different.

Forward Chaining is ‘data-driven’ and thus reactionary – facts are asserted into the working memory which results in rules firing – we start with a fact, it propagates and we end with multiple elegible Rules which are scheduled for execution. Drools is a forward chaining engine. Backward Chaining is ‘goal-driven’, we start with a conclusion which the engine tries to satisfy. If it can’t it searches for conclusions, ‘sub goals’, that help satisfy an unknown part fo the current goal – it continues this process until either the initial conclusion is proven or there are no more sub goals. Prolog is an example of a Backward Chaining engine; Drools will adding support for Backward Chaining in its next major release.

The Rete algorithm by Charles Forgy is a popular approach to Forward Chaining, Leaps is another approach. Drools has implementations for both Rete and Leaps. The Drools Rete implementation is called ReteOO signifying that Drools has an enhanced and optimised implementation of the Rete algorithm for Object Oriented systems. Other Rete based engines also have marketing terms for their proprietary enhancements to Rete, like RetePlus and Rete III. It is important to understand that names like Rete III are purely marketing where, unlike the original published Rete Algorithm, no details of implementation are published; thus asking a question like “Does Drools implement Rete III?” is nonsensical. The most common enhancements are covered in “Production Matching for Large Learning Systems (Rete/UL)” (1995) by Robert B. Doorenbos

Business Rule Management Systems build value on top of an Rule Engine providing systems for rule management, deployment, collaboration, analysis and end user tools for business users. Further to this the Business Rules Approach is a fast evolving and popular methodology helping to formalise the role of Rule Engines in the enterprise.

For more information read the following two chapters from the manual:
Introduction and Background
Knowledge Representation

Post Comment