Skip to content

API Docs - v4.1.0

Sinkmapper

wso2event (Sink Mapper)

This section explains how to map events processed via Siddhi in order to publish them in the WSO2Event format. In default mapping, the format used is the pre-defined WSO2Event format that adheres to the schema of the defined stream. In order to use custom mapping, additional parameters need to be configured (i.e., in addition to the format type).

Syntax

@sink(..., @map(type="wso2event")

Examples EXAMPLE 1

`@sink(type='wso2event', @map(type='wso2event')); ``define stream FooStream (symbol string, price float, volume long);`

This configuration performs a WSO2 default input mapping that generates thefollowing output.
Wso2event = {
                 streamId: barStream:1.0.0,
                 timestamp: FooStream_siddhi_event_timestamp,
                 metaData: [],
                 correlationData: [],
                 payloadData: [symbol, price, volume]
            }

EXAMPLE 2

@sink(type='wso2event', @map(type='wso2event',meta_timestamp='timestamp', symbol='symbol', price='price',volume='volume', arbitrary_portfolioID='portfolio_ID')) define stream FooStream (timestamp long, symbol string, price float, volume long, portfolioID string);

This configuration performs a custom mapping and produces the following output.
Wso2event = {
                 streamId: barStream:1.0.0,
                 timeStamp: FooStream_siddhi_event_timestamp,
                 metaData: [meta_timestamp],
                 correlationData: [],
                 payloadData: [symbol, price, volume],
                 arbitraryDataMap: arbitrary
            }
The value of the arbitrary_portfolioID attribute in the processed Siddhi event is assigned as the value for the portfolio_ID attribute in the published WSO2Event event.'>

Sourcemapper

wso2event (Source Mapper)

This extention is a WSO2Event input mapper type that converts events received in WSO2Event format to Siddhi events before they are processed. In default mapping, the format used is the pre-defined WSO2Event format that adheres to the schema of the defined stream. In order to use custom mapping, additional parameters need to be configured (i.e., in addition to the format type). This is useful when the events are generated by a third party and as a result, you do not have control over how they are formatted.

Syntax

@source(..., @map(type="wso2event")

Examples EXAMPLE 1

@source(type=?wso2event?, @map(type=?wso2event?) define stream FooStream (meta_timestamp long, symbol string, price float, volume long);

This query performs a default mapping to convert an event of the WSO2Event format to a Siddhi event. The expected input is as follows.
Wso2event = {
                streamId: org.wso2event.fooStream:1.0.0,
                timestamp: 431434134134,
                metaData: [timestamp],
                correlationData: [],
                payloadData: [symbol, price, volume]
            }

EXAMPLE 2

@source(type=?wso2event?, @map(type=?wso2event?, @attributes(timestamp='meta_timestamp',symbol='symbol',price='price',volume='volume',portfolioId='arbitrary_portfolio_ID')))define stream FooStream (timestamp long, symbol string, price float, volume long, portfolioId string)); 

This query performs a WSO2 mapping. Expected input is as follows.follows,
Wso2event = {
                streamId: org.wso2event.fooStream:1.0.0,
                timeStamp: 431434134134,
                metaData: [timestamp],
                correlationData: [],
                payloadData: [symbol, price, volume],
                arbitraryDataPosition: objectMap,
            }
In this query, the WSO2 mapper gets the value of the arbitrary_portfolio_id attribute in the WSO2Event event received, and assigns it to the portfolioId attribute in the corresponding Siddhi event.