Add the PreProcessor Rule Function

In this task, you configure a rule function that replies to the request received from the HTTP channel. HTTP is a request-reply protocol, and this step is required so that the HTTP server is ready to process the next request from the readme.html form. This rule function executes when an event is received. (You’ll configure that connection later.)

What is a rule function? A rule function is a function you write in the TIBCO BusinessEvents® Extreme rule language.

How are rule functions created and used? You write rule functions using the rule editor. You can use rule functions in rules and other rule functions, in event preprocessors, and as startup or shutdown functions.

What other types of functions are there? TIBCO BusinessEvents® Extreme provides a large library of functions for various purposes. In addition, an ontology function is automatically created for each concept and event in your project. These are constructor functions. Query functions are also automatically generated for each key defined on a concept. Another type of ontology function enables you to create and schedule a timed event. You can also add custom Java functions.

[Note]

See Rules and Functions in TIBCO BusinessEvents® Extreme Application Architect’s Guide.

Relevant chapters in the TIBCO BusinessEvents® Extreme Application Developer’s Guide.

What is an event preprocessor? An event preprocessor is a rule function that processes incoming messages before TIBCO BusinessEvents® Extreme transforms them into events. In this case the preprocessor is used to send a response to the HTTP server. In real-world applications, however, a preprocessor might filter the messages so that only certain ones are used as events, and it might do other event enrichment actions. Preprocessors are multi-threaded and you can choose from various threading and queue options, as appropriate to handle the work load. By default the threading uses the system-wide shared queue and threads.

How are event preprocessors configured for use? A preprocessor is associated with a destination. It processes events arriving at that destination. See the section called “Add a Cluster Deployment Descriptor and Build the EAR File” for details.

[Note]

See Event Preprocessors in TIBCO BusinessEvents® Extreme Application Architect’s Guide.

See Event Preprocessors in TIBCO BusinessEvents® Extreme Application Developer’s Guide.

Add the PreProcessor Rule Function

  1. Right click the RuleFunctions folder, and select New > Rule Function

  2. You see the New Rule Function Wizard. In the Rule Function name field, type PreProcessor. In the Description field, type Generates a response to an HTTP request. Click Finish.

  3. Click the Form tab at the bottom of the editor.

  4. In the Scope section, click Add.

  5. You see the Select Rule Function Scope Arguments dialog. In the Types area (at the top), select Event. Click OK.

    In the Select Resource area, you could select a specific event type in the project. However, here we want any event to be in the scope of this rule function, not one specific event type.

  6. In the Alias column (in the Scope section), replace the default alias (e) with request.

  7. In the Body area, type: Event. (Event followed by a period). Notice that when you type the period (.) you see a list of all catalog functions in the Event category. Use the down arrow to scroll down the list of functions and stop at replyEvent. Its tooltip displays. Documentation for all catalog functions is provided in tooltips.

  8. Click the replyEvent function to select it. Now the body looks like this: Event.replyEvent(

    As you can see, the rule function arguments are two events, a request event and a reply event.

  9. To specify the request event, type request, the alias for the scope argument you added above.

  10. To specify the reply event, just type request again. The reply event can be any event in this case, so we can simply reply with the request event.

  11. Save and close the resource.

Summary and Next Steps

You have configured a rule function that will send a reply to requests sent by an HTTP client (through the HTTP channel). Next you will configure rules that take an action on assertion of Create, Debit, and Enable events, depending on various conditions.