You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by Gaurav Sehgal <ga...@yahoo.com> on 2012/09/10 12:45:40 UTC
Loading Camel Context from Spring XML
Hi,
I have a simple XML file:
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:camel="http://camel.apache.org/schema/spring"
xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd">
<camel:camelContext autoStartup="false">
<camel:route autoStartup="false" shutdownRoute="Defer">
<camel:from uri="file:data/inbox/file" />
<camel:to uri="file:data/outbox/" />
</camel:route>
</camel:camelContext>
</beans>
which I load from my Java Program using ApplicationContext, the code is below:
{
ApplicationContext context = new ClassPathXmlApplicationContext(new String[]{"routes1.xml"});
CamelContext camel = SpringCamelContext.springCamelContext(context);
System.out.println(camel.getName());
camel.start();
Thread.sleep(10000);
camel.stop();
}
Though for some reasons it does not execute the route specified in the CamelContext. The file never gets copied. Though I am sure the context is getting created inside the Java Program. Do I need some additional configuration parameters to make sure the route defined in the CamelContext gets started?
Regards,
Gaurav
Re: Loading Camel Context from Spring XML
Posted by Claus Ibsen <cl...@gmail.com>.
Hi
The file component in Camel is configured with a starting directory,
as documented (see big green box)
http://camel.apache.org/file2
So you route should most likely be
<camel:from uri="file:data/inbox" />
Then it will pickup any files you put in the inbox directory.
On Mon, Sep 10, 2012 at 1:14 PM, gsehgal <ga...@yahoo.com> wrote:
> Hi,
> I did that now my XML looks like:
> <camel:camelContext >
> <camel:route shutdownRoute="Defer">
> <camel:from uri="file:data/inbox/file" />
> <camel:to uri="file:data/outbox/" />
> </camel:route>
> </camel:camelContext>
>
> Though even now the routes are not started, I am using Camel version:
> 2.9.2 and spring version : 3.0.6. That should be fine right?
>
> Regards,
>
>
>
>
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/Loading-Camel-Context-from-Spring-XML-tp5719025p5719030.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, fusenews
Blog: http://davsclaus.com
Author of Camel in Action: http://www.manning.com/ibsen
Re: Loading Camel Context from Spring XML
Posted by gsehgal <ga...@yahoo.com>.
it worked. You have to specify a "//" after "file:" otherwise it was not able
to resolve the path.
Thanks for your help.
--
View this message in context: http://camel.465427.n5.nabble.com/Loading-Camel-Context-from-Spring-XML-tp5719025p5719032.html
Sent from the Camel - Users mailing list archive at Nabble.com.
Re: Loading Camel Context from Spring XML
Posted by gsehgal <ga...@yahoo.com>.
Hi,
I did that now my XML looks like:
<camel:camelContext >
<camel:route shutdownRoute="Defer">
<camel:from uri="file:data/inbox/file" />
<camel:to uri="file:data/outbox/" />
</camel:route>
</camel:camelContext>
Though even now the routes are not started, I am using Camel version:
2.9.2 and spring version : 3.0.6. That should be fine right?
Regards,
--
View this message in context: http://camel.465427.n5.nabble.com/Loading-Camel-Context-from-Spring-XML-tp5719025p5719030.html
Sent from the Camel - Users mailing list archive at Nabble.com.
Re: Loading Camel Context from Spring XML
Posted by Claus Ibsen <cl...@gmail.com>.
Hi
You have set autoStartup=false, which means routes wont be started on
staring CamelContext.
Set the option to true, or remove it (as true is default).
On Mon, Sep 10, 2012 at 12:45 PM, Gaurav Sehgal <ga...@yahoo.com> wrote:
> Hi,
> I have a simple XML file:
>
>
> <beans xmlns="http://www.springframework.org/schema/beans"
> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
> xmlns:camel="http://camel.apache.org/schema/spring"
> xsi:schemaLocation="
> http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
> http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd">
>
>
> <camel:camelContext autoStartup="false">
> <camel:route autoStartup="false" shutdownRoute="Defer">
> <camel:from uri="file:data/inbox/file" />
> <camel:to uri="file:data/outbox/" />
> </camel:route>
> </camel:camelContext>
> </beans>
>
>
> which I load from my Java Program using ApplicationContext, the code is below:
>
> {
> ApplicationContext context = new ClassPathXmlApplicationContext(new String[]{"routes1.xml"});
> CamelContext camel = SpringCamelContext.springCamelContext(context);
> System.out.println(camel.getName());
> camel.start();
> Thread.sleep(10000);
> camel.stop();
>
> }
>
>
> Though for some reasons it does not execute the route specified in the CamelContext. The file never gets copied. Though I am sure the context is getting created inside the Java Program. Do I need some additional configuration parameters to make sure the route defined in the CamelContext gets started?
>
>
> Regards,
> Gaurav
--
Claus Ibsen
-----------------
FuseSource
Email: cibsen@fusesource.com
Web: http://fusesource.com
Twitter: davsclaus, fusenews
Blog: http://davsclaus.com
Author of Camel in Action: http://www.manning.com/ibsen