Success and Failure Listeners (Callback Functions)

For each instantiated and deployed pattern instance, you configure two callback rule functions. One acts as a success listener and the other as a failure listener.

Note: Do not perform time consuming operations in a listener. A listener should return control quickly to insure efficient functioning of the pattern service.

The listeners execute every time a pattern succeeds or fails.

On successful completion of a pattern the service invokes the success listener. If the pattern fails because of a timeout or elements of the pattern arriving out of order, then it invokes the failure listener.

Success and failure listeners have the same arguments. Advanced listeners have an additional argument.

Functions that Cannot be Used in Listeners

Functions that read, modify, or delete concepts and events, such as Instance.deleteInstance(), cannot be used in the callback functions that you use as listeners. These functions must execute in the context of a run to completion cycle (RTC). They cannot be used in success or failure listeners, which run in a different thread. (See the functions documentation for details on thread pool management functions such as the Pattern.Manager.Advanced.setPoolSize() function.)

In order to use functions that execute in the context of an RTC, create a rule that executes the functions, and create an event with all the necessary information. Send the event using Pattern.IO.toDestination(), preferably on a local channel. The event is asserted in an RTC and triggers the rule, which executes the desired functions.

Tip: TIBCO BusinessEventsFunctions that are valid in the query engine are also valid in the pattern engine.