Query the Cache Using BQL Queries
In order to execute the queries, you must first enable a dynamic query session.
Note:
- This method relates to Cache OM functionality and is not relevant if you are using TIBCO BusinessEvents Express edition.
- This method of querying a cache requires use of the TIBCO BusinessEvents Event Stream Processing add-on product.
- The term BQL is an acronym indicating the TIBCO BusinessEvents Event Stream Processing query language.
- This is the only method that works with TIBCO BusinessEvents DataGrid.
- For the Coherence cache provider you can also use the methods explained in TIBCO BusinessEvents Architect’s Guide.
Procedure
Example Rule Function for a TIBCO BusinessEvents DataGrid Cache
The following example preprocessor rule function code shows the techniques used for querying a TIBCO BusinessEvents DataGrid cache. You can then use standard functions to work with the entities returned by the query.
/** * @description */ void rulefunction RuleFunctions.InputEventPreprocessor { attribute { validity = ACTION; } scope { Events.InputEvent inputevent; } body { System.debugOut("Now starting InputEventPreprocessor"); Concepts.Misc misc = Instance.getByExtId("misc"); String[] EXTIDS_COLLECTION = Instance.PropertyArray.toArrayString(misc.EXTID_LIST); String queryString = "select c" + "\n from /Concepts/TestConcept as c" + "\n where c@extId in" + "(\"" + EXTIDS_COLLECTION[0] + "\", \"" + EXTIDS_COLLECTION[1] + "\", \"" + EXTIDS_COLLECTION[2] + "\", \"" + EXTIDS_COLLECTION[3] + "\", \"" + EXTIDS_COLLECTION[4] + "\")"; System.debugOut("Executing query: \n" + queryString); Object resultList = Query.Util.executeInDynamicQuerySession(queryString, null, true); System.debugOut("Query returned: " + Query.Util.sizeOfList(resultList) + " rows"); while(Query.Util.sizeOfList(resultList) > 0){ Concepts.TestConcept c = Query.Util.removeFromList(resultList, 0); Cluster.DataGrid.CacheLoadEntity(c); System.debugOut("Now loading concept " + c + " in the pre-processor"); } } }
Copyright © TIBCO Software Inc. All Rights Reserved.