370 likes | 499 Views
Rules Processing and BPM An Architectural Perspective. Charles Young Principal Consultant. Agenda. Rule processing What are rules, what do they do and how do you use them in business processes? Why use rule engines? The architectural drivers Rule patterns and practices
E N D
Rules Processingand BPMAn Architectural Perspective Charles Young Principal Consultant
Agenda • Rule processing • What are rules, what do they do and how do you use them in business processes? • Why use rule engines? The architectural drivers • Rule patterns and practices • Rules-driven process governance • Common inter- and intra-process rule patterns • Rules at the edge • Event-driven scenarios • Interaction with the physical world • What about the user interface?
What are Rules? • “A law or regulation that governs behaviour, actions, or operations.”AMS Glossary • “A clause that defines the relationship or relationships between facts.”PC AI Glossary • “A data-driven programming construct…consisting of a condition and action. A rule’s action is executed (‘fired’) when its condition is satisfied by objects in memory. Sometimes called a ‘production’ or ‘production rule’.” AT&T R++ User Manual
What Rules Do • Define scope and meaning of terms • Define structure of systems and organisations • Constrain actions and bind activities • Derive information and knowledge from data • Rules are everywhere! • Intrinsic to any organisation or process • Intrinsic to any software system or service
Rule Categories • RuleML categories • Integrity constraints • Assertions, SQL foreign key (RI) constraints, etc. • Derivation rules • Static • Condition Conclusion • Reaction rules • Temporal • On event, if condition then action • SQL triggers, event handlers, Subscription-based routing • Production rules • If condition then action • Widely supported in rules engines • Transformation rules • If condition then transform A into B • Deontic rules (future support) • Rights, obligations and empowerments
Implementing Rules • No single approach • Rules are everywhere! • Custom code • Message routing and subscription • Workflows and processes • Database systems • Rules engines • XSLT • etc.
Rules Engines • Executable rules • Rule sets • Policies: govern decision making and interaction • Production rules • Map to other rule categories • Sequential engines • Less expressive, powerful and scalable • Procedural: familiar, easier to debug • Excellent for simple decision logic • Microsoft: WF rules • Set-based pattern matching engines • Production systems • More expressive, powerful and scalable (esp. large rule sets) • Good support for highly combinatorial matching • Declarative: unfamiliar, harder to debug • Inferencing and reasoning • Microsoft: MS BRE
IF State == POReceived THEN PO=GetPurchaseOrder() State == ValidatingCustomer IF AND State == ValidatingCustomer IsApprovedCustomer(PO.CustomerID) NOT OR AccountSuspended(PO.CustomerID) OutstandingArrears(PO.CustomerID, 8000) THEN PO.Accepted = true State = ProcessingPO IF AND State == ProcessingPO PO.Accepted == true PO.Total >= 100000 THEN SendApprovalRequest(PO.RefId) State = ApprovingPO IF AND State == ProcessingPO OR PO.Accepted == false PO.Total < 100000 THEN State = CompletingPOProc IF AND State == ApprovingPO AP.Approved== true THEN State = CompletingPOProc IF AND State == ApprovingPO AP.Approved== false THEN PO.Accepted = false State = CompletingPOProc IF AND State == CompletingPOProc PO.Accepted == true THEN EnterPODetails(PO) State = POProcCompleted IF AND State == CompletingPOProc PO.Accepted == false THEN SendDeclineEmail(PO) State = POProcCompleted
Why use Rules Engines? • Better separation of concerns • Separate process definition from governance • Improved traceability • Align process logic to business goals • Validate completeness and correctness • Externalisation of rules • Direct definition and maintenance by business users • Orthogonal versioning of rules and processes • Inferencing • Sophisticated and efficient framework for reasoning over facts
MS Business Rules Framework Application, Orchestration, etc. “Short Term” Facts Assert Facts, Execute Rules Policy Tester Rule Policy Objects (executable rule sets) Assert Facts, Execute Rules Get Rule Set Get Facts Rule Engine Object Tracking Interceptor Rule Set Translator Rule Set Update Service Fact Retriever (Fact Remover) Executor Pub/Sub Adapter Specified In Rule Set Cache Pub/Sub Agent Get Rule Set Fact Creator Rule Store Object Event Service Pub/Sub Service Policy Composer Rule Language Converter “Long Term” Facts Rule Sets & Vocabularies Fact Stores Application Data Deployment Tool Rule Set Deployment Driver Versioning
Mapping Business Rules to Executable Rules • Business rules • Business abstractions • Not driven by technology • Highly declarative • No run-time context • Map at two levels • Business rule Executable rule • Business rule Policy (rule-sets) • Policy ‘chaining’
Process Definition • A process may… • Decompose to several sub-processes • Multiple orchestrations or workflows • Include both automated and manual processing • Span multiple platforms and services • Enterprise BPM servers (e.g. BizTalk Server) • Human Workflow tools • Web services and browser / desktop applications • Line of Business and back office applications • Cross multiple organisational boundaries
Process Governance • Governance involves… • Enforcing organisational policies within processes • Managing the alignment of processes to corporate requirements and strategies • Ensuring traceability, accountability and openness within processes • Ensuring optimal reuse of services across process and organisational boundaries • Policy-driven • Externalised • Managed
Intra-Process Rule Patterns • Used within a single executable process • e.g. within a single orchestration • Basic rule-based patterns for BPM • Rule-based derivations • Rule-based assertions • Rule-driven process flow
Rule-Based Derivations • Intent • Derive and infer new facts from existing facts • Applicability • Data and message generation • Data and message transformation • Uses • Decision support • Rating • Analysis • Prediction • Scheduling and process optimisation
Rule-Based Assertions • Intent • Enforce validity and integrity constraints within a process • Applicability • Data and message validation • Uses • Validation • Policy enforcement • Enforcement of obligations and permissions (deontic rules) • Alerting and notification
Rule-Driven Process Flow • Intent • Control sequence of state transitions and process activities • Applicability • Process decision points • Conditional process logic • Processes with branches and loops • Uses • Policy-driven processes • Process automation • Human interactions and workflow
Intra-Process Patterns: Relationships Rules Engine Estimate anticipated profit margin for new product based on monthly sales of similar products, market conditions, etc. Rule-Based Derivations Rules Engine Rule-Based Assertions Estimated profit margin for new product is > 10% Orchestration If estimated profit margin is not > 10%, notify product manager Rule-Driven Process Flow
An Intra-Process Anti-Pattern • Flow-based derivation • Controlling cyclic derivation logic through process flow • Using process flow inappropriately to implement activity logic • Symptoms • Excessively nested loop structures • Iterating data collections • Constructing new data collections • ‘Meta-loops’ to repeat work when date collections change • (Forward chaining) • Consequences • Inefficient, resource-intensive code • Hard to verify, stabilise and maintain • Resolution • Replace with set-based pattern matching approach using a Rules Engine • Use declarative rules rather than complex procedural code
Inter-Process Rule Patterns • Used across multiple executable process definitions • e.g. within across multiple orchestrations • Advanced rule-driven patterns for BPM • Rule-driven process routing • Policy-driven process versioning • Policy-driven process composition
Rule-Driven Process Routing • Intent • Implement dynamic patterns of process invocation • Applicability • Message exchange between different processes • Uses • Subscription-based routing • Dynamic policy-driven routing • Foundational for advanced patterns • Fine-grained orthogonal versioning of individual processes • Dynamic composition of discrete processes and services
Example: BizTalk Server Enhanced Subscription Orchestration A Set context properties and promote using correlation set Context Port Message Message Box Rules Engine Message Agent Orchestration B Policy Port Event-Condition-Action Dynamic Routing Subscription Rules Filter Subscribe on promoted message properties
Policy-Driven Process Versioning • Intent • Fine-grained versioning control of individual processes • Applicability • Discrete sub processes that can be re-used across multiple business processes • Processes that must constantly adapt to rapidly changing business environments • Uses • Anywhere there is a need to regularly re-deploy versioned processes with maximum agility and minimum impact
Policy-Driven Process Composition • Intent • Dynamic composition of discrete services and processes • Applicability • Discrete sub processes that can be re-used across multiple business processes • Processes that must constantly adapt to rapidly changing business environments • Uses • Anywhere there is a need to regularly change the composition of overall processes with maximum agility and minimum impact
Rules in Edge Processing • Edge processes • Contextualised • Customer / service-focused • ‘Real world’ interactions • Event-driven • Non-deterministic • Transformational • Map between events / interactions and managed process definitions • Filtering and cleansing
Rules in the Presentation Tier • “The system architecture … is the user agent”Fred Brooks - The Mythical Man-Month • Rule-driven interfaces • Validation and derivation • Composition and navigation • Analysis, inference and prediction • Guidance and learning • Shared rule-base with central processes
Call to Action • Investigate rule technologies • Many vendors, many approaches • Built-in vs. external tool sets • Distinguish between process definition and process governance • Apply rule patterns and practices to process design • Assess, measure and improve!