The functions registry includes various catalogs of functions provided with the product, and each catalog organizes functions into various related categories. You can use functions in rule conditions and actions and in rule function bodies.All catalogs appear in the Catalog Functions view. To open the view navigate to Window > Show View > Other > TIBCO BusinessEvents and select Catalog Functions. The catalog view appears on the right, by default.For all the built-in functions, this section lists the main categories in each function catalog (but not sub-categories). See TIBCO BusinessEvents Functions Reference for full details.The most generally useful catalog, the standard function catalog include the following categories:
• BusinessWorks functions are used in ActiveMatrix BusinessWorks integration projects. See Chapter 20, ActiveMatrix BusinessWorks Integration.
• Channel functions return information about destinations, and can resume and suspend a destination.
• Cluster functions help with multi-engine functionality
• Coherence functions are for use with Cache object management. See Guidelines for Use of Coherence (Cache Query) Functions.
• Date functions allow you to compare two DateTime values using only the date portion of the value.
• DateTime functions allow you to perform these date/time related tasks and more: add units of time to a DateTime, compare, retrieve, and format dates and times.
• Engine functions allow you to retrieve information about the engine, for example, available memory or the number of rules fired.
• Event functions allow you to assert, create, and send simple events and perform other event-related tasks, for example, return the default destination URI of a simple event.
• The Exception function enables you to create an exception.
• File functions provide various useful functions used when working with files.
• HTTP functions are used with the HTTP channel
• Instance functions allow you to create and delete concept instances and perform other instance-related tasks, for example, return an instance given an internal ID.
• Math functions allow you to perform advanced mathematical operations.
• Number functions allow you to perform type conversions from and to numbers and return the maximum and minimum values for a numeric type.
• SOAP functions enable you to work with SOAP messages sent through an HTTP channel.
• String functions allow you to perform comparisons, searches, conversions, and other operations with strings.
• System functions allow you to send messages to a debug log, retrieve global variables, retrieve system properties, and write data to a file.
− IO functions allow the writing and closing of specific files.
• Temporal functions allow you to examine and perform calculations on values stored in a property’s history. For information about using temporal functions, see Temporal Functions.
• Util functions category has one sub-category for working with HashMaps.
• VRF functions (that is, Virtual Rule Function functions) allow you to work with decision tables. See VRF Functions and see TIBCO BusinessEvents Decision Manager User’s Guide for details.
• XPath functions allow you to evaluate XPath expressions.Pattern functions are used with the pattern matcher language for identifying patterns in events. See TIBCO BusinessEvents Event Stream Processing add-on documentation for details.Query functions are used with the query language for querying data in the cache. See TIBCO BusinessEvents Event Stream Processing add-on documentation for details.Communication functions provide a set of catalog functions that enables TCP communication. You can create a local TCP server and a TCP client so that BusinessEvents can communicate with data sources not otherwise available through channels, using TCP. See Communicating with Other Sources using TCP for details.Database functions are provided for working with database concepts. See TIBCO BusinessEvents Data Modeling for more on database concepts.These functions are used internally by the Decision Manager add on, for authentication.You can also create custom functions. Custom functions appear in the Custom Function catalog. For information about custom functions, see Adding Custom Functions.Ontology functions are generated by BusinessEvents based on the concepts, events, and rules in your project. There are three types of ontology functions:The Ontology Functions area uses the same folder structure as the project (or rather, a subset of that structure).When you float the curser over a function in the registry, BusinessEvents displays the description and syntax in a tool tip next to the curser. Tooltips also form the online reference to the function catalogs. See TIBCO BusinessEvents Functions Reference in the HTML documentation.
Some functions are decorated with small letters that indicate useful information about use of the function. A function can have zero, one, or more decorations. the following figure shows all the available decorations. They are described in the sections after the figure:Functions that bring up the XSLT mapper and XPath builder are identified by a small m at the upper left of the f, for example:. For more on using mapper functions, see Using the Function Argument Mapper.
Functions That Can Be Used in Decision ManagerFunctions that can be used in Decision Manager are marked with a small table icon,for example (which is also an action-only function).
Some functions can be used only in rule actions, some in rule actions and rule conditions, and some in actions, conditions, and in queries.Functions that can be used in actions and conditions have no decoration. They are considered to have the default validity.These functions are for use in rule actions only. Some of these functions have side effects, for example they can change values. Other functions are limited to actions for other reasons. These action-only functions are identified by a small a at the bottom right of the f. For example:.
Functions that can be used in queries or with Pattern Matcher are marked with a blue q for example,, for example. You can call such functions in a query string.
See documentation for TIBCO BusinessEvents Event Stream Processing add-on software for details on pattern matcher and query features.These functions are used only with TIBCO BusinessEvents Decision Manager.The VRF category of functions (within the Built-in > Standard Functions) provide flexibility when you are working with virtual rule function implementations.
Default Implementation When you deploy multiple implementations (tables) for one virtual rule function, but use a function that doesn’t specify the implementation by name, for example if you use Functions.MyVirtualRuleFunction(), the default implementation is used. The default implementation is whichever was the last implementation to be deployed. However, if you use hot deployment, it may not be possible to determine which implementation was deployed last.Common arguments used in the above functions are described in Table 25, Common Arguments for VRF Functions.
1. Right-click the folder where you want to store the virtual rule function and select New > Rule Function. You see the New Rule Function Wizard.
a. Inthe Rule Function Name field, type a name for the rule function.
b. In the Description field, type a description. (In the source editor the description appears in the * @description line of the comments at the top of the editor).
c. Check the Virtual checkbox.
You can’t change a new resource name after you click Finish. (You can change the description, however.)
2. Click Finish.Click the tabs at the bottom of the editor to switch between the form-based editor and the source editor as you work, depending on your preference. These instructions use the form editor and mention the equivalent settings in the source editor.
3. In the Form editor Configuration panel, add or edit a description as desired. (In the source editor the description appears in the * @description line of the comments at the top of the editor).
4. If you did not do so in the Wizard, check the Virtual check box.
In the source editor, the signature of a virtual rule function is:Do not add code to the Body block in the source editor of a virtual rule function. If you do, you see error messages if you try to save orto switch to the form-based editor.In virtual rule functions, the Validity field is set to Action and the Return Type is set to Void. column, select where the rule function can be used (source editor equivalents shown in parentheses:
5. In the Scope section (scope statements in the source editor), drag an ontology entity into the Scope area, OR do the following:
a. Click Add to add resources that you will be using in your rule function. You see the Select Rule Function Scope Arguments dialog.
b. In the upper half of the Select Rule Function Scope Arguments dialog, select the type you want to use.
c. If the type you select is an ontology type, in the lower half of the dialog, select a resource from the filtered ontology tree.
d. Click OK.Your selection appears in the Declarations list. BusinessEvents assigns an alias to it. You can edit the alias.Add more entities as needed.
6. For example, hereis the source view for a simple virtual rule function:
/*** @description Action to take when account is suspendedvirtual void rulefunction Rules.FollowUp {
Table 25 Common Arguments for VRF Functions The universal resource identifier (URI) for the virtual rule function. This is typically the full path to the virtual rule function within the project directory. For example, in the CreditCardApplication example, the virtual rule function Person_VirtualRuleFunction() has the following URI: An object representing a virtual rule function implementation. This argument is required when invoking specific virtual rule function implementations. The name of a decision table (also known as a virtual rule function implementation). For example, in the CreditCardApplication example, the virtual rule function BankUser_VirtualRuleFunction has an implementation (decision table) called bankUser.The implName argument is used to retrieve a corresponding implementation object, or to execute an implementation. The arguments to be passed to one or more virtual rule function implementations on invocation. These objects consist of the concepts, events, scorecards, and so on. that are needed by the implementation or implementations. For example, the processApplication implementation in the CreditCardApplication example project requires concepts of type Application, BankUser, and CreditCardApplication to be passed as arguments. In order to invoke the processApplication implementation, an instance of each concept type must be passed in the args array. Not used in this release. This argument is used only for the invokeVRFImpls function. When invoking multiple implementations, the return value of each implementation is stored in this array. The array will contain a null entry for each implementation that does not return a value.The set of Built-In > Standard functions that come with TIBCO BusinessEvents includes functions that allow you to perform calculations on numeric values sampled over time. These functions are called temporal functions and they work exclusively with concept properties that store numeric values. Temporal functions make use of the history ring buffer to sample a property’s values over time.
• property — The property for which you want to sample values.
• stime — The time from which you want to begin sampling values (the start time) measured in milliseconds since 00:00:00 UTC on January 1, 1970.
• etime — The time at which you want to stop sampling values (the end time) measured in milliseconds since 00:00:00 UTC on January 1, 1970.
• sample_rate — The number of milliseconds between samples.
• bound_by_stime — A flag indicating whether the start-time is flexible:
− True indicates that if the start time you provide is earlier than the timestamp for the oldest available value, you want to perform the calculation starting with the oldest available value.
− False indicates that if the start time you provide is earlier than the timestamp for the oldest available value, you want to abort the calculation.Figure 4 Temporal Functions Parameters
Copyright © TIBCO Software Inc. All Rights Reserved.