This sample demonstrates how to set up an execution plan to filter out credit card transactions that makes use of an in-memory event table to identify blacklisted transactions. 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:
Given above is the table definition,
- Defines a table named CardUserTable with the given attributes. This is by default an in-memory table.
The first query,
- Processes the events received through the CardUserStream
- Selects all the attributes under the
selectclause, 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
selectclause, 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,
- Defines a length window that keeps 1 event of the input stream PurchaseStream.
- Joins it with the CardUserTable with the condition p.cardNo == c.cardNum and c.blacklisted == false. In this condition, the events with blacklisted == true in the table gets filtered out and then the remaining events will be joined based on the card number.
- Emits those events as output events through the TransformedRoomTempStream.
The last query is used to clean up the table from an external trigger event through DeleteAllUsers stream,
- It processes the events received through the DeleteAllUsers.
- Checks for the condition deleteAll == true and if it's true, deletes all the records in the CardUserTable.
See Prerequisites in CEP Samples Setup page.
Building the sample
Start the WSO2 CEP server with the sample configuration numbered 0106. For instructions, see Starting sample CEP configurations. This sample configuration does the following:
- Points the default Axis2 repo to
<CEP_HOME>/sample/artifacts/0106(by default, the Axis2 repo is
Executing the sample
Log into the CEP management console which is located at https://localhost:9443/carbon.
- 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.
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: