Introduction
This sample demonstrates how to set up an execution plan with simple filter. It checks for delayed flight arrival and add the specific related flight event to the stream called delayedFlightStream.
The query used in this sample is as follows:
from flightStatsStream[status != 'On-Time'] select flightName, flightId, flightType, arrivalTime, trackNo insert into delayedFlightStream
This sample has used jms queues for the processing.
Prerequisites
For a list of prerequisites, please refer to the prerequisites section in Setting up CEP Samples.
- Need to add necessary ActiveMQ jms related jars to the <CEP_HOME>/repository/components/lib directory of the CEP server (Please refer this ). Start the ActiveMQ server before CEP server starts.
- For Active MQ, copy the following JARs from ActiveMQ distribution directory to <CEP_HOME>/samples/lib directory:
<ActiveMQ_HOME>/activemq-all-5.7.0.jar
<ActiveMQ_HOME>/lib/ geronimo-jms_1.1_spec-1.1.1.jar Need to add apache axiom.jar also to the <CEP_HOME>/samples/lib directory (To send xml event types). You can use this axiom jar.
Building the Sample
- Start the WSO2 CEP server with the sample number as ./wso2cep-samples.sh -sn 0103 (or on Windows, wso2cep-samples.bat -sn 0103). This will start up the server with the configuration files required for this sample.
Here when executing the sample with above command, there are some operations done in the background. There is a file called "stream-manager-config.xml" copied to the <CEP_HOME>/repository/conf from the artifacts directory of the sample. This file will be used in the server startup to create the stream definitions to run the sample.
Then, default Axis2 repo will be pointed to the directory <CEP_HOME>/sample/artifacts/0103 (by default Axis2 repo is <CEP_HOME>/repository/deployment/server). There will be limited functionality in sample server startup mode, so don't perform other tasks in the server when it is start-up in the sample mode.
Executing the Sample
Open another terminal and switch to <CEP_HOME>/samples/consumers/jms and run the below command. This will build the sample jms consumer and execute it. Do not close this terminal as it is required to keep the server running in order to receive events and view them.
ant queueConsumer -Dqueue=DelayedFlightStats (Since we are sending events from CEP to a topic called DelayedFlightStats
From another terminal switch to <CEP_HOME>/samples/producers/flight-stats/ and run ant from there. This will build and run the jms producer which will send some flight stats data to the CEP server. From this terminal, you will be able to view the details of the events sent.
Note
To configure queue use -Dqueue=xxxx
For example : ant -Dqueue=FlightStats
Once the step 2 is done successfully, you will be able to see the output events received from the CEP via the terminal opened in step 1.
Below is the console output in the CEP server when events are received after processing.