com.atlassian.confluence.content.render.xhtml.migration.exceptions.UnknownMacroMigrationException: The macro 'next_previous_links' is unknown.

Sample 0102 - Twitter & Stock-Quote Analyzer

Introduction

This sample demonstrates how to set up an execution plan with two siddhi queries that monitor the stock exchange. It checks whether the last traded price of the stock has changed by 2% within the last minute, and who tweet about a company within the last minute.

The query used in this sample is as follows:

from AllStockQuotes#window.time(1 min)
select symbol,price, avg(price) as averagePrice 
group by symbol 
having ((price > averagePrice*1.02) or (averagePrice*0.98 > price ))
insert into FastMovingStockQuotes;
	
from TwitterFeed#window.time(1 min)
select company as company, sum(wordCount) as words 
group by company having (words > 10) 
insert into HighFrequentTweets;
	
from FastMovingStockQuotes#window.time(1 min) as fastMovingStockQuotes
join HighFrequentTweets#window.time(1 min) as highFrequentTweets on fastMovingStockQuotes.symbol==highFrequentTweets.company
select fastMovingStockQuotes.symbol as company, fastMovingStockQuotes.averagePrice as amount, highFrequentTweets.words as words 
insert into PredictedStockQuotes;
  

It has two incoming streams:

  • Event stream of Stock Quotes from a stock exchange
  • Event stream of word counts of various company names taken from Twitter pages

Prerequisites

  1. See Prerequisites in CEP Samples Setup page.
  2. Copy the ActiveMQ JMS related JARs referred in JMS Transport to <CEP_HOME>/repository/components/lib directory.
  3. 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.

Building the sample

Start the WSO2 CEP server with the sample configuration numbered 0102. For instructions, see Starting sample CEP configurations. This sample configuration does the following:

  • Creates <CEP_HOME>/repository/conf/data-bridge/stream-definitions.xml file, which is used to create the stream definitions for the sample.
  • Points the default Axis2 repo to <CEP_HOME>/sample/artifacts/0102 (by default, the Axis2 repo is <CEP_HOME>/repository/deployment/server).

Executing the sample

  1. Open a terminal, go to <CEP_HOME>/samples/consumers/generic-log-service and run the command below:

    ant -DsampleNo=0102

    It builds the sample log service and deploys it in the webapps repository that is relevant to the specified sample. The Web service is now able to receive messages sent from the CEP server.

  2. See the logs in CEP server when GenericLogService.war is deploying.

  3. Open another terminal, go to <CEP_HOME>/samples/producers/twitter-feed and run ant from there. It builds and runs the Wso2Event producer, which sends twitter feed data to the CEP server.

  4. From this terminal, see the details of the events sent.

    Note

    To configure host, port, username, password and number of events, use -Dhost=xxxx -Dport=xxxx -Dusername=xxxx -Dpassword=xxxx -Devents=xx

    For example : ant

  5. Open another terminal, go to <CEP_HOME>/samples/producers/stock-quote and run ant -Devents=7 from there.

    It builds and runs the jms producer, which sends sample stock quotes to the CEP server.

  6. From the terminal opened in the above step, see the details of the events sent. For example,

  7. Also see the console output in the CEP server, when events are received after processing. For example,

com.atlassian.confluence.content.render.xhtml.migration.exceptions.UnknownMacroMigrationException: The macro 'next_previous_links2' is unknown.