This chapter explains how to work with the rule editor to create rules and rule functions. It also explains some specific uses for rule functions.To learn how rules are executed at runtime and for other background information see TIBCO BusinessEvents Architect’s Guide, especially the section Understanding Conflict Resolution and Run to Completion Cycles.
•
• Chapter 24, Diagrams for information on using rule dependency and sequence diagrams.You can switch between editors and changes made in one editor are reflected in the other one. You can’t switch from the source editor to the form editor if there are validation errors in the code.A BusinessEvents rule has three components:
• Declaration — Use the declaration to declare which concepts and events the rule will depend on, and the names by which instances of these entities can be referred to in the conditions and actions. Aliases must be valid identifiers. Declaring multiple terms of the same type allows the rule to consider multiple instances of the corresponding Entity.
• Conditions — Each statement in the condition must evaluate to a boolean value. All of these statements must be true for the rule’s action to be executed. Assignments and calls to certain functions are disallowed in the condition.
• Actions — List of statements that will be executed, when the rule is fired, for each combination of terms that matches all the conditions.At runtime, event instances that are created using rules are not automatically asserted. You must explicitly assert such events, for example using the Event.assertEvent() function.Events that are created from incoming messages, on the other hand, are automatically asserted.BusinessEvents includes two functions that allow you to send simple events out to another application: Event.sendEvent() and Event.routeTo().
• Event.sendEvent() automatically sends the event to its default destination.
• Event.routeTo takes a destination as an argument, ignoring the event’s default destination.With routeTo you can direct an event to a destination on a different channel from the event’s default destination. You can also override the properties of the destination, for example, the subject.You cannot, however, override the properties of the channel itself, for example, the network field in a Rendezvous channel.First you create a scheduler using the function Cluster.createScheduler(); then you use the function Cluster.scheduleEvent to schedule an event to be sent at a certain time:The work key is the name of the scheduled task (event), used to identify it later, for exampl to cancel it. You also specify a time in milliseconds. It is the number of milliseconds after the function is called that the event will be sent.When using Cache Only cache mode for one or more entities, you must consider how to handle the cache-only entities when you write rules and preprocessor rule functions. See Working With Cache Modes and Loading Cache-Only Objects into the Rete Network in TIBCO BusinessEvents Architect’s Guide.
Copyright © TIBCO Software Inc. All Rights Reserved.