Setting up CEP Samples
For information to understand the general flow of WSO2 CEP samples, see See Overview of Samples. Follow the generic setup instructions below to execute the samples.
Prerequisites
Sample | Requirements |
---|---|
All samples |
|
JMS related samples | Setting up JMS samples |
Email related sample | Setting up Email 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
By default, the <CEP_HOME>/bin/wso2server.bat
or <CEP_HOME>/bin/wso2server.sh
scripts start an instance of the CEP using the configuration files in <CEP_HOME>/repository/deployment/server
directory, which is the default Axis2 repository. Hereby, sample configurations passed in as -sn <n>
are ignored in the normal mode.
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 artifacts for sample 0101 is inside the <CEP_HOME>/samples/artifacts/0101
directory. This sample configuration points the default Axis2 repository to <CEP_HOME>/sample/artifacts/<n>
directory.
It is recommended to use WSO2 CEP in the sample mode only to run the samples, because the server has limited functionality in the sample mode. Thereby, the CEP dashboard application is not available when running CEP in the sample mode. However, if you need to use it in the sample mode, copy the <CEP_HOME>/repository/deployment/server/webapps/
and <CEP_HOME>/repository/deployment/server/jaggeryapps/
directories to the <CEP_HOME>/samples/artifacts/<SAMPLE_NUMBER>/
directory.
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 -Dtopic=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 -Dtopic=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. Given below is the format to pass arguments.
Purpose | Syntax | Example | Default |
---|---|---|---|
Specify the publishing topic for the producer client | -Dtopic=XXXX | ant -Dtopic=AllStockQuotes | AllStockQuotes |
Publish to a specific host, which is an IP address | -Dhost=XXXX | ant -Dhost=org.test.domain | localhost |
Publish to a specific port | -Dport=XXXX | ant pizzaOrderClient -Dport=9764 | 9763 |
Publish to a specific Web service | -Dservice=XXXX | ant pizzaOrderClient -Dservice=wsInAdaptorService | WSEventLocalAdaptorService |
Send events in batches (i.e., the adapter receives a batch of events) | -DbatchedEvents={true|false} | ant -DbatchedEvents=true | |
To subscribe events from a JMS topic (consumer) | -Dtopic=XXXXXX | ant topicConsumer -Dtopic=TestTopic | TestTopic |
To subscribe events from a JMS queue (consumer) | -Dqueue=XXXXX | ant queueConsumer -Dqueue=DelayedFlightStats | DelayedFlightStats |
Setting up JMS for JMS sample clients
Before you run JMS samples, set up and start a JMS provider.
CEP samples are pre-configured to use an ActiveMQ 5.7.0 JMS server, which is set up locally. You can change this to another provider by editing the input/output event-adapter configuration in <CEP_HOME>/samples/artifacts/<sample_number>/inputeventadaptor
or <CEP_HOME>/samples/artifacts/<sample_number>/outputeventadaptor
directories or follow the JMS Input/Output Event Adapter configurations.
Also, copy the relevant JMS client libraries to <CEP_HOME>/samples/lib
folder.
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
Previous Apache ActiveMQ versions may not contain SLF4J related files in the client JAR. Therefore, if you get an error, add SLF4J related JAR file to
<CEP_HOME>/samples/lib/
directory of the samples.
For WSO2 Message Broker, the relevant JAR files are,
<MB_HOME>/client-lib/ andes-client-xx.jar
<MB_HOME>/client-lib/ geronimo-j2ee-management_1.1_spec-1.0.1xx.jar
See JMS Transport to configure JMS transport for WSO2 CEP.
Setting up Mail transport sender and receiver
The Mail transport sender is enabled by default in sample configurations. Point it to a valid SMTP configuration using <CEP_HOME>/
repository/conf/axis2/axis2_client.xml
file as follows:
<transportSender name="mailto" class="org.apache.axis2.transport.mail.MailTransportSender"> <parameter name="mail.smtp.from">wso2cep.demo@gmail.com</parameter> <parameter name="mail.smtp.user">wso2cep.demo</parameter> <parameter name="mail.smtp.password">wso2cep@123</parameter> <parameter name="mail.smtp.host">smtp.gmail.com</parameter> <parameter name="mail.smtp.port">587</parameter> <parameter name="mail.smtp.starttls.enable">true</parameter> <parameter name="mail.smtp.auth">true</parameter> </transportSender>
To enable the Mail transport receiver for samples, uncomment the following in axis2.xml
file:
<transportReceiver name="mailto" class="org.apache.axis2.transport.mail.MailTransportListener"> </transportReceiver>
In Email Input Event Adapter configuration, provide correct parameters of a valid mail account.