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: Need control back in the Main routine so that we can terminate JVM
Date Mon, 13 Jun 2011 15:51:20 GMT
On Mon, Jun 13, 2011 at 5:25 PM, AnujK <reachanuj@gmail.com> wrote:
> Thanks Claus.
>
> -Yes, I did follow that example, and am calling Main.run()
> "System.out.println("Starting Camel. Use ctrl + c to terminate the JVM.\n");
>  main.run();"
>
> The problem is ' the main just keeps on running' - which we don't want.
>
> However, I need to terminate my VM when the FTP route is complete.
>
> I can stop/start the routes programatically, but is there a way to signal to
> the main thread, that routes have stopped, and you can now terminate.
>
> In essence, I do not need to be running 'forever'.
>

You can have for example a static boolean on the Main class, and then
change that when the route is done.

Then in the Main thread you loop and check that boolean and stop if its changed.
Remember to use sleep in the while loop so you dont loop too often and
drain CPU cycles.

Its frankly a general problem, so you can google for ideas.



> --
> View this message in context: http://camel.465427.n5.nabble.com/Need-control-back-in-the-Main-routine-so-that-we-can-terminate-JVM-tp4483312p4484731.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.blogspot.com/
Author of Camel in Action: http://www.manning.com/ibsen/

Mime
View raw message