I did bit of investigation at eclipse side and noticed that Eclipse only
invokes terminate and doesn't call Ctr C equivalent shutdown. There is an
existing bug in eclipse as shown below which won't be fixed. 

https://bugs.eclipse.org/bugs/show_bug.cgi?id=38016 


So, i have found a way to initiate graceful shutdown. Please see the link
below which gave me an idea
http://blog.arc90.com/2008/04/18/patrick-avis-java-tips-2-graceful-jvm-shutdown-in-eclipse/


I have written a code that will allow me to shutdown from eclipse console.
This can be seen a hack but it helps during development to gracefully
shutdown an application that was started through eclipse ide.

in the main method
....
if (Boolean.parseBoolean(System.getenv("RUNNING_IN_ECLIPSE")) == true){
                                                ShutDownFromEclipseConsole 
shutDownThread = new
ShutDownFromEclipseConsole();
                                                shutDownThread .setDaemon(true);
                                                shutDownThread .start();
}
...
// call Spring method
// i.e. org.apache.camel.spring.Main.main(configLocation);
...


public class ShutDownFromEclipseConsole extends Thread {
                @Override
                public void run() {
                        String line = null;
                        do{
                        try{
                                //if i didn't add this delay, then
in.readline will block the camel logging on the console.
                                Thread.sleep(1000);
                                InputStreamReader converter = new 
InputStreamReader(System.in);
                                BufferedReader in = new 
BufferedReader(converter);

                                line = in.readLine();
                                
                        }catch (IOException e) {
                                e.printStackTrace();
                        } catch (InterruptedException e) {
                                
                                e.printStackTrace();
                        }
                        } while(!line.equalsIgnoreCase("x"));
                        System.exit(1);
                }
}


Cheers,
-Vid-


-- 
View this message in context: 
http://camel.465427.n5.nabble.com/Camel-shutdown-on-windows-tp2688126p2739597.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Reply via email to