BRBeans run-time behavior

Business Rule Beans (BRBeans) run-time behavior can best be described by giving a simple example of a trigger point selecting, executing, and then responding to the results of a business rule.

The first step in triggering a rule is for the trigger point framework to perform a query on the rule server to determine which rules to trigger. The main item used for the query is the fully qualified rule name. Other items used in the query include the start and end date, whether this is a classifier, the classification of the rule, and whether the rule is marked "ready". This query returns zero or more rules. If there is at least one rule, the trigger point assembles the data that is sent as parameters to each rule. The trigger point then loops through the list of rules invoking the fire() method on each and passing the parameters. The results are combined depending on the combining strategy used.

When the trigger point framework invokes fire on a rule, it instantiates the RuleImplementor and uses it to do the actual work (to execute the rule algorithm or test). Once it has arrived at a result, the RuleImplementor returns that result. For constraint rules (ones that arrive at a boolean true or false answer) the returned value is, by convention, a ConstraintReturn. A ConstraintReturn is a data structure that indicates whether the constraint was satisfied. If not, the ConstraintReturn indicates what went wrong. For derivation rules (ones that calculate a single, generally non-boolean value), the return value can be any type. In the simplest case, the return value from each RuleImplementor is returned back to the trigger point where it is analyzed to determine what action to take.

The following is an overview of what happens when the maxTruckDriverHours rule is triggered:

A rule exists named maxTruckDriverHours. The purpose of this rule is to check that the number of hours entered by a user for a particular truck driver does not exceed the maximum allowed value. This rule contains an initialization parameter list consisting of a single value of 8. This rule is bound to a RuleImplementor class called MaxRuleImpl. MaxRuleImpl tests the parameter it is passed against the initialization list value and returns a ConstraintReturn. The ConstraintReturn is set to true if the passed parameter is less than or equal to the initialization value. Otherwise, a ConstraintReturn is set to false and some information is added that describes which values were compared and why the test failed.

When this rule is triggered, the following details the trigger point process:

  1. During the execution of the application, the application reaches a point where it needs to verify that the number of truck driver hours that was entered is valid. The application code invokes a simple trigger point passing the name of the rule to be triggered and a parameter list containing the entered hours for the driver.
  2. The trigger point framework performs a query on the rule server to find the rule with the specified name. It receives back a sequence of rule objects. In this case, this sequence contains one rule, maxTruckDriverHours.
  3. The framework determines whether this rule is to be triggered on a local or remote machine. If local, the framework gets a local copy of the rule object and calls the fire method on the copy. If remote, the framework calls the fire method on the enterprise bean reference. The parameter list containing the weight is passed to the fire method.
  4. The maxTruckDriverHours rule (either the copy or the enterprise bean itself) creates an instance of the rule implementor class, maxRuleImpl, if it does not already have one. When a new rule implementor instance is created, the rule calls its init method passing any initialization parameters defined for the rule. In this case, the initialization parameter list contains the single value 8. If the rule already has a rule implementor instance, it uses that one and does not call the init method.
  5. The maxTruckDriverHours rule calls the fire method on the rule implementor instance. The firing parameters passed to the trigger point are passed to the rule implementor and are possibly modified by any firing parameters defined in the rule itself. In this case, the firing parameters are passed directly from the trigger point.
  6. The maxRuleImpl returns a ConstraintReturn object to the rule that indicates the result of its comparison. This ConstraintReturn is returned to the trigger point framework and ultimately to the application.
  7. The application checks the value in the ConstraintReturn and takes the appropriate action.


Related concepts
Overview of Business Rule Beans



Searchable topic ID:   cbrb_rtbhv
Last updated: Jun 21, 2007 8:07:48 PM CDT    WebSphere Business Integration Server Foundation, Version 5.0.2
http://publib.boulder.ibm.com/infocenter/wasinfo/index.jsp?topic=/com.ibm.wasee.doc/info/ee/brb/concepts/cbrb_rtbhv.html

Library | Support | Terms of Use | Feedback