170 likes | 344 Views
Exposing the Business Rules Service. Auckland Connected Systems User Group November 19th 2009. Jeffrey Chilberto BizTalk Consultant http://bloggingabout.net/blogs/chilberto. Business Rules Engine. The Business Rules Framework is a Microsoft .NET-compliant class library.
E N D
Exposing the Business Rules Service Auckland Connected Systems User Group November 19th 2009 Jeffrey Chilberto BizTalk Consultant http://bloggingabout.net/blogs/chilberto
Business Rules Engine The Business Rules Framework is a Microsoft .NET-compliant class library. It provides an efficient inference engine that can link highly readable, declarative, semantically rich rules to any business objects (.NET components), XML documents, or database tables. Application developers can build business rules by constructing rules from small building blocks of business logic (small rule sets) that operate on information (facts) contained in .NET objects, database tables, and XML documents. Reference: http://msdn.microsoft.com/en-us/library/aa561216(BTS.10).aspx Business Rules Service
Jeff’s Definition The Business Rules Engine is a .Net framework designed to inject functionality at runtime. Solution Process Host Application Business Rules Engine Facts • The BRE is comprised of a utilities to create and manage Rules, • Business Rules Composer • BizTalk Management Console • a repository for storing Rules, • Rule Store • Policy Update Service • and a mechanism for executing rules • BizTalk Call Rules Shape from within an Orchestration • Microsoft.RuleEngine Library Business Rules Service
Why BRE? Separation of business logic from application allowing for more opportunities to leverage the logic elsewhere Can lead to lower maintenance costs Can lead to greater understanding of the business requirements When to use BRE? Application involves significant decision making Rules change frequently Application is relatively stable Business Rules Service
Facts • .Net objects (methods, properties and fields) • XML documents (elements, attributes) • Database rowsets Facts can be short term • A short-term fact is specific to a single execution cycle of the rule engine. and long term facts • A long-term fact is loaded into the working memory of the rule engine for use over an arbitrary number of execution cycles. Business Rules Service
Policies A policy is a versioned logical grouping of rules. Rules A rule consists of a condition and actions. The condition is evaluated, and if it evaluates to true, the rule engine initiates one or more actions. Business Rules Service
Vocabulary A collection of values, references to .Net class members, xpath statements and database objects used to make the creation of Rules simpler and more intuitive. Business Rules Service
ACSUG Order Management System An order: Business Rules Service
Vocabulary Examples Constant Value Set of Values Business Rules Service
Vocabulary Examples XPath Get XPath Set Business Rules Service
Vocabulary Examples The XPath Selector is used to define and select a 'fact‘ while the XPath field determines what aspect of the fact is to be selected. Business Rules Service
Rules Examples Promotion based on product id • multiple facts can be asserted • Forward Chaining • Priority Business Rules Service
Calling From Orchestration Business Rules Service
Common Orchestration Scenarios • Manipulation of business objects • Configuration storage • Default values • Routing • Document Validation http://seroter.wordpress.com/2009/11/11/validating-incoming-data-using-the-biztalk-business-rules-engine/ Business Rules Service
WCF Service Loosely tied service with contract definitions • Facts are sent in and returned as un-typed objects • ServiceKnownTypeAttribute is used for serialization of messages and contract metadata without requiring a service rebuild Business Rules Service
WCF Service Reference to Microsoft.RuleEngine library Policy policy = new Policy(“ACSUG.ApplyPromotion”); policy.Execute(facts.ToArray(), interceptor); IRuleSetTrackingInterceptor can be used to track activity of BRE Business Rules Service
References MSDN Documentation http://msdn.microsoft.com/en-us/library/aa561216(BTS.10).aspx BizTalk Hotrod – Exposing Business Rules Engine as a WCF Service (Issue 4) http://biztalkhotrod.com/Issues.aspx Configuration http://www.biztalkgurus.com/newsletter/TheBizTalker-Volume-07.html Static Methods Feature http://blogs.msdn.com/richardbpi/archive/2005/11/14/492489.aspx Lengthy walk-through http://msdn.microsoft.com/en-us/library/ms942178(BTS.10).aspx Business Rules Service