Creating a Siddhi Application
com.atlassian.confluence.content.render.xhtml.migration.exceptions.UnknownMacroMigrationException: The macro 'next_previous_link3' is unknown.

Creating a Siddhi Application

Siddhi applications are files that define the Siddhi logic to process the events sent to WSO2 SP. They are written in the Siddhi Query Language using the Stream Processor Studio tool shipped with WSO2 SP.

A Siddhi file contains the following configurations:

Configuration

Description

Configuration

Description

Stream

A logical series of events ordered in time with a uniquely identifiable name, and set of defined attributes with specific data types defining its schema.

Source

This consumes data from external sources (such as TCPKafkaHTTP, etc) in the form of events, then converts each event (that can be in XMLJSONbinary, etc. format) to a Siddhi event, and passes that to a stream for processing.

Sink

This takes events arriving at a stream, maps them to a predefined data format (such as XMLJSON, binary, etc), and publishes them to external endpoints (such as E-mailTCPKafkaHTTP, etc).

Executional Element

An executional element can be one of the following:

  • Stateless query: Queries that only consider currently incoming events when generating an output. e.g., filters

  • Stateful query: Queries that consider both currently incoming events as well as past events when generating an output. e.g., windows, sequences, patterns, etc. 

  • Partitions: Collections of stream definitions and Siddhi queries separated from each other within a Siddhi application for the purpose of processing events in parallel and in isolation.

Creating a Siddhi application

To create a Siddhi application, follow the steps below:

  1. Start WSO2 SP in the editor mode and access the Stream Processor Studio. For detailed instructions, see Starting Stream Processor Studio. The Stream Processor Studio opens as shown below.

  2. Click New to start defining a new Siddhi application. A new file opens as shown below.

  3.  Add the following sample Siddhi application to the file.

    @App:name("SweetProductionAnalysis") @Source(type = 'tcp', context='SweetProductionData', @map(type='binary')) define stream SweetProductionStream (name string, amount double); @sink(type='log', @map(type='json')) define stream ProductionAlertStream (name string, amount double); from SweetProductionStream select * insert into ProductionAlertStream;
  4. To save this Siddhi application, click File, and then click Save. By default siddhi applications are saved in the <SP_HOME>/wso2/editor/deployment/workspace directory.

  5. To export the Siddhi application to your preferred location, click File, and then click Export File

com.atlassian.confluence.content.render.xhtml.migration.exceptions.UnknownMacroMigrationException: The macro 'next_previous_links2' is unknown.