This documentation is for WSO2 Stream Processor 4.0.0. View documentation for the latest release.

All docs This doc

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

With WSO2 SP's streaming SQL capabilities and its  inbuilt editor that has event simulation and debugging support, it can help you to create real-time applications much faster than before. The WSO2 SP version  4.0.0  is a new product focusing on solving stream processing and complex event processing use cases. 

WSO2 SP uses a single Siddhi Streaming SQL file for script data collection, processing, and notification logic. The batch analytics aspect is handled via Siddhi aggregations.

...

To use Siddhi, you need to write the processing logic as a Siddhi pplication in application in the Siddhi Streaming SQL language.Once a Siddhi application is created and started, it does the following:

...

Map Attributes

@attributes is an optional annotation used with the @map annotation to define custom mapping that replaces <mapping customMapping> in the CEP/DAS server. When the @attributes annotation is not provided, each mapper assumes that the incoming events adhere to its own default data format. By adding the @attributes annotation, you can configure mappers to extract data from the incoming message selectively, and assign them to attributes.

There are two ways you can configure map attributes.

  1. Defining attributes as keys and mapping content as values in the following format.
    @attributes( attributeN='mapping_N', attribute1='mapping_1')
  2. Defining the mapping content of all attributes in the same order as how the attributes are defined in stream definition.
    @attributes( 'mapping_1', 'mapping_N')

Example

This query receives events via the HTTP source in the JSON data format, and directs them to the InputStream stream for processing. Here the HTTP source is configured to receive events on all network interfaces at the 8080 port and on the foo context. The source is also secured via basic authentication.

Configuration in WSO2 DAS
Code Block
<eventReceiver ... xmlns="http://wso2.org/carbon/eventreceiver">    <from ... />
    <mapping customMapping="enable" type="json">
        <from streamName="sensor.stream" version="1.0.6"/>
        <property>
            <from dataType="meta" name="time"/>
            <to name="meta_timestamp" type="long"/>
        </property>
        <property>
            <from dataType="meta" name="meta_ispowerServed"/>
            <to name="meta_isPowerSaverEnabled" type="bool"/>
        </property>
        <property>
            <from dataType="meta" name="id"/>
            <to name="meta_sensorId" type="int"/>
        </property>
    </mapping>
    <to ... />
</eventReceiver>
Configuration in Siddhi file
Code Block
@source(type='http', receiver.url='http://0.0.0.0:8080/foo', is.basic.auth.enabled='true', 
  @map(type='json'))
define stream InputStream (name string, age int, country string);


...


Code Block
@PrimaryKey('symbol')
define table StockTable (symbol string, price float, volume long);

Indexes

Indexes allow tables to be searched/modified much faster.

Indexes are configured by including the @Index( 'key1', 'key2' ) annotation to the table definition. Each event table configuration can have 0-1 @Index annotations. Support for the @Index annotation and the number of attributes supported differ based on the table implementations. When more then one attribute is used for index, each one of them is used to index the table for fast access of data. Indexes can be configured together with primary keys.

Example

This query creates an indexed event table named RoomTypeTable with the roomNo attribute as the index key.

Code Block
@Index('roomNo')
define table RoomTypeTable (roomNo int, type string);
      

Execution Plan -> Queries

...