Hey, I have read the Main API and decided to override the doStart and doStop
methods. However, they don't work as one may expect, espcially the doStop
method, which seems quite useless.

First I have a problem. In my main, when I use main.start(), the progam does
not hangup, even though I specify that I want hangupsupport. Therefore, I
have to use the run() method, instead of the start() method.

Then there is the stop() method. In my example, using main.stop() seems
useless at best. For a method that is supposed to stop the server (or so it
is what I assume) it simply does not work when I use main.run() instead of
main.start().

Now to the doStart() and doStop() methods that I override. The doStart()
method is always called when I call main.start() or main.run(), which is
what I expected.

However, the doStop() method only is called when I use main.start(). I will
not run if I use main.run(). Furthermore, if the server is running, and I
terminate it using CTRL+C, the doStop() method will not be called as well.

This leaves me with the question: am I using the methods wrong or are they
bugged? I believe it is the first one, but I am not sure. 

Here is the sample app I am testing, in case you need:

public class MyApp_B extends Main{

        public static void main(String... args) throws Exception {
                MyApp_B main = new MyApp_B();

                main.enableHangupSupport();

                main.addRouteBuilder(
                                new RouteBuilder(){
                                        @Override
                                        public void configure() throws 
Exception {
                                                //TODO main job of the route 
here, change and forward reports
                                        }
                                }
                );

                System.out.println("Starting Camel MyApp_B. Use ctrl + c to 
terminate the
JVM.\n");
                main.run();

                //main.start() wont hangup, the program terminates immediately
                //main.stop() wont work with main.run(), only works with 
main.start()
        }

        
        @Override
        protected void doStart(){
                System.out.println("Starting !");
                
                addRouteBuilder(new RouteBuilder(){
                        @Override
                        public void configure() throws Exception {
                                // TODO generate Message with local IP and send 
it to master asking him
to ADD me
                        }
                });
        }
        
        @Override 
        protected void doStop(){
                System.out.println("Stopping !");
                
                addRouteBuilder(new RouteBuilder(){
                        @Override
                        public void configure() throws Exception {
                                // TODO generate Message with local IP and send 
it to master asking him
to REMOVE me
                        }
                });
        }
}



--
View this message in context: 
http://camel.465427.n5.nabble.com/Is-there-a-way-to-send-a-message-when-I-am-terminating-tp5742834p5742851.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Reply via email to