Sample 0004 - Simple Pass-through with Email & JMS
Introduction
This example demonstrates how to filter incoming event attributes and add them to a topic using simple pass-through with Email and JMS event adapters. Because we do not use any execution plan here, there is no Siddhi query.
Prerequisites
- See Prerequisites in CEP Samples Setup page.
- Copy the ActiveMQ JMS related JARs referred in JMS Transport to
<CEP_HOME>/repository/components/lib
directory. - 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
Start the ActiveMQ server before the CEP server starts.
Uncomment the mail transport receiver configuration in
<CEP_HOME>/repository/conf/axis2/axis2.xml
file to receive events from email client.<transportReceiver name="mailto" class="org.apache.axis2.transport.mail.MailTransportListener"> </transportReceiver>
Building the sample
Start the WSO2 CEP server with the sample configuration numbered 0004. For instructions, see Starting sample CEP configurations. This sample configuration does the following:
- Creates
<CEP_HOME>/repository/conf/stream-manager-config.xml
file, which is used to create the stream definitions for the sample. - Points the default Axis2 repo to
<CEP_HOME>/sample/artifacts/0004
(by default, the Axis2 repo is<CEP_HOME>/repository/deployment/server
).
Executing the sample
Open a new terminal, go to
<CEP_HOME>/samples/consumers/jms
and run the following command:ant topicConsumer -Dtopic=ServiceManagement (Since we are sending events from CEP to a topic called ServiceManagement
It builds the sample jms consumer and executes it.
Do not close this terminal. It is required to keep the server running and receiving events.
Send an event from a email client with the following information:
To Address: wso2cep.demo@gmail.com
Mail Subject: SOAPAction:urn:ServiceManagement
Mail Content: Subscribe PizzaOffers to Johan for 20 daysNote that
ServiceManagement
is the email subject mentioned in theeventbuilder
of this sample. Mail subject has to beSOAPAction:urn:ServiceManagement
. For example,
See the output events received from the CEP via the terminal opened in step 1. Shown below is a console output in the consumer terminal with events sent to CEP: