[
https://issues.apache.org/activemq/browse/CAMEL-919?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Claus Ibsen resolved CAMEL-919.
-------------------------------
Resolution: Won't Fix
Currently Camel doesn't properly support removing existing routes and adding
new dynamically. This is scheduled for Camel 2.x.
You should use the camelContext.addRoutes(routeList) to add you new routes to
an existing context.
At present time we can not add a fix for this as it will break to much at
current time.
> RouteBuilder.getRoutes does not return routes
> ---------------------------------------------
>
> Key: CAMEL-919
> URL: https://issues.apache.org/activemq/browse/CAMEL-919
> Project: Apache Camel
> Issue Type: Bug
> Components: camel-core
> Affects Versions: 1.4.0
> Reporter: Atle Prange
> Assignee: Claus Ibsen
>
> Suspected reason:
> Looking at the code reveals that the initalization of the routebuilder
> actually sets the routes in the injected CamelContext, but does not populate
> the local list of routes.
> Consequence:
> One is not able to replace routes in the CamelContext by fetching routes from
> routebuilders, and then set the list of routes in the camel context.
> {code}
> List<Routes> routeList = new ArrayList();
> //Some method fetching all my builders
> List<Routes> routesList = getRouteBuilders();
> //Build a list of all routes, thereby updating my camel context with fresh
> routes...
> for(Routes routes:routesList){
> //Fetches an empty list, but the builder now sets the route in the context
> List<Route> routeListFromBuilder = routes.getRouteList();
> //I am now adding an empty list to my list of routes
> routeList.addAll( routeListFromBuilder );
> }
> //Sets an empty list into the context, thereby clearing all routes
> camleContext.setRoutes( routeList );
> {code}
> Possible solution:
> in RouteBuilder replace:
> {code}
> protected void populateRoutes(List<Route> routes) throws Exception {
> CamelContext camelContext = getContext();
> if (camelContext == null) {
> throw new IllegalArgumentException("No CamelContext has been
> injected!");
> }
> routeCollection.setCamelContext(camelContext);
> camelContext.addRouteDefinitions(routeCollection.getRoutes());
> }
> {code}
> with
> {code}
> protected void populateRoutes(List<Route> routes) throws Exception {
> CamelContext camelContext = getContext();
> if (camelContext == null) {
> throw new IllegalArgumentException("No CamelContext has been
> injected!");
> }
> routeCollection.setCamelContext(camelContext);
> routes.addAll(routeCollection.getRoutes());
> }
> {code}
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.