camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Claus Ibsen <claus.ib...@gmail.com>
Subject Re: Loading routes from XML files with Camel 2.4.0
Date Fri, 14 Jan 2011 14:23:05 GMT
Hi

Yeah I think the loading of routes XML files lack a step where it
merges stuff from its parent CamelContext such as transacted error
handlers and whatnot. I will have to move some logic from
camel-core-xml into camel-core to have it unified in one place and
reusable by spring, blueprint and from 3rd party like you using the
API from CamelContext.

I will see if I got time to work on this before 2.6 is being cut next week.


On Fri, Jan 14, 2011 at 3:17 PM, bfischer <bfischer@gk-software.com> wrote:
>
> Hi Claus,
>
> thank for spending your time with my problem ...
>
> I followed your advice and tested the behavior on Camel 2.6.0 latest
> snapshot after extracting it out of our internal projects. But behavior
> stays unchanged.
>
> And of course I'm loading loading routes from a separate xml file inside of
> <routes> tags ... Maybe it would be better to describe it a little in coding
> style ...
>
> I'm using Spring to "boot" Camel. So I have a spring-config.xml containing
> following camleContext
>
>  <camelContext id ="camel-core" xmlns
> ="http://camel.apache.org/schema/spring">
>    <route id="core-route01">
>      <from uri="direct:core-route01"/>
>      <transacted/>
>      <to   uri="mock:core-route01"/>
>    </route>
>  </camelContext>
>
> Of course all the stuff to make <transacted/> working are present too and
> only let out to shorting this post.
> In my testcase I verify that this route is loaded and working
>
>    Assert.assertNotNull( this.context.getRoute( "core-route01" ) );
>    Assert.assertEquals ( 1, this.context.getRoutes().size() );
>    [....]
>
> Works fine.
>
> Now I'm loading new route from xml file (routeContext-test01.xml)
>
>  <routes xmlns="http://camel.apache.org/schema/spring">
>    <route id="test01-route01">
>      <from uri="direct:test01-route01"/>
>      <to   uri="mock:test01-route01"/>
>    </route>
>  </routes>
>
> with following code
>
>    Resource rs = new ClassPathResource( "routeContext-test01.xml",
> this.getClass() );
>    RoutesDefinition routes = this.context.loadRoutesDefinition(
> rs.getInputStream() );
>    this.context.addRouteDefinitions( routes.getRoutes() );
>
> and verifying it again (I don't repeat the code).
>
> Works fine.
>
> Now I'm going to load next xml file (routeContext-test02.xml)
>
> <routes xmlns="http://camel.apache.org/schema/spring">
>  <route id="test02-route01">
>    <from uri="direct:test02-route01"/>
>    <transacted/>
>    <to   uri="mock:test02-route01"/>
>  </route>
> </routes>
>
> Only difference to test01 is added <transacted/> tag. And it should be
> basically same like the one in camelContext. Of course naming is a little
> bit different too but I hope this wouldn't be reason ...
>
> Loading it with code snippet shown above now leads to an exception
>
> org.apache.camel.FailedToCreateRouteException: Failed to create route
> test02-route01 at: >>> From[direct:test02-route01] <<< in route:
> Route[[From[direct:test02-route01]] -> [Transacted[ref:null]... because of
> Route test02-route01 has no output processors. You need to add outputs to
> the route such as to("log:foo").
>        at
> org.apache.camel.model.RouteDefinition.addRoutes(RouteDefinition.java:764)
>        at
> org.apache.camel.model.RouteDefinition.addRoutes(RouteDefinition.java:174)
>        at
> org.apache.camel.impl.DefaultCamelContext.startRoute(DefaultCamelContext.java:698)
>        at
> org.apache.camel.impl.DefaultCamelContext.startRouteDefinitions(DefaultCamelContext.java:1603)
>        at
> org.apache.camel.impl.DefaultCamelContext.addRouteDefinitions(DefaultCamelContext.java:649)
>        at
> com.gk_software.camel.testRouteLoading.TestCase.test01(TestCase.java:104)
>        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>        at
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
>        at
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
>        at java.lang.reflect.Method.invoke(Method.java:592)
>        at
> org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:44)
>        at
> org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
>        at
> org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:41)
>        at
> org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20)
>        at
> org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:28)
>        at
> org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:31)
>        at
> org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:76)
>        at
> org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50)
>        at org.junit.runners.ParentRunner$3.run(ParentRunner.java:193)
>        at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:52)
>        at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:191)
>        at org.junit.runners.ParentRunner.access$000(ParentRunner.java:42)
>        at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:184)
>        at org.junit.runners.ParentRunner.run(ParentRunner.java:236)
>        at
> org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:49)
>        at
> org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
>        at
> org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
>        at
> org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
>        at
> org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
>        at
> org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)
> Caused by: java.lang.IllegalArgumentException: Route test02-route01 has no
> output processors. You need to add outputs to the route such as
> to("log:foo").
>        at
> org.apache.camel.model.RouteDefinition.addRoutes(RouteDefinition.java:762)
>        ... 29 more
>
> Reason why a route described (to avoid the word "loading") in camelContext
> behaves different than a route loaded from <routes> tags are in my opinion
> the post processing happening in
> AbstractCamelContextFactoryBean.afterPropertiesSet().
>
> Maybe this bavior is wanted, I don't know. If full "power" of spring dsl for
> routes is useable only if they are processed during startup of camelContext
> ...
>
> For now it seems real reloading can be done only by restarting complete
> camelContext ...
>
> Still I haven't any idea how do go around - reloading of routes is a needed
> key feature for us ...
>
>
> -----
> Bernd Fischer
> GK Software AG
> bfischer@gk-software.com
> --
> View this message in context: http://camel.465427.n5.nabble.com/Loading-routes-from-XML-files-with-Camel-2-4-0-tp3340082p3341319.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>



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

Mime
View raw message