Introduction
This sample demonstrates how to set up an execution plan with a quartz scheduler based cron window for generating periodic alerts on build failures.
The execution plan used in this sample is as follows:
from buildStatisticsStream[isBuildFailed == true]#window.cron("0 1 * * * ? ") select project, productTeam, lastCommitter, count(timeStamp) as totalBuildFailures group by project insert into buildFailureStream;
The first query,
- Receives events through the buildStatisticsStream
- Adds events that satisfy the condition isBuildFailed == true to a cron window. The cron window is configured to output at 1 am every day using the cron notation.
- Selects the attributes project, productTeam, lastCommitter, count(timeStamp) as totalBuildFailures
- The group by clause causes the count() to be calculated per project.
- Outputs events to the buildFailureStream
Prerequisites
See Prerequisites in CEP Samples Setup page.
Building the sample
Start the WSO2 CEP server with the sample configuration numbered 0115. For instructions, see Starting sample CEP configurations. This sample configuration does the following:
- Points the default Axis2 repo to
<CEP_HOME>/sample/artifacts/0115
(by default, the Axis2 repo is<CEP_HOME>/repository/deployment/server
).
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: