A.11.2 ADDRULE

Adds a new Oracle CQL rule, query, or view to the specified processor of an Oracle Stream Analytics application. If a rule, query, or view with the same name (identified with the rulename, queryname, or viewname parameter) already exists, then the ADDRULE command replaces the existing rule, query, or view with the new one.

Note:

An Oracle CQL query immediately begins to output events when its input channels provides input events. If you plan to use a query selector on a channel with an upstream Oracle CQL processor, then you might observe unwanted query results on the downstream channel between the time you add the query to the upstream Oracle CQL processor and the time you configure the query selector on the downstream channel.

Syntax

java wlevs.Admin 
    [ Connection Arguments ]
    [ User Credentials Arguments ]
    [ Common Arguments ] 
    ADDRULE -application application -processor processor 
        -rule  [rulename]  rulestring  | 
        -query [queryname] querystring | 
        -view  [viewname]  viewstring [-schema comma-separated-names]
        [-active true | false]

Table A-7 ADDRULE Arguments

Argument Definition
-application application

Specifies the name of the Oracle Stream Analytics application whose Oracle CQL rules you want to manage.

To get the exact name of your application, you can:

  • Use wlevs.Admin to query for the name (see Query for Application and Processor Names).

  • Use the Oracle Stream Analytics Visualizer: Start the Oracle Stream Analytics Visualizer (see Using Visualizer for Oracle Stream Analytics). In the left pane, navigate to and expand the Applications node of the Oracle Stream Analytics instance to which the application is deployed. Each node under the Applications node is named with the exact application name.

  • Look at the MANIFEST.MF file of the application; the application name is specified by the Bundle-SymbolicName header.

-processor processor

Specifies the name of the particular processor, attached to the Oracle Stream Analytics application specified with the -application argument, whose Oracle CQL rules you want to manage.

See Query for Application and Processor Names for details on getting the exact name if you do not know it.

-rule [rulename] rulestring

Specifies the Oracle CQL rule you want to add to the specified processor of your application. An Oracle CQL rules include:

  • REGISTER|CREATE FUNCTION (aggregate and single-row functions)

  • REGISTER|CREATE WINDOW

The rulename parameter is not required; if you do not specify it, Oracle Stream Analytics generates a name for you.

Enter the Oracle CQL rulestring using double quotes.

-query [queryname] querystring

Specifies the Oracle CQL query you want to add to the specified processor of your application.

The queryname parameter is not required; if you do not specify it, Oracle Stream Analytics generates a name for you.

Enter the Oracle CQL querystring using double quotes.

-view [viewname] viewstring [-schema comma-separated-names]

Specifies the Oracle CQL view you want to add to the specified processor of your application.

The viewname parameter is not required; if you do not specify it, Oracle Stream Analytics generates a name for you.

Enter the Oracle CQL viewstring using double quotes.

The comma-separated-names parameter is not required; if you do not specify it, Oracle Stream Analytics generates the schema based on the select statement in the viewstring.

-active true | false

Specifies if the rule should be started and ready to process events after being added.

Valid values for this argument are true (start rule after adding) or false (do not start rule after adding); default value is true. If set to false, use STARTRULE to start the rule.

Example

The following example shows how to add the Oracle CQL query SELECT * FROM Withdrawal [Rows 5], with name myquery, to the Oracle CQL processor helloworldProcessor of the helloworld application:

java wlevs.Admin 
     -url service:jmx:msarmi://localhost:9002/jndi/jmxconnector 
     -username wlevs -password wlevs 
     ADDRULE -application helloworld -processor helloworldProcessor 
     -query myquery "SELECT * FROM Withdrawal [Rows 5]"