login button

esper examples

Forums :

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

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

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

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

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

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.