[Tutorial] A Step-by-Step Guide on How to Run CEP Fleet Management Samples
- Awanthika Senarath
- Software Engineer - WSO2
Co-author of this tutorial
Yassasri Ratnayake
Table of contents
- Prerequisites
- Configuring the CEP to run the samples
- Running the samples
- Sample 01
- Sample 02
- Sample 03
Prerequisites
- WSO2 CEP (Version 3.1.0)
- ActiveMQ 5.9.0
- Configure CEP to use JMS transport (refer https://docs.wso2.com/display/CEP310/Setting+up+CEP+Samples)
- Download the zip file attached here
Configuring the CEP to run the samples
Unzip the content and follow the below steps;
- Copy the three sample folders 1002, 1003 and 1004 to CEP_HOME/samples/artifacts
- Copy the GPS_Stream_Consumer in the consumer folder to CEP_HOME/samples/consumers
- Copy the DataAgent in the producer folder to CEP_HOME/samples/producers
- Copy the two siddhi extension jars in the customextensions folder to CEP_HOME/repository/components/lib and also update the /CEP_HOME/repository/conf/siddhi/siddhi.extension file by adding the following content;
customtransformer.WithinBufferTransformer
customextension.GeoProximity - Copy the Jars in the lib folder to the CEP_HOME/samples/lib directory
Now the CEP is configured to run the CEP Fleet Management samples.
Running the samples
Sample 01: Speed AlertThis sample will demonstrate a speed alert scenario. If a device exceeds a predefined speed threshold an alert will be generated and it will be shown in the console as shown below;
Figure 1.0
Follow the below steps to run the sample;
- Start the CEP with the following command to run it with sample 1002
./wso2cep-samples.sh -sn 1002
This demonstrates the high speed alarm triggering in fleet management (make sure your ActiveMQ is running in the default port) - Move to the CEP_HOME/samples/consumers/GPS_Stream_Consumer and run ant.
This starts the message consumer for CEP which pulls the data from activemq and pushes it to the socket server. - Open the URL https://localhost:9763/CEP_DeviceTracking_Sample/
On the ‘Admin Panel’ go to ‘Enable Alerts’ and enable the ‘Speed Alert’ as shown in Figure 1.1
Figure 1.1
Note: If the ‘Focus on Device’ option is enabled the focus will be maintained on a specific device which will demonstrate the scenario. Deselect this option to freely move along the MAP console.
- Run the producer to generate the data stream for the CEP. Move to CEP_HOME/samples/producers/DataAgent and run ant
Ensure that ActiveMQJMSAdaptor is activated in the CEP before running the producer.
Go to your browser and tick the relevant options and observe the different vehicles moving. When a vehicle’s speed exceeds 5 km/h the speed alarm will be triggered. This is shown in Figure 1.0.
Sample 02: Stationery Alert
This sample will demonstrate a stationary alert scenario. If a device stays within a predefined buffer-zone stationed for a predefined period of time an alert will be generated and it will be displayed in the console as shown below;
Figure 2.0
- Start the CEP with the following command to run it with sample 1003
./wso2cep-samples.sh -sn 1003
This demonstrates the stationary alarm triggering in fleet management (make sure your ActiveMQ is running in the default port) - Move to the CEP_HOME/samples/consumers/GPS_Stream_Consumer and run ant
- Open the URL https://localhost:9763/CEP_DeviceTracking_Sample/
On the ‘Admin Panel’ go to ‘Enable Alerts’ and enable the ‘Stationary Alert’ as shown in Figure 2.1
Figure 2.1
Note: If the ‘Focus on Device’ option is enabled the focus will be maintained on a specific device which will demonstrate the scenario. Deselect this option to freely move along the MAP console.
- Run the producer to generate the data stream for the CEP. Move to CEP_HOME/samples/producers/DataAgent and run ant
Ensure that ActiveMQJMSAdaptor is activated in CEP before running the producer.
Go to your browser and tick the relevant options and observe the different vehicles moving. When a vehicle reached the predefined buffer point the stationary alarm will be triggered.This is because the time period for which the stationary condition is checked is set to 0.01 seconds. It is possible to increase the time period and observe that the alarm is triggered only if the device remains stationary for that period. Changes need to be done in the execution plan.
Sample 03 : Proximity AlertThis sample will demonstrate a proximity alert scenario. If two devices move in close proximity for more than a predefined time period an alert will be generated as shown below;
Figure 3.0
- Start the CEP with the following command to run it with sample 1004
./wso2cep-samples.sh -sn 1004e
This demonstrates the proximity alarm triggering in fleet management (make sure your ActiveMQ is running in the default port) - Move to the CEP_HOME/samples/consumers/GPS_Stream_Consumer and run ant. This starts the message consumer for CEP which would pull the data from activemq and push it to the socket server
- Open the URL https://localhost:9763/CEP_DeviceTracking_Sample/
On the ‘Admin Panel’ and go to ‘Enable Alerts’ and enable the ‘Proximity Alert’ as shown below;
Figure 3.1
Note: If the ‘Focus on Device’ option is enabled the focus will be maintained on a specific device which will demonstrate the scenario, Untick this option to freely move along the MAP console.
- Run the producer to generate the data stream for the CEP. Move to CEP_HOME/samples/producers/DataAgent and run ant
Ensure that ActiveMQJMSAdaptor is activated in the CEP before running the producer.
Go to your browser and tick the relevant options and observe the different vehicles moving and triggering the proximity alarm when any two devices move in close proximity than 20 meters for over 4 seconds.
Note: All the samples are configured and developed to run on default CEP configurations when started on localhost and on the default port. If the address endpoints need to be changed they have to be done in a code level.
UI Guide
Figure 4.0
- Display Settings
- Enable Alerts
- Advance Options
- Guides
- Map Options
- Device Detail Console
- Connected Device Output Console
- Stream Output Console
- Alerted Vehicle Output console
- Map Console
To view a more detailed guide on the UI go the sample guide menu in the UI console and open the UI Guide as shown below;
Figure 4.1