
Business Rules are everywhere in business applications. Business policies, user interface’s validation rules, elevation/escalation rules, dynamic assignment rules, data loading rules etc. It is safe to say – behind every successful business application, there are business rules.
Business rules brings in transparency and agility to business applications. Infusing quick, sustainable customization of rules leads to business agility. Along with it, if the system allows business analysts and auditors to view the translated (code) version of business policies and validate the precision of translating business policies as business rules, then such applications are termed as transparent applications.
Business policies and there effective implementation can be possible with a business rule engine. This blog post drills into rule engine and define the qualifiers for choosing rule engine. Blog also covers Oracle Business Rules (OBR), Oracle Policy Automation (OPA) and showcase difference between OBR and OPA. For sake of convenience, this blog is divided into three parts – part one delves into rule engine, part two drills into OBR, OPA and algorithms while part three focus on OPA vs OBR.
Blog covers following topics –
A software system that provides an engine for the execution of business policies (as rules) is termed as business rule engine (BRE). Business policies can be legal regulations, business policies, validation rules, translation rules; operational rules like assignment rules, escalation rules etc. A BRE allows creation, modification and maintenance of such business policies as separate entity from the business application (code) and data.
Business applications like workflows, user interfaces and supporting components like integration etc. are meant for executing business functions. However, Business rules induces knowledge to business applications and business rules produces knowledge. Example, a 22 year male is buying a sports car of red color. Such business scenario can lead to events (via underlying messaging framework) to create business knowledge (example evaluating regulatory laws, insurance laws etc.). However, a workflow or a business application will only reach to such event. Maybe, that event is captured by the workflow, which again triggers business rules to route such approval requests to someone authorized. Here, following are the interesting pieces –
Here, workflow represent the business logic and business rules represent the business policies. But there is a separation between them. This allows greater reuse of the business rules, allows centralization of rules, and allows separate lifecycle of creating, modifying and maintaining the rules. From the design and architecture perspective, separation of business logic from business policies (as rules) is the recommended approach. However, from product prespecitve, many vendors offers native integration. Example Oracle’s BPM/SOA integrated with Oracle business rules (OBR). Alternatively, applications can also connect with rules engines like Oracle policy automation via a service invocation or APIs.
Business have business rules and rule engine offers the core to execute ‘business rules’. Business rules are the coded version of business policies, which leads to a business decision. Example – If Car is red and car is a sports car and the driver is a male less then 22 years of age then increase insurance premium by 15 %.
Based on rules scheduling, there are different types of rules engine – forward chaining and backward chaining rules engine. Backward chaining are goal driven and facts are resolved to reach a specific goal. Forward chaining rule engine are either inference rules or reactive rules. Inference rules uses condition-action model to represent rules while reactive rules detect events, processes event patterns and reacts based on it example complex event processing.
Weather you need a rule engine or not, can be gauged with matching your use case and requirements and weighing the benefits of rules engine vs complexity of not having a rule engine. Rules can be embedded in the programs itself or can be in a rule repository, which is used by rule engine. Rules engines are not singular, they comes with tools and GUI to manage, edit rules and options to deploy, version and administer rules. Defining nature of rule engine, comes from the rule algorithms that drives it. Example RETE, LEAPS etc. They connect facts with rule, determines the order, chaining, conflict resolution and the execution of the rules. This section, we enlist few of the qualifiers for using rule engine.
Following are the qualifies for using Rule Engine

We discussed about imperative and declarative model above, hence it is important for me to delve into it, in this section.
Imperative model consists of sequenced commands with loops, conditions. Essentially, imperative model focus on HOW, where the program dictates HOW to do it. On the other hand, declarative model consists of rules, which have a condition and an action. Declarative model focus on WHAT and defines what needs to happen instead of how it needs to happen. Imperative model involves righting extensive code with many steps to solve problems and to reach decisions (desired results). These code instructions are dictating system HOW to perform something. Codes can turn out so overwhelming and focus gets shift towards the code and its maintenance rather than rules. Besides that, such code are distributed and maintenance of it will soon turn into a nightmare. On the other hand, rule engines are declarative computational model.
Rule engine (declarative computational model) have following advantages –
No Rule Engine (Imperative computation model) has following disadvantages –
Declarative models allows expressing business policies (aka rules) in simple logic or natural language, allowing reasoning and reaching decisions more obvious to those, who author and maintain policies/rules. Ordering, chaining, conflict resolution etc. of policies is automatically taken care by the rule engine, which takes care of correct evaluation of the business policies.
Following section covers Oracle Business rules, offers a glimpse to Oracle policy automation (OPA) and compares them from various use case perspective. Forward chaining System, Inference Cycle, declarative models of rule engine are exclusively added in below section to allow readers to correlate above rule engine section with OBR and OPA sections below.
When an application can be view by business analyst or auditor and they can determine that an application can precisely implement’s business policies, it can be termed as transparent application. Example insurance, human resourcing, financial services etc. OBR offers efficient development and deployment of business rules. OBR consists of rule authoring tool for defining rules, an SDK for rule access and a rule engine for execution of rules.
Oracle business rules adds flexibility to applications and processes by empowering analysts and process owners to define, edit business rules. With OBR, application’s business logic is separate from rules, allowing agile rule maintenance and creates empowered business analysts and process owners. The Oracle Business Rules includes following components –
Users can use business rules editor [rules designer or rule composer] and rules are stored and managed in a central business rules repository. You can reference pre-defined business process rules within the modeler. The Business Rules activity in the business process model gets converted to a decision service that in turn invokes the business rules engine in the executable business process. Business users can change these business policies on the fly via an intuitive web browser interface without having to redeploy or re-implement the business process.

Business rule comprises of following –
The Oracle Business Rules environment is implemented in a JVM or in a J2EE container by the classes supplied with rl.jar. The RL Language command-line interface provides access to an Oracle Business Rules RuleSession. The RuleSession is the API that allows Java programmers to access the RL Language in a Java application (the command-line interface uses a RuleSession internally).
An RL Language ruleset provides a namespace, similar to a Java package, for RL classes, functions, and rules. In addition, you can use rulesets to partially order rule firing. A ruleset may contain executable actions, may include or contain other rulesets, and may import Java classes and packages. An RL Language rule consists of rule conditions, also called fact-set-conditions, and an action-block or list of actions. Rules follow an if-then structure with rule conditions followed by rule actions.
OBR rules can be modelled using follows ways –
If/Then rules written using following approaches –
Note - Rules and Decision Tables are grouped in an Oracle Business Rules object called a ruleset. You group one or more rulesets and their facts and valuesets in an Oracle Business Rules object called a dictionary
Rule comprises of rule condition and rule actions. Rules are used to evaluate conditions and specify actions when the conditions are met (evaluate to true).
Note – Rule activation is different from rule firing.
The rule condition activates the rule whenever a combination of facts makes the conditional expression true. In some respects, the rule condition is like a query over the available facts in the Rules Engine, and for every row returned from the query the rule is activated.
The rule action aka rule THEN part contains the actions that are executed when the rule is fired. A rule is fired after it is activated and selected among the other rule activations using conflict resolution mechanisms such as priority. A rule might perform several kinds of actions. An action can add facts, modify facts, or remove facts. An action can execute a Java method or perform a function which may modify the status of facts or create facts.
Note - Rules fire sequentially, not in parallel. Note that rule actions often change the set of rule activations and thus can affect which rule fires next.
A rule action is activated if all of the rule conditions are satisfied. There are several kinds of actions that a rule's action-block might perform. For example, an action in the rule's action-block can add new facts by calling the assert function or remove facts by calling the retract function. An action can also execute a Java method or perform an RL Language function. Using actions, you can call functions that perform a desired task associated with a pattern match.
The Oracle Rules Engine first matches the facts against the rule conditions of all rules as the state of working memory changes. A group of facts that makes a given rule condition true is called a fact set row. A fact set is a collection of all the fact set rows for a given rule. Thus a fact set consists of the facts that match the rule conditions for a rule. For each fact set row in a fact set, an activation, consisting of a fact set row and a reference to the rule is added to the agenda (the agenda contains the complete list of activations).
Rules fire when the Oracle Rules Engine removes activations, by popping the activations off the agenda and performing the rule's actions.
The Oracle Rules Engine may remove activations without firing a rule if the rule conditions are no longer satisfied. For example, if the facts change or the rule is cleared then activations may be removed without firing. Further, the Oracle Rules Engine removes activations from the agenda when the facts referenced in a fact set row are modified or the facts are retracted, such that they no longer match a rule condition (and this can also happen in cases where new facts are asserted, when the ! operator applies).
Oracle Business Rules provides high performance and easy to use implementation of Business Rules technology. It provides easy to use authoring environment as well as a very high performance inference capable rules engine. Oracle Business Rules is part of the Oracle Fusion Middleware stack and will be a core component of many Oracle products including both middleware and applications.
For internet based business applications, there are three primary layers for applications – presentation layer (user interface aka display layer), business logic layer (middle layer) and policy layer (rules engine layer). This is ideal for rule enabled application, policy logic is separated from business logic and its written as business rules (if-else, decision matrix or declarative form). Business logic can be written in Java or Java based technology etc. while rules are authored as business policy and implemented as set of rules, which are executed by a rule engine.
Below diagram shows the architecture of OBR. Here, business policy are executed in rule engine, where facts are analyzed and results are returned. Rule authoring GUI [or applications using rules SDK], allows rule creation, which are stored in rule repository and rule engine refers to this repository for rules execution.

Oracle business rule is written in Java and is integrated with XML and Java. OBR constitutes of following components – Rule engine, Rules SDK and Rule authoring tool. Authoring tools offers if-else, decision matrix and English-like paradigm for declaring rules.
In OBR, the rule-based system is a data-driven, forward chaining system. The facts determine which rules can fire so when a rule fires that matches a set of facts, the rule may add facts and these facts are again run against the rules. This process repeats until a conclusion is reached or the cycle is stopped or reset. Thus, in a forward-chaining rule-based system, facts cause rules to fire and firing rules can create more facts, which in turn can fire more rules. This process is called an inference cycle.

A rule-based forward chaining system consists of the following:
With OBR you can use declarative rules, where you create rules that make declarations based on facts rather than coding. Here is an example of declarative rules:
IF a Driver is a Premium customer, offer them 20% discount
IF a Driver is a Gold customer, offer them 10% discount
Advantages of declarative rules -
When a rule adds facts and these facts run against the rules, this process is called an inference cycle. An inference cycle uses the initial facts to cause rules to fire and firing rules can create more facts, which in turn can fire more rules. For example, using the initial facts, Rules Engine runs and adds an additional fact, and an additional rule tests for conditions on this fact creating an inference cycle:
Oracle Business Rules uses working memory to contain facts (facts do not exist outside of working memory). A RuleSession contains the working memory. Each RuleSession includes one Rule stack. The RuleSession's ruleset stack contains the top of the stack, called the focus ruleset, and any non-focus rulesets that are also on the ruleset stack. The focus of the ruleset stack is the current top ruleset in the ruleset stack.
The Oracle Rules Engine sequentially selects a rule activation from all of the activations on the agenda, using the following ordering algorithm:
The Rete algorithm, invented by Charles Forgy in 1979 PhD thesis was based on the ‘fact’ that the facts in the rule engine's working memory change slowly over time through a series of inference cycles.
Facts about RETE algorithm -
The Non-Rete algorithm (NRE) is an alternative to the Rete algorithm that consumes less memory than the Rete algorithm. For business rules use cases it will result in improved performance. The core of NRE algorithm is a new rule condition evaluation approach. The majority of the rules engine is unmodified and shared across the Rete and NRE algorithms. The externally defined semantics of the existing Rete algorithm are preserved by the NRE algorithm.
Facts about NRE –
Following is a quick comparison of RETE vs No-RETE algorithms -
In OBR designer, NRE algorithm can be selected in the dictionary settings panel under preference tab. SOA and BPM applications will automatically handle the switch of algoritms. For JEE applications, the algorithm selection will need to be specified when the RuleSession or RuleSessionPool is created.
Oracle Business Rules uses working memory to contain facts. Facts do not exist outside of working memory. A RuleSession contains the Oracle Business Rules working memory.
Some bonus to the developers -
OPA is a rule engine designed to offer consistent and auditable advice across channels and business processes by capturing rules in natural language Microsoft Word and Excel documents and building interactive customer service experiences called interviews around those rules.
This blog goes into drills into OPA. Please follow below link to read more about OPA –
https://documentation.custhelp.com/euf/assets/devdocs/cloud19b/PolicyAutomation/en/Default.htm
Oracle Policy Automation provides complex eligibility and policy inferencing algorithm for forward chain inferencing. This is well suited for making decisions based on legislation modeled in natural language.
Difference between RETE and Linear Algorithm -
|
Linear |
RETE |
|
The linear inferencing algorithm maximizes the use of large, onboard processor memory caches by serializing the inferencing process.
|
RETE algorithm maintains a network of data flows with the aim of minimizing the discrete number of operations required for each inference. This, however, requires larger and more-complex data structures. |
|
The algorithm works by ordering rules so that they can be processed in a single left-to-right sweep for each forward inference cycle.
|
A rule engine essentially replicate the logical structure of the underlying rules for each inference session.
|
|
Only one sweep of the rules is required, regardless of how much data is changed between inference cycles.
|
Each individual change in data requires a “walk” of the network, because multiple changes in data cannot be handled at the same time. |
|
By minimizing the number of processor cache misses, this approach maximizes the efficiency of memory access to the rules. That is, rules are almost always accessed from the processor’s high-speed onboard memory. This is the most important feature of the algorithm, because nontrivial rule sets such as those typically found in legislation and policy will not fit within such caches.
|
Each walk of the network requires non sequential, mutable memory access. This results in substantially higher memory requirements and lower memory access locality, generating substantially more memory cache misses. As a result, it is less suitable to handling the complex logic expressed in legislation and organizational policy. |
|
By minimizing the number of processor cache misses, the linear inferencing algorithm maximizes the efficiency of memory access to the rules. That is, rules are almost always accessed from the processor’s high-speed onboard memory |
|
|
The sequential access of the rules also means more space-efficient data structures; such structures further increase the use of the onboard processor cache. Moreover, all rule access is read-only, which means the same cached copy can be shared across multiple inferencing sessions. |
|
Following are the advantages of linear inferencing over the Rete algorithm -
If you are reading part # 3, you are already convinced the need for a rule engine. So, welcome to part # 3.
Choosing rule engine is a case-by-case assessment. This section, we discuss about the qualifiers to choose Oracle Policy Automation (OPA) vs Oracle Business Rule (OBR). Following are the qualifiers to choose between OPA and OBR -


Refer following diagram for a quick glance to the qualifiers -

Today, compliance with complex regulations or intricate company policies is a substantial challenge for many organizations. Rule engine plays an important role in driving compliance with these rules.
No rule engine and the act of ‘masquerading rule engine’, surprises me the most as there must be a great reason why rules are termed as “business rules”. Hence, I recommend to avoid imperative model and custom rule engine as they are only masquerading rule engine. A rule engine should be for the business users, by the business users and of the business users.