This documentation is for WSO2 Complex Event Processor 4.0.0. View documentation for the latest release.
WSO2 Complex Event Processor is succeeded by WSO2 Stream Processor. To view the latest documentation for WSO2 SP, see WSO2 Stream Processor Documentation.
Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

Version 1 Next »


This sample demonstrates how to set up an execution plan with some basic queries that perform projections and transformations of attributes and enriching events with new attributes. This sample uses Event simulator for inputs and the logger publisher for logging the outputs to the CEP console.

The execution plan used in this sample are as follows:

define table CardUserTable (name string, cardNum string, blacklisted bool) ; 

from CardUserStream
select * 
insert into CardUserTable;
from BlackListStream
select cardNo as cardNum, true as blacklisted  
update CardUserTable
	on cardNum == CardUserTable.cardNum;
from PurchaseStream#window.length(1) as p join CardUserTable as c
	on  p.cardNo == c.cardNum and c.blacklisted == false
select p.cardNo as cardNo, as name, p.price as price
insert into WhiteListPurchaseStream ;
from DeleteAllUsers 
delete CardUserTable
	on deleteAll == true;

The table definition,

  • Defines a table named CardUserTable with the given attributes 

The first query,

  • Processes the events received through the CardUserStream
  • Selects all the attributes under the select clause, from each event received. 
  • Inserts it to the CardUserTable.

The second query,

  • Processes the events received through the BlackListStream
  • Selects cardNo and renames it as cardNum, introduces a new attribute named blacklisted with the value 'true' under the select clause, for each event received. 
  • Updates the CardUserTable with the condition cardNum == CardUserTable.cardNum. Here the 'blacklisted' attribute in the table will be updated with the new value.

The third query,

  • Processes the events received through the TempStream.
  • When selecting the attributes, concatenate roomNo and deviceId with the inbuilt concat function and names it as uuid using the 'as' keyword, converts the temp attributes to Farenheit scale (from the incoming Celcius scale), and then adds a new attribute named 'scalw' with the value 'F' under the select clause, from each event received. 
  • Emits those events as output events through the TransformedRoomTempStream.


See Prerequisites in CEP Samples Setup page.

Building the sample

Start the WSO2 CEP server with the sample configuration numbered 0101. For instructions, see Starting sample CEP configurations. This sample configuration does the following:

  • Points the default Axis2 repo to <CEP_HOME>/sample/artifacts/0101 (by default, the Axis2 repo is <CEP_HOME>/repository/deployment/server).

Executing the sample

  1. Log into the CEP management console which is located at https://localhost:9443/carbon.


  2. Go to Tools -> Event Simulator. Under the 'Multiple Events' section, you can see the listed 'events.csv' file which contains some sample data. Click 'play' to start sending sample events from the file.
  3. See the output events received from the CEP console. This sample uses the logger adaptor to log output events to the console.

    For example, given below is a screenshot of the output of the consumer sending events from the producer:

  • No labels