Open topic with navigation

TIBCO BusinessEvents® Enterprise Edition 6.3.1

# Dynamic Query Agent Sessions

You can dynamically start a collocated query agent session from an inference agent and make queries, using startup and preprocessor rule functions.

## executeInDynamicQuerySession

The following function is used in the inference agent's preprocessor. It enables you to execute a query in the dynamic query agent session (without the need for collocated query agent),, and use the results:

    Query.Util.executeInDynamicQuerySession(String sqlString, Object mapOfParameters, boolean reuse, long timeout, boolean isNativeQueryRawResults);

The is an example showing how you might use this rule function:

    void rulefunction Inference.RuleFunctions.MyPreProcessor {
           attribute {
       validity = ACTION;
    }
    scope {
       Events.AccountOperations request;
    }
    body {
       String queryString = "select acc" +
          " from /Concepts/Account as acc" +
          " where acc.Status = \"Normal\"";
       Object resultList = Query.Util.executeInDynamicQuerySession(queryString, null, true);
       int size = Query.Util.sizeOfList(resultList);
       System.debugOut("Result list has " + size + " items");

       for(int i = 0;  i < size; i = i + 1){
          Object row = Query.Util.removeFromList(resultList, 0);
          Concepts.Account acc = row;
          System.debugOut("  Result row: " + acc);
          }
       }
    }

## executeInQuerySession

The following rule functions executes the SQL string synchronously in the collocated query and returns the results:

    Query.Util.executeInQuerySession(String querySessionName, String sqlString, Object mapOfParameters, boolean reuse, long timeout, boolean isNativeQueryRawResults)

## invokeFunctionInQuerySession

The following rule function invokes a rule function in another query session/agent and needs a collocated query agent. The name of the query session/agent, which is deployed in the same processing unit, is provided as a parameter:

    Query.Util.invokeFunctionInQuerySession(String querySessionName, String queryRuleFunctionUri, Object[] parameters)

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.