Details
-
Improvement
-
Status: Closed
-
Major
-
Resolution: Fixed
-
2.1.0
-
None
-
Linux ubuntu 2.6.24-26-generic, java 1.5.0_16, Esper 3.3.0
Description
org.apache.camel.impl.DefaultCamelContext uses HashMap to hold route services
In start() method it uses routeServices.values() to list route services.
It does not work for Esper.
Camel-extra Esper demo example for Esper, http://code.google.com/p/camel-extra/wiki/EsperDemo, creates 3 routes:
1: Route[[From[activemq:EventStreamQueue]] -> [To[esper://feed]]]
2: Route[[From[esper://feed?eql=insert into TicksPerSecond select feed, count(*) as cnt from com.iona.ps.demos.MarketDataEvent.win:time_batch(1 sec) group by feed]] -> [To[esper://feed]]]
3: Route[[From[esper://feed?eql=select feed, avg(cnt) from TicksPerSecond.win:time(10 sec) group by feed + having cnt < avg(cnt) * 0.75]] -> [To[esper://feed], process[com.iona.ps.demos.MyRouteBuilder$1@1274069]]]
3-rd route depends on 2-nd route, it uses TicksPerSecond event type that gets created in route 2.
DefaultCamelContext starts 3-rd route before 2-nd route, as a result Esper fails to resolve event type:
com.espertech.esper.epl.expression.ExprValidationException: Failed to resolve event type: Event type or class named 'TicksPerSecond' was not found
at com.espertech.esper.epl.spec.FilterStreamSpecRaw.resolveType(FilterStreamSpecRaw.java:189)
at com.espertech.esper.epl.spec.FilterStreamSpecRaw.compile(FilterStreamSpecRaw.java:99)
at com.espertech.esper.core.StatementLifecycleSvcImpl.compile(StatementLifecycleSvcImpl.java:956)
at com.espertech.esper.core.StatementLifecycleSvcImpl.createStopped(StatementLifecycleSvcImpl.java:195)
...
As a workaround, it is possible to change startup order by assigning custom ids to routes, so routeServices HashMap would return values in different order.
Please, be advise that 3-rd route's From URI: "esper://feed?eql=select feed, avg(cnt) from TicksPerSecond.win:time(10 sec) group by feed + having cnt < avg(cnt) * 0.75" is modified,
original From URI from svn:
"esper://feed?eql=select feed, avg(cnt) as avgCnt, cnt as feedCnt from TicksPerSecond.win:time(10 sec) group by feed + having cnt < avg(avgCnt) * 0.75"
It was done to resolve Esper compiling issue with avgCnt and feedCnt and has no impact on this reported Camel issue .