Hi Welcome to the Camel community.
On Mon, May 24, 2010 at 11:52 AM, StonePeng <tian_bogu...@tom.com> wrote: > > i am new to camel, i find a interesting thing that the method start() is not > blocking and listening. The method main will finish and exit if there is not > "Thread.sleep(1000)". so need i start() and stop() every time when i use > camel? and need i run "context.start()" for every route msg? > this is my demo below: > public class CamelTest { > public static void main(String args[]) throws Exception { > CamelContext context = new DefaultCamelContext(); > context.addRoutes(new SomeRouteBuilder()); > context.start(); > Thread.sleep(1000); > context.stop(); > } Well if you create CamelContext yourself from a Java application in the main method. Then you must handle its lifecycle. This is no different than lets say you created a Spring ApplicationContext in the same way. You can extend a MainSupport class from org.apache.camel.util which have some logic for "keep running". However there is a better Main class in camel-spring for that. Usually you embed Camel in your application and deploy it in some server/container of some sort. And then the lifecycle is handled by the container. So you can use a stop script etc. to stop your app. Chapter 13 in the Camel in Action book will cover this in details. > -- > View this message in context: > http://old.nabble.com/need-i-start%28%29-and-stop%28%29-every-time-when-i-use-camel--tp28655285p28655285.html > Sent from the Camel - Users mailing list archive at Nabble.com. > > -- Claus Ibsen Apache Camel Committer Author of Camel in Action: http://www.manning.com/ibsen/ Open Source Integration: http://fusesource.com Blog: http://davsclaus.blogspot.com/ Twitter: http://twitter.com/davsclaus