390 likes | 565 Views
Welcome to the Twin Cities BizTalk User Group. July 2006. Implementing a BizTalk Rule Engine Solution. Tips, Tricks & Best Practices. Balaji Thiagarajan ITRGroup, Inc www.itrgroupinc.com. This event is sponsored by ITR Group, Inc. Introduce you to the group. About me.
E N D
Implementing a BizTalk Rule Engine Solution. Tips, Tricks & Best Practices Balaji Thiagarajan ITRGroup, Inc www.itrgroupinc.com
About me • Working on BizTalk since the BizTalk 2000 days • MCP in BizTalk since August 2002 • Worked for Microsoft Consulting Services, India. • Currently working as a BizTalk Consultant for ITRGroup, Inc.
Agenda • Overview of BizTalk Rules Engine(BRE) • Features • Building Rules • Architecture • Rules & Orchestration • Q & A
BRE Overview What are Rules? • Rules are • Declarative statements for capturing changing business policies • Represented as: IF <Condition(s)> THEN <Action(s)> • Logically grouped into policies • Rules allow users to • Define & own business policies without coding • Change business policies in real time without rebuilding/redeploying applications
BRE Overview BizTalk Rules in a Nutshell • Lightweight .Net engine • Host-agnostic for in-process scenarios • Integrated with BizTalk Server • Powerful Framework & Tools • Supports Developers, IT Admin and IW • Complete API for design & execution • Rich Modeling Capabilities • Data Sources: .Net Objects, XML, DB • Logical expressions • Enterprise-Ready • Security, Performance, Versioning
BRE Overview Rules Tools - Development • Business Rule Composer • Bind Vocabularies • Build & test policies • Deploy Policies • Visual Studio.NET • OD – Integrate policies & processes • Build supporting code • Fact Retrievers – long term facts • Custom operations
BRE Overview Rules Tools – Admin/Management • Rule Engine Deployment Wizard • Deploy policies • Export/Import policies & vocabularies • HAT • Tracking configuration • Policy execution monitoring
Demo #1 Automated Loan Processing
Agenda • Overview of BizTalk Rules Engine(BRE) • Features • Building Rules • Architecture • Rules & Orchestration • Q & A
Features Design Time • Rich built-in library that includes: • Temporal, relational predicates • Support for ranges and regular expressions • Arithmetic operations • Engine execution control functions • Support for complex logical expressions(AND / OR / NOT) • User-defined predicates/functions/actions • Policy testing
Features Run Time • Application integration via Policy object • Support for long-term (semi-static) & short-term (dynamic) facts • Performance optimizations • Forward Chaining Inference Mechanism • Finds all true statements given knowledge base and a new set of facts • Execution tracking
Agenda • Overview of BizTalk Rules Engine(BRE) • Features • Building Rules • Architecture • Rules & Orchestration • Q & A
Building Rules .Net Objects • Drag and drop public members • Actions • Predicates • Arguments • Assert .Net Instances IF MyClass.A = 5 THEN MyClass.B() MyClass Engine Assert
Building Rules Data Connection • Perform dynamic queries on a DB DataConnection(“DataSetName”,”TableName”, SqlConnection,SqlTransaction)
Building Rules Data Connection - Retrieve IF Table.CustType = “Residential” AND Table.Balance > 1000 THEN …. SELECT * FROM Table WHERE CustType = “Residential” and Balance > 1000 TDR Engine TDR
Building Rules Data Connection - Update IF Table.CustType = “Residential” AND Table.Balance > 1000 THEN Table.Status = “Over Limit” SELECT * FROM Table WHERE CustType = “Residential” and Balance > 1000 Modify Call DC.Update() and commit the SQL Transaction TDR Engine TDR Modify
Building Rules TypedDataTable • Wrapper class on ADO.NET DataTable • Rules built against DB tables, using “Database binding type” field • Asserts individual TypedDataRows Note: If you assert a DataTable – without the TypedDataTable wrapper – it is treated as a standard .NET object
Demo #2 Automated Loan Processing with DB
Building Rules TypedXmlDocument
Building Rules TypedXmlDocument
Building Rules TypedXmlDocument IF orderline.quantity > 5 THEN orderline.discount = 10
Building Rules TypedXmlDocument • Objects are created based on XPath selectors; Xpath Field represents object “property” • Other points • Adding nodes • XPath editing
Policy Rule 1 If A.amount > $0 Then B.total + A.amount Rule 2 If B.total > $50 & < $100 Then B.discount = 10% Rule 3 If B.total >= $100 Then B.discount = 15% A.Amount = $25 B.Total = $80 Rule Engine Agenda B.Total = B.total + A.amount B.Discount = 10% Building RulesForward Chaining
Policy Rule 1 If A.amount > $0 Then B.total + A.amount Rule 2 If B.total > $50 & < $100 Then B.discount = 10% Rule 3 If B.total >= $100 Then B.discount = 15% A.Amount = $25 B.Total = $80 $105 Rule Engine Agenda B.Total = B.total + A.amount B.Discount = 10% B.Discount = 15% B.Discount = 15% Building RulesForward Chaining
Building Rules Engine Control Functions • Assert • Add facts to working memory • Retracts • Remove facts from working memory • RetractByType • Remove all instances of the specified type • Update • Instruct engine to reevaluate relevant facts/conditions
Building Rules Engine Control Functions • CreateObject • Exposed as constructors in Composer • Halt • Stop engine processing • Clear • Clear facts from memory • Clear actions from agenda • Executor • Handle to the rule engine instance
Agenda • Overview of BizTalk Rules Engine(BRE) • Features • Building Rules • Architecture • Rules & Orchestration • Q & A
Architecture Schematic
Architecture Policy Instantiation – Get RE Instance
Architecture Policy Instantiation – Execute Engine
Architecture Policy Instantiation – Get RE Instance
Demo #3 Policy Testing
Agenda • Overview of BizTalk Rules Engine(BRE) • Features • Building Rules • Architecture • Rules & Orchestration • Q & A
Rules and Orchestration Patterns Illustrated
Rules and Orchestration Patterns Illustrated