camel-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Kostyantyn Oliynyk (JIRA)" <>
Subject [jira] Commented: (CAMEL-2398) DefaultCamelContext starts route services out of order
Date Mon, 25 Jan 2010 21:26:32 GMT


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
                    // 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
                    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:
>             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,,
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 sec) group by feed]] -> [To[esper://feed]]]
> 3: Route[[From[esper://feed?eql=select feed, avg(cnt) from
sec) group by feed + having cnt < avg(cnt) * 0.75]] -> [To[esper://feed], process[$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(
> 	at com.espertech.esper.epl.spec.FilterStreamSpecRaw.compile(
> 	at com.espertech.esper.core.StatementLifecycleSvcImpl.compile(
> 	at com.espertech.esper.core.StatementLifecycleSvcImpl.createStopped(
>         ... 
> 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 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
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.

View raw message