IT tutorials
 
Applications Server
 

BizTalk Server 2009 : Playing By The Rules? Use The Business Rule Engine - How Does the BRE Work?

6/10/2013 4:25:11 AM
- How To Install Windows Server 2012 On VirtualBox
- How To Bypass Torrent Connection Blocking By Your ISP
- How To Install Actual Facebook App On Kindle Fire

The main activities of the Business Rule Engine fall into one of two main user experience categories, the design-time experience and the runtime experience. At design time, business rule creators can use the business policy authoring tool, namely the Business Rule Composer in BizTalk, to create and update the business rules and policies. As mentioned previously, business rule authors use the Business Rule Composer to first create the vocabulary required to define the different business rules and then proceed to define their business rules grouped in the form of policies. The different artifacts created by the business rule creator are then compiled and persisted in the Business Rule Store. A service, the Rule Engine Update Service, periodically checks the Business Rule Store for changes to update the rule engine runtime.[] Applications and orchestrations calling the rule engine to execute policies use the interfaces exposed by the Business Rules Framework to do so. Figure 1 shows the separation between the two experiences and how the different components interact together to allow for the auto-update of business rules at runtime.

[] To configure how often the Rule Engine Update Service polls the Rule Store for changes to update the engine, define the registry value PollingInterval under the registry key HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\BusinessRules\3.0. The PollingInterval value defines the number of seconds that the Rule Engine Update Service waits between Rule Store polls for changes. The default value for this setting is 1 minute.

Figure 1. The interaction between the different Business Rules Framework components 


As we mentioned earlier, a highly efficient rule inference engine serves as the core compo-nent of the Business Rules Framework, and it provides the execution context for a policy. The rule engine is primarily composed of three main components:

  • An inference engine, also called the rule set executor, is responsible for the evaluation of rule conditions and action execution. The default rule set executor, implemented as part of the Business Rules Framework, is a "discrimination network-based forward-chaining inference engine designed to optimize in-memory operation". The inference engine uses forward chaining[] of rules and conditions to evaluate and action the rules in a rule set. Weighted priorities assigned to the different rules will affect the engine's processing and reorder the execution of their actions.

    [] Forward chaining, often called data driven, is one of the two main methods of reasoning when using inference rules in artificial intelligence. The other is backward chaining. 

  • A rule set translator takes as input a rule set definition—a RuleSet object—and "produces an executable representation of the rule set. The default in-memory translator creates a compiled discrimination network from the rule set definition"). A custom translator can be assigned to a particular policy version through the policy translator property. To assign a custom translator, the policy author needs to identify the .NET assembly containing the rule translator as well as the class implementing the IRuleSetTranslator interface in that assembly.

  • A rule set tracking interceptor receives output from the inference engine—rule set executor—and forwards it to the rule set tracking and monitoring tools that facilitate the tracking and debugging of business rules' execution.


The discrimination network-based forward-chaining logic of the inference engine consists of a three-stage algorithm for policy execution. The stages are as follows :


  1. Match. In the match stage, facts are matched against the predicates that use the fact type[] using the predicates defined in the rule conditions. To improve efficiency, pattern matching occurs over all the rules in the policy, and conditions that are shared across rules are matched only once. Partial condition matches may be stored in working memory to accelerate subsequent pattern-matching operations. The output of the pattern-matching phase consists of updates to the rule engine agenda. An agenda is completed when all facts that are simultaneously present in working memory are matched to all active policy rules. The agenda is used by the engine to queue rules and schedule them for execution.

    [] The fact type is an object reference maintained in the rule engine's working memory.

  2. Conflict resolution. In the conflict resolution stage, the rules that are candidates for execution are examined to determine the next set of rule actions to execute based on a predetermined resolution scheme. All candidate rules found during the matching stage are added to the rule engine's agenda. The default conflict resolution scheme is based on rule priorities within a policy. ... Therefore if multiple rules are triggered, the higher-priority actions are executed first.

  3. Action. In the action stage, the actions in the resolved rule are executed. Note that rule actions can assert new facts into the rule engine, which causes the engine to cycle again and start at the matching stage. This is also known as forward chaining. It is important to note that the algorithm never preempts the currently executing rule. All actions for the rule that is currently firing will be executed before the match phase is repeated. However, other rules on the agenda will not be fired before the match phase begins again. The match phase may cause those rules on the agenda to be removed from the agenda before they ever fire.

    An agenda exists per engine instance, and acts on a single policy only. A rule's actions are placed on the agenda and executed according to their priority, when facts are asserted and the rule's conditions are satisfied. A rule's actions are executed as a block and in order from top to bottom, before the execution of the actions of the next rule on the agenda.

A policy is defined with two rules. The rules and their facts are detailed in Tables 1 and 2, respectively.
Table 1. Rules Definition
Declarative RepresentationIF—THEN Representation Using Business Objects
Rule 1: Evaluate Income 
An applicant's credit rating should be ob-tained only if the applicant's income-to-loan ratio is less than 0.2.IF Application.Income / Property.Price < 0.2 THEN Assert new CreditRating(Application)
Rule 2: Evaluate Credit Rating 
An applicant should be approved only if the applicant's credit rating is more than 725.IF Application.SSN = CreditRating.SSN AND CreditRating.Value > 725 THEN SendApprovalLetter(Application)

Table 2. Facts Definition
FactField
Application: An XML document representing a home loan applicationIncome = $65,000 SSN = XXX-XX-XXXX
Property: An XML document representing the property being purchasedPrice = $225,000
CreditRating: An XML document containing the loan applicant's credit ratingValue = 0 – 800 SSN = XXX-XX-XXXX

Initially, the rule engine working memory and agenda are empty. After the application asserts the Application and Property facts with the values detailed in Table 8-2 to the rule engine, the engine's working memory and agenda are updated, as shown in Table 3. Rule 1 is added to the agenda because its condition (Application.Income / Property.Price < 0.2) evaluated to true during the match phase. There is no CreditRating fact in working memory, so the condition for Rule 2 was not evaluated.

Table 3. Engine's Working Memory and Agenda Before Execution
Working MemoryAgenda
ApplicationRule 1
PropertyAssert new CreditRating(Application)

Because the only rule in the agenda is Rule 1, the rule is executed and then disappears from the agenda. The single action defined for Rule 1 results in a new fact (CreditRating document for the applicant) being added to working memory. After the execution of Rule 1 completes, control returns to the match phase. Because the only new object to match is the CreditRating fact, the results of the match phase are as shown in Table 4.

Table 4. Engine's Working Memory and Agenda After the Execution of Rule 1
Working MemoryAgenda
ApplicationRule 2
PropertySendApprovalLetter(Application)
CreditRating 

At this point Rule 2 is executed, resulting in the invocation of a function that sends an approval letter to the applicant. After Rule 2 has completed, execution of the forward-chaining algorithm returns to the match phase. Because there are no longer new facts to match and the agenda is empty, forward chaining terminates, and policy execution is complete .

 
Others
 
- BizTalk Server 2009 : Playing By The Rules? Use The Business Rule Engine - The Business Rule Composer
- Monitoring Microsoft Lync Server 2010 : Securing OpsMgr
- Monitoring Microsoft Lync Server 2010 : OpsMgr Component Requirements, Advanced OpsMgr Concepts
- Migrating to Configuration Manager 2007 : Conducting an In-place Upgrade (part 6) - Upgrading SMS 2003 Clients
- Migrating to Configuration Manager 2007 : Conducting an In-place Upgrade (part 5) - Upgrading Secondary Sites
- Migrating to Configuration Manager 2007 : Conducting an In-place Upgrade (part 4) - Upgrading a Primary Site
- Migrating to Configuration Manager 2007 : Conducting an In-place Upgrade (part 3) - Database Upgrade Tips and Tricks
- Migrating to Configuration Manager 2007 : Conducting an In-place Upgrade (part 2) - Upgrading SQL Server
- Migrating to Configuration Manager 2007 : Conducting an In-place Upgrade (part 1) - Running the Prerequisite Checker
- Improving Dynamics GP with Hacks : Reducing licensing needs by preventing Multiple Company Logins
 
 
Top 10
 
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Finding containers and lists in Visio (part 2) - Wireframes,Legends
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Finding containers and lists in Visio (part 1) - Swimlanes
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Formatting and sizing lists
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Adding shapes to lists
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Sizing containers
- Microsoft Access 2010 : Control Properties and Why to Use Them (part 3) - The Other Properties of a Control
- Microsoft Access 2010 : Control Properties and Why to Use Them (part 2) - The Data Properties of a Control
- Microsoft Access 2010 : Control Properties and Why to Use Them (part 1) - The Format Properties of a Control
- Microsoft Access 2010 : Form Properties and Why Should You Use Them - Working with the Properties Window
- Microsoft Visio 2013 : Using the Organization Chart Wizard with new data
programming4us programming4us
 
Popular tags
 
Video Tutorail Microsoft Access Microsoft Excel Microsoft OneNote Microsoft PowerPoint Microsoft Project Microsoft Visio Microsoft Word Active Directory Biztalk Exchange Server Microsoft LynC Server Microsoft Dynamic Sharepoint Sql Server Windows Server 2008 Windows Server 2012 Windows 7 Windows 8 Adobe Indesign Adobe Flash Professional Dreamweaver Adobe Illustrator Adobe After Effects Adobe Photoshop Adobe Fireworks Adobe Flash Catalyst Corel Painter X CorelDRAW X5 CorelDraw 10 QuarkXPress 8 windows Phone 7 windows Phone 8 BlackBerry Android Ipad Iphone iOS