United States   Change   |   All Microsoft Sites

Home

The Business Rules Framework

BizTalk Server 2009 includes the Business Rules Framework as a stand-alone .NET-compliant class library that includes a number of modules, support components, and tools. The primary modules include the Business Rule Composer for constructing policies, the Rule Engine Deployment Wizard for deploying policies created in the Business Rule Composer, and the Run-Time Business Rule Engine that executes policies on behalf of a host application.

You can integrate business rules into your orchestrations to support a variety of scenarios:

  • Use rules instead of coding and recoding constantly changing business policies and logic within your complex business processes. Incorporate a call and allow information workers to update business rules.

  • Use rules to evaluate business logic and to determine when a business process requires a variable delay. For example, you might set up a loop to check on the status of an item to determine whether the item is in stock. After initially checking the stock of an item that is not available, the rule delay would be one minute. The next time, the rule would wait five minutes before executing; the time after that, the rule would wait 30 minutes before executing; and so on.

  • Use rules to determine the execution path for a business process, basing the determination on the results of the rule execution. For example, if a customer does not exist for a particular purchase order, you could route the document to another business process to add the customer to the database before continuing to process the purchase order.

The BizTalk Orchestration Engine, in contrast, coordinates and schedules message processing and performs complex logic on the message as it is passed through a defined workflow.

The Business Rule Composer

The Business Rule Composer enables you to create rules by adding predicates and facts and defining actions. You can add facts and actions by dragging them to the Business Rule Composer design surface. The actions update the nodes in the specified document. You can also add AND, OR, and NOT operators to conditions to create complex comparisons.

The Business Rule Composer helps you create, test, publish, and deploy multiple versions of business rule policies and vocabularies to make the management of these artifacts easier. The Business Rule Composer can be used by developers, administrators, and information workers to develop and apply rules and policies.

Role

Description

Developers

  • Create vocabularies to make it easier for information workers to edit and understand business rule policies.

  • Create the initial business rule policies.

  • Bind business logic to data. Developers create the orchestrations from which the business rules are called and define the action to be taken when a decision is returned to the orchestration. As long as the decision path within the orchestration does not change, you do not need to redeploy the orchestration.

Administrators

  • Secure business rule policies. By default, when a new policy or vocabulary is created in the rule store, only the user who created it and the BRE administrator have both read/execute and modify/delete access. The BRE administrator can configure which users have the access level, or rights, to perform different operations.

  • Deploy business rule policies from one physical environment to another. This can be accomplished by using the Rule Engine Deployment Wizard. Administrators can also export and import rules by using the MSI process.

Information Workers

  • Manage business policies in real time.

The Business Rule Vocabularies

Business rule vocabularies are user-defined names for the facts that you use in rule conditions and actions. Vocabulary definitions make rules easier to read, understand, and share among various workers within a particular business domain. For example, the source location for a particular fact is a specific field in one record in a single database and is represented as an SQL query. Instead of using the SQL query in the rule, you can use a vocabulary definition to assign a meaningful name with the query for the benefit of all the relevant parties in the development and deployment process for the rule.

Consider the following example of a business rule:

If the Shopping Cart contains more than $1,000 worth of items, give the customer a 10% discount.

This rule is easy to understand. It is a Boolean comparison (greater than) between two variables, the shopping cart and a value of 1,000. The action to be performed is to apply a 10 percent discount to the total order. In computer terms, this rule will look like this:

If Company.Namespace.ShoppingCart.PurchaseAmount > Qualifying Amount as System.Decimal

Then

Company.Namespace.Customer.DiscountedAmount = Company.Namespace.ShoppingCart .PurchaseAmount * .1

To provide a more user-friendly alias, you can create a business rule vocabulary to abstract difficult concepts by defining an alias to the schema nodes, database fields, and .NET classes. Vocabularies make the creation and maintenance of these rules much easier. Correctly defined vocabularies can empower information workers in maintaining policies.

The Business Rule Composer contains two built-in vocabularies, Predicates and Functions, which are used in the creation of all rules. You can extend these vocabularies if required. For example, the phrase “If the Shopping Cart contains more than $ 1,000 worth of items” is actually a greater than comparison (Shopping Cart > 1,000). You can define an additional vocabulary term to clarify the meaning of the relationship represented by the built-in Greater Than function.

Business Rule Policy

A business rule policy is a logical collection of business rules. Each rule is a conditional comparison of facts. If the comparison evaluates to True, the actions defined in the rule are executed. Business rules are versioned together as part of a business policy. Therefore, if a rule changes, you simply need to create a new version of the policy, test it, and deploy it. You do not need to recompile or modify orchestrations or other business processes that use that specific business policy.

Business rule definition in the BizTalk Business Rule Composer

Figure 1. Business rule definition in the BizTalk Business Rule Composer

When called from an orchestration, the BRE always executes the latest version of a policy. Changes made to a business rule policy are immediate. The next time the policy is called from an orchestration, the latest version number of the policy that is in a deployed state is used. When you call a policy programmatically, you need to specify the policy version.

Publishing the policy to the rule store makes it available to the BRE. By default, the BRE uses a Microsoft SQL Server database as the rule store; however, you can also export rules to an XML-based rule store as well. Once a policy is published, it is immutable and you can change it only by creating a new version.

Note: Although policies are typically used in conjunction with BizTalk orchestrations, you can also call them from any .NET assembly by using the supplied APIs.

A business analyst or information worker might explain the logic of the rule in Figure 1 by saying: If the applicant's total monthly income is greater than the loan amount and he has either had the same job for at least six months, or lived in the same location for at least six months, then the loan should be approved.

It's important to notice that this rule alone does not contain all the logic used for loan evaluation. There may be other conditions for approving a loan, and there will be many different conditions for denying the loan as well. This rule is designed to be evaluated as part of a policy that contains other rules.

The Rule Engine Deployment Wizard

The Rule Engine Deployment Wizard provides an easy and efficient way to:

  • Export a version of a policy or vocabulary from an SQL rule store to an XML file store.

  • Import a version of a policy or vocabulary from an XML file store to an SQL rule store.

  • Deploy a version of a policy to make it available to the update service and the rule engine runtime. The wizard deploys a policy by marking it as “deployed” in the database.

  • Undeploy a version of a policy from a production SQL rule store to make the policy unavailable for use by a rule-based application.

For more information on BizTalk Business Rule Framework Integration please refer to the BizTalk Interactive Capabilities Reader or the BizTalk Product Documentation on MSDN.

Try BizTalk Server 2009

Get the 120 day trial