[
https://issues.apache.org/activemq/browse/CAMEL-2398?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=57114#action_57114
]
Kostyantyn Oliynyk commented on CAMEL-2398:
-------------------------------------------
I did.
It is possible to assign startup order to route but DefaultCamelContext will
use it to start inputs, i.e. consumers but not the route services.
That is why this issue has name: "DefaultCamelContext starts ROUTE SERVICES out
of order".
This is source code from org.apache.camel.impl.DefaultCamelContext:
This is how routeServices defined, line 139:
...
private final Map<String, RouteService> routeServices = new HashMap<String,
RouteService>();
...
This is how route service get started, from line 895:
...
// figure out the order in which the routes should be started
for (RouteService routeService : routeServices.values()) {
Boolean autoStart =
routeService.getRouteDefinition().isAutoStartup();
if (autoStart == null || autoStart) {
// defer starting inputs till later as we want to prepare
the routes by starting
// all their processors and child services etc.
// then later we open the floods to Camel by starting the
inputs
// what this does is to ensure Camel is more robust on
starting routes as all routes
// will then be prepared in time before we start inputs
which will consume messages to be routed
routeService.startInputs(false);
try {
See ----> routeService.start();
// add the inputs from this route service to the list
to start afterwards
// should be ordered according to the startup number
Integer startupOrder =
routeService.getRouteDefinition().getStartupOrder();
if (startupOrder == null) {
// auto assign a default startup order
startupOrder = defaultRouteStartupOrder++;
}
...
> DefaultCamelContext starts route services out of order
> -------------------------------------------------------
>
> Key: CAMEL-2398
> URL: https://issues.apache.org/activemq/browse/CAMEL-2398
> Project: Apache Camel
> Issue Type: Improvement
> Components: camel-core
> Affects Versions: 2.1.0
> Environment: Linux ubuntu 2.6.24-26-generic, java 1.5.0_16, Esper
> 3.3.0
> Reporter: Kostyantyn Oliynyk
>
> 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.myroutebuilde...@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 .
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.