Open topic with navigation

TIBCO BusinessEvents® Enterprise Edition 6.3.1

# Obtain Results Using a Callback Rule Function

You can pass query results to a callback rule function.

Two functions are available for this purpose:

- `Query.Statement.executeWithCallback()` calls the rule function once for each row of results, as well as at the end of a batch (if ordering is used) and at the end of the execution. Results are sent to the callback rule function as individual rows of data. (See Example Showing Batching of Return Values (Continuous Queries) for an example.)
- `Query.Statement.executeWithBatchCallback()` calls the rule function at the end of a batch and at the end of the execution. The results are sent to the callback rule function as an array of rows of data, at batch end. It is generally used for queries that contain an `order by` clause, which results in useful batches of data. It is useful, for example, when you want to send an outbound message containing all the results of a batch.

Only `Query.Statement.executeWithCallback()` can be used for snapshot queries. When used with snapshot queries, the query looks at the current state of the cache and calls the rule function once for each matching row, in quick succession. Batching is not used with snapshot queries.

Both functions are used for continuous queries. You set the `IsContinuous` argument to `true` so that the query runs as a continuous query. When used in continuous queries, the query listens for changes to the cache, or listens to events if the query is listening to events, and calls the rule function as matches occur over the lifetime of the query.

Note: Use `Query.Statement.executeWithCallback()` only when batches of results will be small.

The format of the `Query.Statement.executeWithCallback()` function is shown in following sample. The format of the `Query.Statement.executeWithBatch Callback()` function is the same (but the way it sends results to the callback function is a little different).

    Query.Statement.executeWithCallback(
    String  statementName,
    String  listenerName,
    String  callbackUri,
    boolean isContinuous,
    Object  closure)

The `listenerName` parameter keeps results from different executions separate from each other.

The `callbackUri` parameter value provides the project path to the callback rule function.

The `isContinuous` parameter defines if the query is a snapshot or continuous query.

The `closure` parameter is stored during the execution of the query, and provided as a parameter to the callback function every time that function is called.

For example:

    String execID = evt@extId;
    Query.Statement.executeWithCallback(
    MyStmt, MyexecID, "/MyRuleFunction", false, evt);

See Callback Rule Function Data Usage for details.

Did you find this helpful?

YesNo
Great!
Thanks for taking the time to give us some feedback.
Sorry about that

Why wasn't this helpful? (check all that apply)

Could not find what I was looking for
Instructions confusing or unclear
Instructions did not work

Want to tell us more?

Please select at least one option or provide details about the issue!!

Error occurred while submitting feedback.

Error2 occurred while submitting feedback.

TIBCO BusinessEvents® Enterprise Edition

Copyright © 2004-2024. Cloud Software Group, Inc. All Rights Reserved.