esper examples

alexb's picture

Hello,

I am trying to get a simple esper example working.

Copy and pasting the example from the webinar does not work

http://wso2.org/files/wso2-esb-webinar-cep-july-29th.pdf

2008-08-12 21:41:44,921 [] [WrapperSimpleAppMain] ERROR AxiomMediator An error occured while setting EPL statement Failed to resolve event type: Failed to load class Ticker [select * from Ticker.win:length_batch(10)]

Thanks

Alex

asankaa's picture

Esper Example

Hi Alex, I did try to recreate your problem but couldn't, it is working on my environment. Can you please use the attached Synapse config file (synapse.xml) and send us the result. Thx Asanka A.     <definitions xmlns="http://ws.apache.org/ns/synapse"> <task class="org.apache.synapse.startup.tasks.MessageInjector" name="Tick"> <property name="to" value="urn:tick" /> <property name="soapAction" value="urn:tick" /> <property name="message"> <tick xmlns="http://mycom.com/ns/tick"> <s>IBM</s> <p>89.6</p> </tick> </property> <trigger interval="1" /> </task> <filter source="get-property('To')" regex="urn:tick"> <log level="custom"> <property name="Incomming msg" expression="get-property('To')" /> </log> <class name="org.sciflex.plugins.synapse.esper.mediators.AxiomMediator"> <property name="Configuration"> <esper-configuration> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://www.espertech.com/schema/esper" xsi:noNamespaceSchemaLocation="esper-configuration-2-0.xsd"> <plugin-event-representation uri="type://xml/apacheaxiom/OMNode" class-name="com.espertech.esperio.representation.axiom.AxiomEventRepresentation" /> <plugin-event-type alias="Ticker"> <resolution-uri value="type://xml/apacheaxiom/OMNode" /> <initializer> <xml-axiom root-element-name="getQuote" default-namespace="http://mycom.com/ns/tick"> <namespace-prefix prefix="t" namespace="http://mycom.com/ns/tick" /> <xpath-property property-name="symbol" xpath="//t:tick/t:s" type="string" /> <xpath-property property-name="price" xpath="//t:tick/t:p" type="number" /> </xml-axiom> </initializer> </plugin-event-type> </esper-configuration> </property> <property name="statement" value="select * from Ticker.win:length_batch(10)" /> <property name="EventToAddress" value="urn:newevent" /> </class> <log level="custom"> <property name="Modified" expression="get-property('To')" /> </log> <log level="full" /> </filter> <filter source="get-property('To')" regex="urn:newevent"> <log level="full" /> </filter> </definitions> My environment as follows JDK 1.5 Synapse-SNAPSHOT from svn trunk Esper 2.1.0
alexb's picture

Hi,

Hi, Thanks for your swift reply and assistance. I am running wso2esb-1.7 java 1.6.0_05 esper 2.1.0 plus other required jars I don't get the class not found exception anymore but I am not getting any messages through to the newevent filter. I changed the following: <xml-axiom root-element-name="getQuote" to: <xml-axiom root-element-name="tick" And it works in terms of firing newevents and getting a newevent only once every 10 tick events. Can you confirm what I have done is correct? Thanks, Alex
asankaa's picture

Esper Exple to print the 10th Event

Hi Alex, Yes, to only print the 10th event the change you have done is correct. I have attached the updated configuration file synapse.xml. Thx Asanka A. <definitions xmlns="http://ws.apache.org/ns/synapse"> <task class="org.apache.synapse.startup.tasks.MessageInjector" name="Tick"> <property name="to" value="urn:tick" /> <property name="soapAction" value="urn:tick" /> <property name="message"> <tick xmlns="http://mycom.com/ns/tick"> <s>IBM</s> <p>89.6</p> </tick> </property> <trigger interval="1" /> </task> <filter source="get-property('To')" regex="urn:tick"> <log level="custom"> <property name="Incomming msg" expression="get-property('To')" /> </log> <class name="org.sciflex.plugins.synapse.esper.mediators.AxiomMediator"> <property name="Configuration"> <esper-configuration> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://www.espertech.com/schema/esper" xsi:noNamespaceSchemaLocation="esper-configuration-2-0.xsd"> <plugin-event-representation uri="type://xml/apacheaxiom/OMNode" class-name="com.espertech.esperio.representation.axiom.AxiomEventRepresentation" /> <plugin-event-type alias="Ticker"> <resolution-uri value="type://xml/apacheaxiom/OMNode" /> <initializer> <xml-axiom root-element-name="tick" default-namespace="http://mycom.com/ns/tick"> <namespace-prefix prefix="t" namespace="http://mycom.com/ns/tick" /> <xpath-property property-name="symbol" xpath="//t:tick/t:s" type="string" /> <xpath-property property-name="price" xpath="//t:tick/t:p" type="number" /> </xml-axiom> </initializer> </plugin-event-type> </esper-configuration> </property> <property name="statement" value="select * from Ticker.win:length_batch(10)" /> <property name="EventToAddress" value="urn:newevent" /> </class> <log level="custom"> <property name="Modified" expression="get-property('To')" /> </log> </filter> <filter source="get-property('To')" regex="urn:newevent"> <log level="full" /> </filter> </definitions> You should get a output on each 10 event as follows.   2008-08-15 22:31:31,283 [127.0.1.1-asankaa-laptop] [SimpleThreadPoolWorker-4] INFO LogMediator Modified = urn:tick 2008-08-15 22:31:32,280 [127.0.1.1-asankaa-laptop] [SimpleThreadPoolWorker-5] INFO LogMediator Incomming msg = urn:tick 2008-08-15 22:31:32,290 [127.0.1.1-asankaa-laptop] [SimpleThreadPoolWorker-5] INFO LogMediator To: urn:newevent, MessageID: urn:uuid:45C3D20F4A4336D7881218819692289821022-708896568, Direction: request, Envelope:<?xml version='1.0' encoding='utf-8'?> <soapenv:envelope xmlns:soapenv="http://www.w3.org/2003/05/soap-envelope"> <soapenv:body> <tick xmlns="http://mycom.com/ns/tick"> <br> <s>IBM</s> <br> </tick> </soapenv:body> </soapenv:envelope> <p>89.6</p> 2008-08-15 22:31:32,291 [127.0.1.1-asankaa-laptop] [SimpleThreadPoolWorker-5] INFO LogMediator Modified = urn:tick
otijhuis's picture

Few problems that can occur

Hi, I've been trying the esper example as well and ran into a few problems (using wso2esb-1.7.1, esper 2.3.0 and the esper mediator as mentioned in the presentation): 1) NoSuchFieldError: ruleMemo This occurs when you use the latest 3.1 version of the antlr runtime instead of version 3.0. Just download version 3.0.1 and use that one. 2) WSO2 changes the order of the configuration when you update it through the web interface This one took a while to figure out. In the case of the esper mediator the statement tag needs to be AFTER the configuration tag. Otherwise it will use a default configuration and won't recognize the event type. If you update the xml through the web interface it will place the statement tag before the configuration tag no matter what you do. The mediator shouldn't depend on the order but it does. Hope this helps :) Regards, Okke T.
library project main code
Learn Cloud
Learn
Cloud

The WSO2 Application Server is a reliable application server that can host your enterprise web applications. The WSO2 Application Server as a Service is offered in StratosLive, the WSO2 Platform as a Service. This article explains how a simple web application can be developed and deployed from Carbon Studio to the WSO2 Application Server...

Latest Webinar
Different groups within an organization need to monitor different Key Performance Indicators (KPIs) - An operations team will be interested in the response times of business services and loads of each service,..
Thursday, February 9th 2012, 09.00 AM (PST)

Thursday, February 9th 2012, 10.00 AM (GMT)