16.5. Using Rule Services with JBoss Rules

The JBoss Enterprise SOA Platform's rule service allows you to deploy business rules, written by your firm's business analyst in JBoss Rules, as services on the ESB. This has two major benefits:
  • the amount of client code required to integrate the rules into your application environment is dramatically reduced.
  • rules can be accessed from either an action chain or from within an orchestrated business process.

Note

The JBoss Business Rules Management System is the supported option but you can also use a rule engine if you so desire.
The rule service functionality is provided by the BusinessRulesProcessor and DroolsRuleService action classes, the latter of which also implements the RuleService interface.
The BusinessRulesProcessor class allows rules to be loaded from the class-path. These rules are defined in .drl and .dsl files, and also in decision tables (which come in .xls format). These file-based rules exist primarily for the purpose of allowing you to test prototypes. There is no way to specify multiple rule files for a single BusinessRulesProcessor action. More complex rule services require the use of the JBoss Rules KnowledgeAgent.
The RuleService uses the KnowledgeAgent to access rule packages from either the Business Rules Management System or from the local file system. Rule packages can contain thousands of rules from different sources, including these:
  1. the JBoss Business Rules Management System
  2. imported DRL files
  3. domain-specific language (DSL) files
  4. decision tables

Important

Red Hat recommends that you use the KnowledgeAgent approach on production systems.
The BusinessRulesProcessor action supports both of JBoss Rules' execution models, namely the stateless and stateful models.
Most rule services will adhere to the stateless model. In this model, a message will be sent to the rule service containing all the facts that are to be processed by the rule engine. The rules then execute and update the message and/or facts.
By contrast, a stateful execution takes place over a longer period time, with several messages being sent to the rule service. Each time a message is sent, the rules are executed again and the message and/or facts are updated. At the conclusion of the process, a final message tells the rule service to dispose of the stateful session's working memory , which is then purged from the rule engine.

Important

RuleAgent is no longer used in the SOA Platform's ESB. It has been replaced by the KnowledgeAgent which is configured differently. The Polling configuration for DRL changes is no longer done via the ruleAgentProperties file's poll property). You now configure it globally via the org.jboss.soa.esb.services.rules.resource.scanner.interval property, found within esb.deployer/jbossesb-properties.xml . (The default value is 60.) This means that every sixty seconds, the system checks for resource changes across all KnowledgeAgents.
You will need to provide these properties to access URLs that are secured with basic authentication:

username=admin password=admin enableBasicAuthentication=true

Note

There can only be a single rule service in the message flow in the stateful model.