CREATE STREAM statement

Creates a data stream attached to the current query module or submodule.

Syntax

CREATE [ INPUT | OUTPUT | LOCAL ] STREAM name [schema_clause] [PROPERTIES prop_def [, ...] ] ;
Components

name

The name of the stream.

schema_clause

The definition of the schema for the stream. See SCHEMA Clause for syntax and usage. Can be omitted if the schema will be created automatically, as described in INSERT Clause and SELECT Clause.

prop_def

A property definition. Not valid for local streams.

prop_def

{ GUARANTEED DELIVERY = {INHERIT | ENABLE | DISABLE} } | { GUARANTEED DELIVERY MAXIMUM QUEUE SIZE = size } | { GUARANTEED DELIVERY MAXIMUM AGE = age } | { MAXIMUM DELAY = max_delay } | { OUT OF ORDER DELAY = delay } | { SYNCHRONIZATION = { INHERIT | IN ORDER | OUT OF ORDER | USE SERVER TIMESTAMP } } | { FILTERCOLUMNS = " col_name [, ...] " }

Components

size

The size of the guaranteed delivery queue, in number of rows.

age

The maximum permitted age of rows in the guaranteed delivery queue, as an interval.

max_delay

An interval specifying the maximum time Sybase CEP Engine waits before sequencing incoming rows.

delay

An interval specifying the maximum time rows can be late before Sybase CEP Engine discards them.

col_name

The name of a column to use for filtering.

Usage

If you do not specify a type of stream, Create Stream creates a local stream by default.

For input and output streams, you can assign property values affecting behavior. You can list such specifications in any order. The values for the properties can be specified with any CCL element that is evaluated at compile time, such as functions, operators, and literals, but cannot contain references to stream or window columns or to other elements whose value is determined at run time.

GUARANTEED DELIVERY

This option controls the Guaranteed Delivery feature, which guarantees that every row is received by its destination at least once, as long as the application components are running. In order to truly guarantee delivery, you must also enable persistence on the module to ensure that rows are delivered even after a software failure.

The INHERIT keyword causes the stream to inherit the Guaranteed Delivery settings of its query module or submodule. This is the default setting of Guaranteed Delivery options for input and output streams.

The ENABLE keyword enables Guaranteed Delivery for the data stream, even if Guaranteed Delivery is turned off for the query module or submodule as a whole.

The DISABLE keyword disables Guaranteed Delivery for the data stream, even if the Guaranteed Delivery is turned on for the query module or submodule as a whole.

GUARANTEED DELIVERY MAXIMUM QUEUE SIZE

When Guaranteed Delivery is enabled for the stream this option specifies the maximum number of rows that should be held in the Guaranteed Delivery queue. Rows that exceed the allowed number are expired from the Guaranteed Delivery queue and their delivery is not guaranteed. The default setting for this option is 0, indicating that no limit is placed on the number of rows the Guaranteed Delivery queue can hold.

GUARANTEED DELIVERY MAXIMUM AGE

When Guaranteed Delivery is enabled for the stream this option specifies the maximum permitted age of rows in the Guaranteed Delivery queue. Rows that exceed the allowed age are expired from the Guaranteed Delivery queue and their delivery is not guaranteed. The default setting for this option is 0, indicating that no limit is placed on the age of rows in the Guaranteed Delivery queue.

MAXIMUM DELAY

The interval specified by this option allows Sybase CEP Server to correct synchronization problems among rows arriving in different input streams in a query module or submodule. Sybase retains incoming rows of all the input streams in the query module or submodule for the interval specified by MAXIMUM DELAY before sorting the order in which they arrive in their respective streams.

Since different streams may have MAXIMUM DELAY set to different values, the largest setting of this field among the different streams attached to the query module or submodule is used to determine the overall MAXIMUM DELAY interval. The default MAXIMUM DELAY setting is one (1) second. MAXIMUM DELAY should not be set to 0.

If the SYNCHRONIZATION property is set to INHERIT, the stream uses the MAXIMUM DELAY setting of the query module or submodule containing the stream, and any MAXIMUM DELAY setting specified directly in the stream properties is ignored.

OUT OF ORDER DELAY

The interval specified by this option allows Sybase CEP Server to correct synchronization problems in a given input stream. Sybase CEP Server retains incoming rows for the input stream for the specified interval before ordering them by their timestamp, and delivering them into the stream. This ensures that any time synchronization problems between Sybase CEP Server and outside data sources encountered in the specified time period are resolved before the information is fed into the stream.

If a row with an earlier timestamp arrives in the stream after the interval specified by OUT OF ORDER DELAY, it is discarded. The default OUT OF ORDER DELAY setting is 0, indicating that rows are not held before being ordered by timestamp.

The OUT OF ORDER DELAY property works in conjunction with the SYNCHRONIZATION property, as explained in the SYNCHRONIZATION option entry of this table.

If the SYNCHRONIZATION property is set to INHERIT, the stream uses the OUT OF ORDER DELAY setting of the query module containing the stream, and any OUT OF ORDER setting specified directly in the stream properties is ignored.

SYNCHRONIZATION

The SYNCHRONIZATION property works with MAXIMUM DELAY and OUT OF ORDER DELAY to correct synchronization problems in a given input stream.

Setting SYNCHRONIZATION to INHERIT causes the input stream to inherit the MAXIMUM DELAY, OUT OF ORDER DELAY and SYNCHRONIZATION settings of the query module in which the stream is contained. INHERIT is the default synchronization setting.

Setting SYNCHRONIZATION to IN ORDER causes Sybase CEP Server to discard any rows arriving in the stream that have an earlier timestamp than the row currently in the stream. When this setting is used, the OUT OF ORDER DELAY property must not be set. If IN ORDER is set and an OUT OF ORDER DELAY value is specified, Sybase CEP Engine issues a warning and ignores the OUT OF ORDER DELAY setting.

Setting SYNCHRONIZATION to OUT OF ORDER causes Sybase CEP Server to retain incoming rows for the input stream for the interval specified by the OUT OF ORDER DELAY property, before ordering them by their timestamp, and delivering them into the stream. This ensures that any time synchronization problems between Sybase CEP Server and outside data sources encountered in the specified time period are resolved before the information is fed into the stream. When this setting is used, the OUT OF ORDER DELAY property must be set to a value of 1 or higher. If OUT OF ORDER is used in conjunction with an OUT OF ORDER DELAY setting of 0, the stream behaves as though the IN ORDER synchronization setting were selected.

Setting SYNCHRONIZATION to USE SERVER TIMESTAMP causes rows arriving in the stream to be assigned a timestamp by Sybase CEP Engine, based on the current time reflected by Sybase CEP Server. This timestamp overrides and replaces the timestamp set by the input adapter.

FILTERCOLUMNS

The optional FILTERCOLUMNS property, used with output streams, defines a filter based on one or more columns from the stream's schema definition. The filter allows subscribers to the stream to receive only rows that include specified values in the filter column(s) without needing to filter the values using the CCL query filtering clauses.

The actual values that the subscriber should receive are passed as GET parameters in the stream URI, using either Sybase CEP Studio, or Sybase CEP SDKs. For example if you define a "FILTERCOLUMNS = 'Exchange, Symbol'" filter, you can then set the stream URI to receive only rows where the value in the Exchange column is NYSE and the value in the Symbol column is IBM. The filtering is performed by Sybase CEP Server before the stream's subscribers receive data from the stream. See the Sybase CEP Studio Guide for information on data filtering in Sybase CEP Studio, and the Sybase CEP Integration Guide for information about filtering using Sybase CEP SDKs.

Restrictions

See Also

Example

CREATE OUTPUT STREAM Alerts 
  SCHEMA 'alerts.ccs'
  PROPERTIES 
  GUARANTEED DELIVERY = ENABLE,
  GUARANTEED DELIVERY MAXIMUM AGE = 10 MINUTES
  FILTERCOLUMNS="User, Host";