You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by bfischer <bf...@gk-software.com> on 2011/01/13 17:42:31 UTC

Loading routes from XML files with Camel 2.4.0

Hi all,

first let me mention that Camel is a very good pice of software.

Right now I'm trying to (re-)load routes like explained 
http://svn.apache.org/viewvc?view=revision&revision=1040085
jaxb-integration-test . Basics are working - but adding a bit more complex
route features like  the things went odd. BTW, some route works if I load
them from a "normal" Camel context (Spring based).

After looking around and debugging I found that loading from a normal Spring
based Camel context and from such external route definition xml file (like
explained behind the link above) leads to different values in the field
"outputs" of class RouteDefinition which causes the validation of this
"outputs" in ProcessorDefinition.hasOutputs() to fail in the second
scenario.

Reason seems to me that during loading a route from Spring based camel
context the routes are somehow preprocessed or corrected during
CamelContextFactoryBean.afterPropertiesSet() (see comment at lines 309ff in
this class). In contrast this preprocessing doesn't happen for the other
loading scenario.
Unfortunately I can't figure out how to solve or go around it. Instead I
have to ask if someone can give me some hints how to load such routes from
"external" files.

TIA
-- 
View this message in context: http://camel.465427.n5.nabble.com/Loading-routes-from-XML-files-with-Camel-2-4-0-tp3340082p3340082.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Loading routes from XML files with Camel 2.4.0

Posted by Claus Ibsen <cl...@gmail.com>.
Hi

Camel 2.6 has a new method on CamelContext to load routes from XML files
http://camel.apache.org/loading-routes-from-xml-files.html



On Thu, Jan 13, 2011 at 5:42 PM, bfischer <bf...@gk-software.com> wrote:
>
> Hi all,
>
> first let me mention that Camel is a very good pice of software.
>
> Right now I'm trying to (re-)load routes like explained
> http://svn.apache.org/viewvc?view=revision&revision=1040085
> jaxb-integration-test . Basics are working - but adding a bit more complex
> route features like  the things went odd. BTW, some route works if I load
> them from a "normal" Camel context (Spring based).
>
> After looking around and debugging I found that loading from a normal Spring
> based Camel context and from such external route definition xml file (like
> explained behind the link above) leads to different values in the field
> "outputs" of class RouteDefinition which causes the validation of this
> "outputs" in ProcessorDefinition.hasOutputs() to fail in the second
> scenario.
>
> Reason seems to me that during loading a route from Spring based camel
> context the routes are somehow preprocessed or corrected during
> CamelContextFactoryBean.afterPropertiesSet() (see comment at lines 309ff in
> this class). In contrast this preprocessing doesn't happen for the other
> loading scenario.
> Unfortunately I can't figure out how to solve or go around it. Instead I
> have to ask if someone can give me some hints how to load such routes from
> "external" files.
>
> TIA
> --
> View this message in context: http://camel.465427.n5.nabble.com/Loading-routes-from-XML-files-with-Camel-2-4-0-tp3340082p3340082.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/

Re: Loading routes from XML files with Camel 2.4.0

Posted by bfischer <bf...@gk-software.com>.
> Now image what we can do for FuseSource subscribers then ;) 

Mr. Stibchar is working on tis topic too ;-)

-----
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-tp3340082p3345928.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Loading routes from XML files with Camel 2.4.0

Posted by Claus Ibsen <cl...@gmail.com>.
On Sun, Jan 16, 2011 at 3:55 PM, bfischer <bf...@gk-software.com> wrote:
>
> Hi Claus,
>
> with todays (sunday) nightly build four from four tests are successful.
>
>

Ah that's great. You made it just before we start cutting the 2.6 release.

>
> Many thanks for your support.
>

Now image what we can do for FuseSource subscribers then ;)


>
>
>
>
>
> -----
> 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-tp3340082p3343373.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/

Re: Loading routes from XML files with Camel 2.4.0

Posted by bfischer <bf...@gk-software.com>.
Hi Claus,

with todays (sunday) nightly build four from four tests are successful.



Many thanks for your support.






-----
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-tp3340082p3343373.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Loading routes from XML files with Camel 2.4.0

Posted by Claus Ibsen <cl...@gmail.com>.
On Sat, Jan 15, 2011 at 11:15 AM, Claus Ibsen <cl...@gmail.com> wrote:
> Hi
>
> I have spotted the issue and is running full tests to ensure no side
> effect is introduced.
>

I have committed a fix, can you try again?

>
>
> --
> 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/
>



-- 
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/

Re: Loading routes from XML files with Camel 2.4.0

Posted by Claus Ibsen <cl...@gmail.com>.
Hi

I have spotted the issue and is running full tests to ensure no side
effect is introduced.



-- 
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/

Re: Loading routes from XML files with Camel 2.4.0

Posted by bfischer <bf...@gk-software.com>.
Hi

sure I can ;-)

Spring context now with myProcessor bean 

<?xml version="1.0" encoding="UTF-8"?>
<beans
  xmlns        ="http://www.springframework.org/schema/beans"
  xmlns:xsi    ="http://www.w3.org/2001/XMLSchema-instance"
  xmlns:context="http://www.springframework.org/schema/context"
  xmlns:util   ="http://www.springframework.org/schema/util"
  xmlns:tx     ="http://www.springframework.org/schema/tx"
  xmlns:jdbc   ="http://www.springframework.org/schema/jdbc"
  xsi:schemaLocation="
    http://www.springframework.org/schema/beans  
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
    http://www.springframework.org/schema/util   
http://www.springframework.org/schema/util/spring-util-3.0.xsd
    http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.0.xsd
    http://www.springframework.org/schema/jdbc   
http://www.springframework.org/schema/jdbc/spring-jdbc.xsd
    http://www.springframework.org/schema/tx     
http://www.springframework.org/schema/tx/spring-tx.xsd
    http://camel.apache.org/schema/spring        
http://camel.apache.org/schema/spring/camel-spring.xsd"
> 
  <bean id="myProcessor"
class="com.gk_software.camel.testRouteLoading.MyPrcossor"/>  
  
  <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>
  
  <!--
===================================================================================================
-->
  
  <jdbc:embedded-database id="dataSource" type="HSQL">
    <jdbc:script location="classpath:META-INF/database-hsqldb.ddl" />
  </jdbc:embedded-database>

  <tx:annotation-driven />
  
  <bean
class="org.springframework.dao.annotation.PersistenceExceptionTranslationPostProcessor"
/>
  <bean
class="org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor"
/>
  
  <bean id="transactionManager"
class="org.springframework.orm.jpa.JpaTransactionManager">
    <property name="entityManagerFactory" ref="entityManagerFactory" />
  </bean>
  
  <bean id="entityManagerFactory"
class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
    <property name="dataSource"          ref  ="dataSource" />
    <property name="persistenceUnitName" value="MsgBus" />
    <property name="jpaVendorAdapter">
      <bean
class="org.springframework.orm.jpa.vendor.EclipseLinkJpaVendorAdapter">
        <property name="generateDdl" value="false"/>
        <property name="showSql"     value="false"/>
        <property name="database">
          <util:constant
static-field="org.springframework.orm.jpa.vendor.Database.HSQL"/>
        </property>
      </bean>
    </property>
  </bean>
    
</beans>

and loading this routes fail

<?xml version="1.0" encoding="UTF-8"?>
<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>

BTW, I found one difference between your and my testing. It seems your
starting camel context after adding routes -> from
"LoadRouteFromXmlWithOnExceptionTest.java"

       InputStream is =
getClass().getResourceAsStream("barOnExceptionRoute.xml");
        RoutesDefinition routes = context.loadRoutesDefinition(is);
        context.addRouteDefinitions(routes.getRoutes());
        context.start();

IMO in my cases the context is still up and running when I try to load/add
routes. Not sure whether it makes a difference or not ...


-----
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-tp3340082p3342468.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Loading routes from XML files with Camel 2.4.0

Posted by Claus Ibsen <cl...@gmail.com>.
Can you past the full route which for this failure below?



On Sat, Jan 15, 2011 at 10:53 AM, bfischer <bf...@gk-software.com> wrote:
>
> Hi
>
> your are right - my fault, sorry.
>
> Now three from four tests are working ... still the one with <transacted/>
> reports this error
>
> 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:750)
>        at
> org.apache.camel.model.RouteDefinition.addRoutes(RouteDefinition.java:160)
>        at
> org.apache.camel.impl.DefaultCamelContext.startRoute(DefaultCamelContext.java:698)
>        at
> org.apache.camel.impl.DefaultCamelContext.startRouteDefinitions(DefaultCamelContext.java:1621)
>        at
> org.apache.camel.impl.DefaultCamelContext.addRouteDefinitions(DefaultCamelContext.java:649)
>        at
> com.gk_software.camel.testRouteLoading.TestCase.loadAdditionalRoute(TestCase.java:131)
>        at com.gk_software.camel.testRouteLoading.TestCase.test02(TestCase.java:67)
>        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:748)
>        ... 30 more
>
>
>
> -----
> 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-tp3340082p3342458.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/

Re: Loading routes from XML files with Camel 2.4.0

Posted by bfischer <bf...@gk-software.com>.
Hi

your are right - my fault, sorry.

Now three from four tests are working ... still the one with <transacted/>
reports this error

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:750)
	at
org.apache.camel.model.RouteDefinition.addRoutes(RouteDefinition.java:160)
	at
org.apache.camel.impl.DefaultCamelContext.startRoute(DefaultCamelContext.java:698)
	at
org.apache.camel.impl.DefaultCamelContext.startRouteDefinitions(DefaultCamelContext.java:1621)
	at
org.apache.camel.impl.DefaultCamelContext.addRouteDefinitions(DefaultCamelContext.java:649)
	at
com.gk_software.camel.testRouteLoading.TestCase.loadAdditionalRoute(TestCase.java:131)
	at com.gk_software.camel.testRouteLoading.TestCase.test02(TestCase.java:67)
	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:748)
	... 30 more



-----
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-tp3340082p3342458.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Loading routes from XML files with Camel 2.4.0

Posted by Claus Ibsen <cl...@gmail.com>.
Hi

You need to have a bean with the processor in the spring XML file

<bean id="myProcessor" class="..."/>

It cannot be define in the <routes> XML file you load. It has to be
available up-front when using Spring applications.


If you use OSGi then you can enlist services on-the-fly.



On Sat, Jan 15, 2011 at 10:40 AM, bfischer <bf...@gk-software.com> wrote:
>
> Hi Claus,
>
> I'm glad that I finally could explain the topic in right way and many thanks
> for your fast reaction!
>
>
>
> Unfortunately I had to wait for nightly build because I wasn't able to build
> it from sources (got a strange compile error - don't know what is wrong in
> my local environment).
>
> Additionally I improved my tests with your new test cases
> (barInterceptorRoute.xml and barOnExceptionRoute.xml) - now having four
> tests steps.
>
> But it still don't work.
>
> Testing a trancacted route fails with sme error message (see my previous
> post).
>
> Testing "barOnExceptionRoute.xml" leads in error in my environment too. But
> this is may be because I had to adopt it a little bit (no jndi environment
> -> added myProcessor to spring configuration) and so it can be my error.
> Error message thrown
>
> org.apache.camel.FailedToCreateRouteException: Failed to create route bar
> at: >>> process[ref:myProcessor] <<< in route: Route[[From[direct:bar]] ->
> [OnException[[class java.lang.Ex... because of registry entry called
> myProcessor must be specified on: process[ref:myProcessor]
>        at
> org.apache.camel.model.RouteDefinition.addRoutes(RouteDefinition.java:759)
>        at
> org.apache.camel.model.RouteDefinition.addRoutes(RouteDefinition.java:160)
>        at
> org.apache.camel.impl.DefaultCamelContext.startRoute(DefaultCamelContext.java:698)
>        at
> org.apache.camel.impl.DefaultCamelContext.startRouteDefinitions(DefaultCamelContext.java:1621)
>        at
> org.apache.camel.impl.DefaultCamelContext.addRouteDefinitions(DefaultCamelContext.java:649)
>        at
> com.gk_software.camel.testRouteLoading.TestCase.loadAdditionalRoute(TestCase.java:131)
>        at com.gk_software.camel.testRouteLoading.TestCase.test04(TestCase.java:99)
>        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: registry entry called
> myProcessor must be specified on: process[ref:myProcessor]
>        at org.apache.camel.util.ObjectHelper.notNull(ObjectHelper.java:293)
>        at
> org.apache.camel.model.ProcessDefinition.createProcessor(ProcessDefinition.java:87)
>        at
> org.apache.camel.model.ProcessorDefinition.makeProcessor(ProcessorDefinition.java:403)
>        at
> org.apache.camel.model.ProcessorDefinition.addRoutes(ProcessorDefinition.java:174)
>        at
> org.apache.camel.model.RouteDefinition.addRoutes(RouteDefinition.java:756)
>        ... 30 more
>
> I'll work on this topic on monday - rest of weekend is reserved for family.
> If wanted I can pimp up my test cases a little bit and "post" it ;-)
>
>
>
> -----
> 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-tp3340082p3342449.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/

Re: Loading routes from XML files with Camel 2.4.0

Posted by bfischer <bf...@gk-software.com>.
Hi Claus,

I'm glad that I finally could explain the topic in right way and many thanks
for your fast reaction!



Unfortunately I had to wait for nightly build because I wasn't able to build
it from sources (got a strange compile error - don't know what is wrong in
my local environment).

Additionally I improved my tests with your new test cases
(barInterceptorRoute.xml and barOnExceptionRoute.xml) - now having four
tests steps.

But it still don't work.

Testing a trancacted route fails with sme error message (see my previous
post).

Testing "barOnExceptionRoute.xml" leads in error in my environment too. But
this is may be because I had to adopt it a little bit (no jndi environment
-> added myProcessor to spring configuration) and so it can be my error.
Error message thrown

org.apache.camel.FailedToCreateRouteException: Failed to create route bar
at: >>> process[ref:myProcessor] <<< in route: Route[[From[direct:bar]] ->
[OnException[[class java.lang.Ex... because of registry entry called
myProcessor must be specified on: process[ref:myProcessor]
	at
org.apache.camel.model.RouteDefinition.addRoutes(RouteDefinition.java:759)
	at
org.apache.camel.model.RouteDefinition.addRoutes(RouteDefinition.java:160)
	at
org.apache.camel.impl.DefaultCamelContext.startRoute(DefaultCamelContext.java:698)
	at
org.apache.camel.impl.DefaultCamelContext.startRouteDefinitions(DefaultCamelContext.java:1621)
	at
org.apache.camel.impl.DefaultCamelContext.addRouteDefinitions(DefaultCamelContext.java:649)
	at
com.gk_software.camel.testRouteLoading.TestCase.loadAdditionalRoute(TestCase.java:131)
	at com.gk_software.camel.testRouteLoading.TestCase.test04(TestCase.java:99)
	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: registry entry called
myProcessor must be specified on: process[ref:myProcessor]
	at org.apache.camel.util.ObjectHelper.notNull(ObjectHelper.java:293)
	at
org.apache.camel.model.ProcessDefinition.createProcessor(ProcessDefinition.java:87)
	at
org.apache.camel.model.ProcessorDefinition.makeProcessor(ProcessorDefinition.java:403)
	at
org.apache.camel.model.ProcessorDefinition.addRoutes(ProcessorDefinition.java:174)
	at
org.apache.camel.model.RouteDefinition.addRoutes(RouteDefinition.java:756)
	... 30 more

I'll work on this topic on monday - rest of weekend is reserved for family.
If wanted I can pimp up my test cases a little bit and "post" it ;-)



-----
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-tp3340082p3342449.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Loading routes from XML files with Camel 2.4.0

Posted by Claus Ibsen <cl...@gmail.com>.
Hi

I have commited an improvement on trunk. Can you try this out?

On Fri, Jan 14, 2011 at 3:17 PM, bfischer <bf...@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/

Re: Loading routes from XML files with Camel 2.4.0

Posted by Claus Ibsen <cl...@gmail.com>.
Hi

I have created a ticket you can check stats upon
https://issues.apache.org/jira/browse/CAMEL-3543


On Fri, Jan 14, 2011 at 3:23 PM, Claus Ibsen <cl...@gmail.com> wrote:
> 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 <bf...@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/
>



-- 
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/

Re: Loading routes from XML files with Camel 2.4.0

Posted by Claus Ibsen <cl...@gmail.com>.
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 <bf...@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/

Re: Loading routes from XML files with Camel 2.4.0

Posted by bfischer <bf...@gk-software.com>.
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.

Re: Loading routes from XML files with Camel 2.4.0

Posted by Claus Ibsen <cl...@gmail.com>.
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 <bf...@gk-software.com> 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
> 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-tp3340082p3341070.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/

Re: Loading routes from XML files with Camel 2.4.0

Posted by bfischer <bf...@gk-software.com>.
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
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-tp3340082p3341070.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Loading routes from XML files with Camel 2.4.0

Posted by Ashwin Karpe <ak...@fusesource.com>.
Hi,

Please check out the link given below.

http://camel.apache.org/configuring-camel.html
http://camel.apache.org/configuring-camel.html 

In particular, please check out the section "How do I import routes from
other XML files"

Hope this helps.

Cheers,

Ashwin...

-----
---------------------------------------------------------
Ashwin Karpe
Apache Camel Committer & Sr Principal Consultant
FUSESource (a Progress Software Corporation subsidiary)
http://fusesource.com http://fusesource.com 

Blog: http://opensourceknowledge.blogspot.com
http://opensourceknowledge.blogspot.com 
---------------------------------------------------------
-- 
View this message in context: http://camel.465427.n5.nabble.com/Loading-routes-from-XML-files-with-Camel-2-4-0-tp3340082p3340666.html
Sent from the Camel - Users mailing list archive at Nabble.com.