Business rules Course materials may not be reproduced in whole or in part without the prior written permission of IBM. 4.0.3
Unit objectives After completing this unit, you should be able to: Describe the advantages to externalizing business rules as business rule services Explain how the SCA programming model supports the development of business rule services Define a business rule Explain rule sets, decision tables and rule groups Identify situations where it is appropriate to use a rule set or a decision table Describe rule templates
What is a business rule? A business rule is an If-Then business decision. If discount == 0.10, Then total = total (total * discount) The job of a business rule is to: Evaluate an input (if-then) Change a state Return some value
Business rules examples Rent-a-car corporate discounts Able to change discount amounts during peak dates and times Insurance agency Ability to invoke a process for an insurance claim that happened in the past when the claim rules were different Updating the Web site of a company Schedule specific dates that a Web site will update to the next development version without the knowledge of the end user
Motivation for using business rules in SOA Loose-coupling between business rules and service management functions. For example, ESB mediations are decoupled from business rule logic. They allow the specification of the business logic in a simple form, easily understood by business analysts. Logic is specified as either: A sequence of if-test-then-actions clauses. A simple decision tree. Rule changes can be made without the intervention of expensive IT personnel. Details of business rules change frequently. While the structure of the rules will be specified using the WebSphere Integration Developer tooling, elements can be added or customized using Web tools (coming up). Changes can also be made to business rules dynamically.
Support for business rules in WebSphere Process Server and WebSphere Integration Developer Service Components Business processes Human tasks Business state machines Business Rules Supporting Services Interface maps Selectors Business object maps Relationships Adapters Mediation Flows SOA Core SCA Business objects Common event infrastructure WebSphere Application Server ND (J2EE runtime)
Roles, rule templates and the Business Rules Manager Tools used Role tasks Business Analyst Role More business skills Business Rules Manager Web Tool Discusses desired changes with Developer and implements business rule changes. More aware of business and customer demand changes. More technical skills Developer Role WebSphere Integration Developer Codes editable business rules. These rules are associated with templates in WebSphere Integratin Developer. Implements what the architect has laid out. More aware of technical development and architecture.
SCA component: Business rule group business rules are invoked through the business rule group. Rules with a common focus are gathered in a business rule group. A business rule group is an SCA component. Rules within a business rule group are represented as rule sets or as decision tables. The business rule group provides the interface for rule sets and decision tables. Run-time clients of a business rule group include BPEL, JSPs, SCA components and the Business Rules Manager Web Tool.
Rule sets There are two kinds of rules: If-then rules that determine the action to execute according to a condition of the incoming message. Action rules that execute an action regardless of what an incoming message is. A rule set is a series of one or more If-Then condition and action statements that are processed sequentially. Evaluated from first listed to last. Able to choose any number of Action/If-Then conditions. An Action does not have an If-Then condition, it simply initializes or sets variables. An If-Then condition can decide on a variable change. A rule set is associated with a specific interface and operation of a business rule group. It evaluates multiple conditions and can fire multiple rules. Might be needed when a rule is found true and fired, then more processing needs to be done.
Decision table Decision table represents a multi-conditional, nested If-Then structure. The decision table represents a tree decision structure in tabular form. A set of If conditions with Then actions are defined at the intersection points of the table. Conditions are evaluated in a nested order (tree). Evaluates one condition or more, fires only one rule. The rule that is fired consists of one or more pre-defined actions. For example, an action could consist of setting an output parameter to a certain value. Most rules will fall under a decision tree. Most business rules are called to fire one rule. A decision table is associated with a specific interface and operation of a business rule group.
Decision table Mortgage request example This decision table returns an approximate mortgage loan amount to the client based on the type of property they are looking for: Size of the home in square feet. Location (city or suburbs). Type of property (apartment or house).
When to use decision tables or rule sets Use decision tables when you: Have a rule with multiple clauses or variables in the conditional statements Want to fire only one rule Use rule sets when you: Have rules with a few clauses or variables in the conditional statements Want to fire multiple rules
Assembling business rules The assembly editor is used to connect business rules to calling SCA components. A rule group is dragged and dropped onto the Assembly Editor and wired to existing components. Exports are used to connect business rule to another module.
Unit summary Having completed this unit, you should be able to: Describe the advantages to externalizing business rules as business rule services Explain how the SCA programming model supports the development of business rule services Define a business rule Explain rule sets, decision tables and rule groups Identify situations where it is appropriate to use a rule set or a decision table Describe rule templates