Open Your Business Rules!                     
Rules-based Operational Decision Services

External Rules

While by default OpenRules expects rules to be defined in Excel files, you may create and maintain your business rules in many other external sources:

  • Database tables created and modified by standard DB management tools

  • Live rule tables in memory dynamically modified by an external GUI

  • Java objects of the predefined type for different rule tables

  • Rule tables described in XML files in your preferred format

  • Problem-specific rule sources that implement a generic rules providing interface.

With external rules you may keep the business parts of your rules in any external source while the technical part (Java snippets) will remain in an Excel-based template, depending on which actual rules will be created by the OpenRulesEngine. For example, you may keep your rules in a regular database table as long as its structure corresponds to the columns (conditions and actions) of an Excel template. Thus, the standard DB management tools, or even your own GUI that maintains these DB-based rule tables, become your de-facto rules management environment.

The external rules may also support a preferred distribution of responsibilities between technical and business people. The business rules can be kept and maintained in a database or other external source by business analysts while developers can continue to use Excel and Eclipse to maintain rule templates and related software interfaces.

Starting with the release 5.3 OpenRules provides a generic Java API for adding business rules defined in different external sources. There is a special constructor

OpenRulesEngine(String excelFileName, ExternalRules rules)

that has an additional parameter of the predefined Java type ExternalRules. You may create an object of this type such as

ExternalRules externalRules = new ExternalRules();

and then add different rule tables using the method:

addRuleTable(String ruleTableName,
                  String ruleTemplateName,
                  Object[][] ruleGrid);

The complete API is described at OpenRules API. This simple interface gives a developer the ability to bring rules from any external source and add them to OpenRulesEngine as regular Java objects. If the rules in the external source are changed, a developer may notify the ExternalRules object about this fact by using the method

externarRules.setModified(true);

Then during the next rule engine's run, all rules will be dynamically reloaded. 

OpenRules provides 5 sample projects that demonstrate how to use External Rules:

ExternalRulesFromJava:

shows how to define rules as Java objects

ExternalRulesFromDB:

shows how to define rules in MS Access using JDBC

ExternalRulesFromXML:

shows how to define rules in XML files

ExternalRulesFromExcel:

shows how to define rules as Excel Data tables

ExternalRulesFromGUI:

shows how to build a web application that allows a user to change and execute rules on the fly without a restart

These projects can be found in the standard OpenRules installation under the section "External Rules".  Click to the proper links above to read step-by-step instructions about these projects.

External rules can be invoked from regular rules described in Excel files. Because these external rules are not known until run-time, OpenRules' Validator will produce warnings about these yet unknown rules, but the OpenRulesEngine will still execute them without problems. To suppress the warnings and to keep track of all participating rules, you may fill out a newly introduced optional table of the type "ExternalRules" that lists names of all external rules along with their templates as in the following example:

ExternalRules
greetingRules defineGreeting
salutationRules defineSalutation

 

Top