You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by ltomuno <lt...@163.com> on 2011/06/03 08:47:34 UTC

CamelContext start and stop question

java code:
CamelContext context = new DefaultCamelContext();
... ...

        // start the route and let it do its work
        context.start();
        Thread.sleep(2000);
        // stop the CamelContext
        context.stop();
I have to do it every time?
start sleep stop
Is there a more elegant way to use CamelContext ?


Re: CamelContext start and stop question

Posted by Claus Straube <cl...@catify.com>.
 You can start it once and use it (that's the default way) over your 
 complete application lifecycle. And you have not to start the route 
 explicitly, but load them into the context.

 Best regards - Claus

 Am Freitag, den 03.06.2011, 08:47 +0200 schrieb ltomuno 
 <lt...@163.com>:
> java code:
> CamelContext context = new DefaultCamelContext();
> ... ...
>
>         // start the route and let it do its work
>         context.start();
>         Thread.sleep(2000);
>         // stop the CamelContext
>         context.stop();
> I have to do it every time?
> start sleep stop
> Is there a more elegant way to use CamelContext ?


Re: CamelContext start and stop question

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

See this FAQ
http://camel.apache.org/running-camel-standalone.html

Which has a link to this cookbook example how to keep it running
http://camel.apache.org/running-camel-standalone-and-have-it-keep-running.html

2011/6/3 ltomuno <lt...@163.com>:
> java code:
> CamelContext context = new DefaultCamelContext();
> ... ...
>
>        // start the route and let it do its work
>        context.start();
>        Thread.sleep(2000);
>        // stop the CamelContext
>        context.stop();
> I have to do it every time?
> start sleep stop
> Is there a more elegant way to use CamelContext ?
>
>



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