For information on understanding the general flow of WSO2 CEP samples, see WSO2 CEP Samples. The following sections explain the generic setup instructions to execute the samples.
Prerequisites
Following applications are required for running the WSO2 CEP samples in this documentation.
Sample | Requirements |
---|---|
All samples |
|
JMS related samples | The JMS samples are explained to be tried out using following JMS providers
|
MQTT related samples | The MQTT samples are explained to be tried out using following MQTT-supported servers
|
Kafka related samples | The Kafka samples are explained to be tried out using following Kafka Broker versions
|
WebSocket related samples | Java Development Kit / JRE version 1.7.* |
Apache Storm related samples | Apache Storm version 0.9.3 or later (to run Storm samples.) |
Starting sample CEP configurations
To start the CEP with a sample configuration, run the following command with -sn <n>, where <n> denotes the number assigned to the sample.
On Linux: ./wso2cep-samples.sh -sn <n> On Windows: wso2cep-samples.bat -sn <n>
For example, to start the CEP with the configuration of sample 0101, run the following command inside <CEP_HOME>/bin
directory:
On Linux: ./wso2cep-samples.sh -sn 0101 On Windows: wso2cep-samples.bat -sn 0101
The <CEP_HOME>/samples/artifacts
directory contains the sample configurations of CEP. Each configuration is inside a sub directory by the name of the sample numbered <n>. For example, the cep artefacts for sample 0101 is inside<CEP_HOME>/samples/artifacts/0101
directory.
In the normal mode the <CEP_HOME>/bin/wso2server.bat
or <CEP_HOME>/bin/wso2server.sh
script starts an instance of the CEP using the configuration files in <CEP_HOME>/repository/deployment/server
directory and any sample configurations passed in as -sn <n>
is ignored.
These configurations on running the samples do the following:
Create
<CEP_HOME>/repository/conf/data-bridge/stream-definitions.xml
file, which is used to create the stream definitions for the sample.Point the default Axis2 repo to
<CEP_HOME>/sample/artifacts/<SAMPLE_NUMBER>/
directory. (<CEP_HOME>/repository/deployment/server/
directory is used as the default Axis2 repo.)
Starting sample consumers
Each sample consumer service is saved in a separate directory as <CEP_HOME>/samples/consumers/<consumer_name>
.
To start a sample consumer, go to its directory
<CEP_HOME>/samples/consumers/<comsumer_name>
and typeant
. For example,
user@host:/tmp/wso2cep-3.1.0/samples/consumers/wso2-event$ ant Buildfile: /home/user/tmp/wso2cep-3.1.0/samples/consumers/wso2-event/build.xml ... run:[echo] To configure host, port and events use -Dhost=xxxx -Dport=xxx -Devents=xx [echo] Sending to : http://localhost:7661 [java] Test Server starting on 10.100.0.75 [java] Thrift Server started at 10.100.0.75 [java] Thrift SSL port : 7761 [java] Thrift port : 7661 [java] Test Server Started
To write a custom wso2Event data publisher (Thrift data publisher), use the pom file given here .
Deploy the log service sample consumer, which is a Web service, by specifying the sample number as follows:
ant -DsampleNo=<sample no>
Running
DsampleNo
ant script deploys the log service in the axis2 repository that is relevant to the specified sample. After proper deployment, the Web service is able to receive messages from the CEP server.user@host:/tmp/wso2cep-3.1.0/samples/consumers/logService$ ant -DsampleNo=0102 Buildfile: /home/usre/tmp/wso2cep-3.0.0/samples/consumers/logService/build.xml -folder.check: -assign.sample: [echo] Sample No : 0102 [echo] Services Dir : ../../../samples/artifacts/0102/axis2services -assign.main: folder.set: clean: ... [jar] Building jar: /tmp/wso2cep-3.1.0/repository/deployment/server/webapps/logService.war BUILD SUCCESSFUL Total time: 0 seconds
Starting sample producers
Starting a sample producer is similar to starting a consumer.
Go to the sample producer's directory
<CEP_HOME>/samples/producers/<producer_name>
and typeant
with relevant input arguments. For example,
user@host:/home/user/wso2cep-3.1.0/samples/producers/pizza-shop$ ant pizzaOrderClient -Dservice=WSEventLocalAdaptorService -DtopicName=BatchedPizzaOrder -DbatchedEvents=true Buildfile: /home/user/tmp/wso2cep-3.1.0/samples/producers/pizza-shop/build.xml init: compile: [copy] Copying 1 file to /home/user/tmp/wso2cep-3.1.0/samples/producers/pizza-shop/temp/classes pizzaOrderClient: [echo] To configure host and port use -Dhost=xxxx -Dport=xxx -Dservice=xxx -DtopicName=xxx [echo] Sending to : http://localhost:9763/services/WSEventLocalAdaptorService/BatchedPizzaOrder [echo] To send events in batches use -DbatchedEvents=true [echo] Sending events in batches : true BUILD SUCCESSFUL Total time: 1 second
Passing arguments to sample clients
Some sample clients take extra arguments. The following table presents the format in which these arguments can be passed.
Purpose | Syntax | Example | Default |
---|---|---|---|
To specify the publishing topic for the producer client. | -DtopicName=XXXX | ant -DtopicName=AllStockQuotes | AllStockQuotes |
To publish to a specific host, which is an IP address. | -Dhost=XXXX | ant -Dhost=org.test.domain | localhost |
To publish to a specific port. | -Dport=XXXX | ant pizzaOrderClient -Dport=9764 | 9763 |
To publish to a specific Web service. | -Dservice=XXXX | ant pizzaOrderClient -Dservice=wsInAdaptorService | WSEventLocalAdaptorService |
To send events in batches (i.e., the adapter receives a batch of events). | -DbatchedEvents={true|false} | ant -DbatchedEvents=true | |
To publish events to a specific client URL. |
|
| |
To subscribe events from a JMS topic (consumer). | -DtopicName=XXXXXX | ant topicConsumer -DtopicName=TestTopic | TestTopic |
To subscribe events from a JMS queue (consumer). | -Dqueue=XXXXX | ant queueConsumer -Dqueue=DelayedFlightStats | DelayedFlightStats |
To receive events from a specific format from the text document (producer). |
| ant -Dformat=csv | |
To specify the JMS broker to which the CEP server listens. |
| ant -Dbroker=activemq | |
To publish events in a specific event stream (producer). |
| ant -DstreamId=org.wso2.event.sensor.stream:1.0.0 | |
To publish events from the specific sample folder (producer). |
| ant -Dsn=00 | |
To specify whether the protocol based on which events are received is thrift or binary. |
| ant -Dprotocol=binary | |
To specify the username when an action performed by a sample requires user credentials to be specified. |
| -Dusername=admin | |
To specify the password when an action performed by a sample requires user credentials to be specified. |
| -Dpassword=admin | |
When doing a performance test, this argument specifies the number of events with which the test should be carried out. |
| -Devents=2000000 | 10000 |
When doing a performance test, this argument specifies the delay that occurs between events in milli seconds. |
| -Ddelay=1000 | |
When doing a performance test, the this argument specifies the number of events after which the throughput/latency should be calculated. |
| -DelapsedCount=10000 | 10000 |
When doing a performance test, this argument specifies the number of publishers that should be used to publish events. |
| -DnoOfPublishers=50 | |
When doing a performance test, this argument specifies the number of events that should be sent to the event flow for the CEP server to warm up and reach a stabilize. |
| -DwarmUpCount=200000 | 10000 |
When doing a performance test, this argument is used to specify whether you want to calculate the throughput or the latency.
|
| -DcalcType=throughput | throughput |
Setting up JMS for JMS sample clients
Before you run JMS samples, set up and start a JMS provider. Configure JMS providers by copying relevant JMS client libraries to <CEP_HOME>/samples/lib
folder as mentioned below.
For Apache ActiveMQ, the relevant JAR files are,
<ActiveMQ_HOME>/activemq-all-5.7.0.jar
<ActiveMQ_HOME>/lib/
geronimo-jms_1.1_spec-1.1.1.jar
<CEP_HOME>/samples/lib/
directory of the samples.For Apache Qpid, the relevant JAR files are,
<QPID-CLIENT_HOME>/lib/geronimo-jms_1.1_spec-1.1.1.jar
<QPID-CLIENT_HOME>/lib/qpid-client-0.32.jar
<QPID-CLIENT_HOME>/lib/qpid-common-0.32.jar
For WSO2 Message Broker (MB) , the relevant JAR files are,
<MB_HOME>/client-lib/andes-client-2.6.1.jar
<MB_HOME>/client-lib/log4j-1.2.13.jar
<MB_HOME>/client-lib/slf4j-1.5.10.wso2v1.jar
<MB_HOME>/client-lib/geronimo-jms_1.1_spec-1.1.0.wso2v1.jar
<MB_HOME>/client-lib/org.wso2.securevault-1.0.0-wso2v2.jar
Setting up MQTT for MQTT sample clients
Before you run MQTT samples, set up and start a MQTT-supported server. Configure MQTT sample clients by copying relevant MQTT client libraries to <CEP_HOME>/samples/lib
folder as mentioned below.
- Download and add MQTT client library (
mqtt-client-0.4.0.jar
) to <CEP_HOME>/samples/lib directory.
Setting up Kafka for Kafka sample clients
Before you run Kafka samples, set up and start a Kafka broker. Configure Kafka sample clients by copying relevant Kafka client libraries to <CEP_HOME>/samples/lib
folder as mentioned below.
- Copy all the JAR files, which are located in
<KAFKA_HOME>/libs/
directory to<CEP_HOME>/samples/lib/
directory.