Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Excerpt
hiddentrue

CEP sample which analyzes stock quotes and outputs the last 10min average, sum of all stock quotes

...

Run WSO2 CEP. Refer to the Running Installing the Product for instructions .

Create JMS Broker

...

Start CEP Server and log in as admin.  Refer to the  Running Installing the Product for instructions.


  Step 2 :

...

No Format
 Topic(topic which filtered event published) : AllStockStats

 BrokerName (Broker to be used)              : activemqJmsBroker

 Output Mapping : XML Mapping 

 XML Mapping Text:  <quotedata:StockQuoteDataEvent xmlns:quotedata="http://ws.cdyne.com/">
			<quotedata:StockSymbol>{symbol}</quotedata:StockSymbol>
			<quotedata:price>{price}</quotedata:price>
			<quotedata:averagePrice>{averagePrice}</quotedata:averagePrice>
			<quotedata:sumPrice>{sumPrice}</quotedata:sumPrice>
                    </quotedata:StockQuoteDataEvent>


Note
After filling all the required fields of the Query , click on add query button to add Query to the bucket. Once you clicked it will disappear the query form and added query will be appeared in Queries table. 
Note
As the last step of adding a bucket , click on save button. Once you clicked it will redirect to the deployed buckets page and deployed bucket will be appeared in buckets table. Further to check whether you have entered the details correctly you can click on the link with the defined bucket and it will show added details. You can come back to the previous adding bucket page by clicking on the back button provided or if needed to edit the bucket you can click on the "Edit" link on the top of the View bucket Page.

...

  JMS ActiveMQ Broker is used in this sample to publish and subscribe events.  

  To create the JMS Publisher, it is necessary to have following classes and property files in your project.    

  • JNDI Properties
  • JNDIContext.java
  • AllStockQuotesPublisher.java

    jndi.properties    

Code Block
 java.naming.factory.initial = org.apache.activemq.jndi.ActiveMQInitialContextFactory
#java.naming.factory.initial =org.apache.qpid.jndi.PropertiesFileInitialContextFactory

#use the following property to configure the default connector
#connectionfactory.ConnectionFactory=amqp://admin:admin@clientid/carbon?brokerlist='tcp://localhost:5673'

# use the following property to specify the JNDI name the connection factory
# should appear as.
#connectionFactoryNames = connectionFactory, queueConnectionFactory, topicConnectionFactory 

...