You should load routes from XML defines in the <routes> tag, as shown here.
http://camel.apache.org/loading-routes-from-xml-files.html

Just peek in the source code on trunk to see how loadRoutesDefinition is coded.

Loading routes from <camelContext> tags is way to difficult. There is
a lot of logic to load using Spring namespace handlers, to prepare the
JAXB model and a lot other stuff.


On Fri, Jan 14, 2011 at 10:53 AM, bfischer <[email protected]> wrote:
>
> Hi Ashwin,
>
> thanks for your reply - but it seems I didn't found right words to explain
> my use case.
>
> If I understand explanations from the link you mentioned right, all this
> different scenarios are somehow "static" which means: routes are loaded
> during creation and/or starting of camel context. My test and productive
> routes are working well in this scenario.
>
> But now I try to load new and/or to re-load existing routes after camel
> context was created and is still running. It's maybe comparable with Camel's
> web console ...
>
> Loading routes from xml files after the camel contexts are already up and
> running with same content like the route inside of camel context in spring
> config worked until I used more complex stuff like "transaction".
>
> The different between loading a route during creation/starting a camel
> context (directly inside the camel context tags or with context ref makes no
> difference) or loading them from separate xml files seems to be inside that
> in first variant the route goes through "bean post processing"
> AbstractCamelContextFactoryBean.afterPropertiesSet() changing already loaded
> routes. This post processing seems to be necessary like following comment
> from this class implies (lines 309 to 314)
>
>                // do special preparation for some concepts such as 
> interceptors and
>                // policies
>                // this is needed as JAXB does not build exactly the same 
> model definition
>                // as Spring DSL would do
>                // using route builders. So we have here a little custom code 
> to fix the
>                // JAXB gaps
>
> Because this corrections don't happen for loading routes after the camel
> context already exists a "transactional routes" fail because inside
> "outputs" (an attribute of class RouteDefintion containing a list of
> ProcessorDefinition) the lsit of Processorcs seems to be wrong.
>
> In my test case loading the route from camel context in
> RouteDefinition.setOutputs() it looks like
>
> [Transacted[ref:null], To[mock:core-route01]]
>
> Later, in RouteDefinition.addRoutes(), it looks like
>
> [Transacted[ref:null]]
>
> wrapping the "mock" inside of "Transacted"
>
> Loading a similar route (except naming) if camel context is already up and
> running in RouteDefinition.setOutputs() it results in the same behavior
>
> [Transacted[ref:null], To[mock:test01-route01]]
>
> but it stay unchanged (not post processed) if it comes to
> RouteDefinition.addRoutes()
>
> [Transacted[ref:null], To[mock:test01-route01]]
>
> Method ProcessorDefinitionHelper.hasOutputs( outputs, true ) now reports a
> problem because "Transacted" wrappes or contains nothing ...
>
> I don't know how to add this post processing as additional step after
> loading from xml and before adding routes with something like
>
>    Resource rsc = new ClassPathResource( resourceName, clazz );
>    Source   src = new StreamSource     ( rsc.getInputStream() );
>    Object   obj = this.unm.unmarshal( src );
>
>     // IMO something should happen here
>
>    camelContext.addRouteDefinitions( routes.getRoutes() );
>
> Camel 2.6 I didn't use right now because company rules forbid usage of
> unreleased stuff.
>
> Hopefully I use now the forum editor a little bit better because in my
> original post some words are not shown ... I think because I did not quote
> xml tags right ..
> Sorry for inconvinience ..
>
> Any help is welcome.
>
> Greetings from Germany
>
>
> -----
> Bernd Fischer
> GK Software AG
> [email protected]
> --
> View this message in context: 
> http://camel.465427.n5.nabble.com/Loading-routes-from-XML-files-with-Camel-2-4-0-tp3340082p3341070.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>



-- 
Claus Ibsen
-----------------
FuseSource
Email: [email protected]
Web: http://fusesource.com
Twitter: davsclaus
Blog: http://davsclaus.blogspot.com/
Author of Camel in Action: http://www.manning.com/ibsen/

Reply via email to