Chapter 9 Working With Rules and Functions : Understanding Rules and Rule Functions

Understanding Rules and Rule Functions
This section introduces some main points to understand about rules and rule functions. Also see Understanding and Working With Functions for details on the many functions you can use in rules and rule functions.
Effect of Cache Only Cache Mode  If you are using the Cache Only cache mode (advanced cache option) for one or more entities, you must consider how to handle the cache-only entities when you write rules and preprocessor rule functions. See Explicitly Loading Objects into Working Memory, With the Cache Only Mode.
Rules
A rule includes a declaration of entity types, and (optionally) one or more separate conditions, which evaluate to true or false, and an action, which is eligible to execute only when all conditions evaluate to true.
Within the Actions panel, semicolons separate statements; one statement can span multiple lines; one line can include multiple statements. Statements in a rule action might execute tasks, create an instance, modify property values in an instance, create and send a simple event, and so on.
Rule Priority
BusinessEvents rules are declarative rather than procedural: there is no inherent order for processing. However, a priority property allows you to specify which rules should execute first.
TIBCO recommends that you use priorities prudently; that is, unless there is reason to use a priority setting, let the rule engine determine the sequence of execution. This lessens the complexity of the rule maintenance task, and takes advantage of the power of the rule engine.
See Understanding Conflict Resolution and Run to Completion Cycles.
Rule Sets
A rule set is a container for rules. All rules exist within a rule set. Grouping rules into rule sets enables you to deploy a selection of rule sets in a BAR (BusinessEvents archive). Your project design determines which rules to put in each rule set and which rule sets to deploy using different agents.
Rule Functions
A rule function is a function you write in the BusinessEvents rule language for use in a project. To create a rule function, you use a RuleFunction resource. All rule functions created for a project are available project-wide and are not contained in a rule set.
Rule functions can take arguments and can return a value. The return type can be set to void, indicating that the rule function does not return anything.
You can use rule functions in the same way as the standard (provided) functions, custom functions, and ontology functions (which are created automatically from the entity types). You can use rule functions in rule conditions and rule actions.
You can assign rule functions to be used as event preprocessors (see Working With Event Preprocessors), and as startup and shutdown actions (see Working With Startup and Shutdown Rule Functions).
Virtual Rule Functions and Decision Manager
Virtual rule functions are created in the TIBCO Designer project using RuleFunction resources. A virtual rule function has arguments but no body or return type, and the Is Virtual checkbox on the Configuration tab is checked.
The implementations for virtual rule functions are provided in the Decision Manager business user interface. Business users select a virtual rule function. they drag and drop entities from a project explorer to form rows in a decision table. Each row forms a simple rule, for example, Condition: age less than 18; Action: refuse credit.
Implementations of the virtual rule functions are known as decision table classes. Because these classes originate in the Decision Manager application, they are also known as external classes, from the point of view of the BusinessEvents nodes.
The classes are placed in one or more known locations and are loaded at system startup, or using JMX while the system is running. See notes for be.engine.cluster.externalClasses.path in Table 27, Cache Cluster Properties (Sheet 1 of 3).
You can also unload previously deployed classes, using RMI. See Chapter 2, RMS and Decision Manager Configuration in TIBCO BusinessEvents Decision Manager for the procedure and for configuration details.
You can use virtual rule functions in BusinessEvents just as you would use any other rule function. At runtime the implementations provide the body of the function.
Additionally, a category of functions enables you to work with the specific features of virtual rule functions. See VRF Functions for details.