You should give Camel time to shutdown graceful instead of forcing a 1
sec timeout
http://camel.apache.org/graceful-shutdown.html

On Tue, Jul 23, 2013 at 12:08 PM, SyedBhai <syedahmed.c...@hotmail.com> wrote:
> Hi.
>   I am having a simple class with main().  In main() I am executing the
> following code:
> try {
>             CamelContext cc=new DefaultCamelContext();
>             cc.addRoutes(new RouteBuilder()  {
>                            public void configure()  {
>                                from("direct:start1").
>
> to("cxf://http://localhost:8080/JAXWS1/MyInterfaceImpl?serviceClass=com.syed.MyInterface&serviceName={http://syed.com/}MyInterfaceImplService&portName={http://syed.com/}MyInterfaceImplPort";);
>                            }
>                          }
>                         );
>             cc.start();
>             ProducerTemplate t=cc.createProducerTemplate();
>             int annsal=t.requestBody("direct:start1", 10000, Integer.class);
>             System.out.println("annsal:"+annsal);
>             cc.getShutdownStrategy().setShutdownNowOnTimeout(true);
>             cc.getShutdownStrategy().setTimeUnit(TimeUnit.SECONDS);
>             cc.getShutdownStrategy().setTimeout(1);
>
>             t.stop();  cc.stop();
> }catch(Exception x){}
>
> To my surprise I am getting the output but the program is still running.  I
> later checked the list of threads running.  This is the list I have:
>
> Thread[main,5,main]
> Thread[Reference Handler,10,system]
> Thread[Finalizer,8,system]
> Thread[default-workqueue-1,5,default-workqueue]
> Thread[Thread-1,5,main]
> Thread[Signal Dispatcher,9,system]
> Thread[GC Daemon,2,system]
> Thread[I/O dispatcher 1,5,main]
> Thread[I/O dispatcher 2,5,main]
> Thread[I/O dispatcher 3,5,main]
> Thread[I/O dispatcher 4,5,main]
>
> If I use a mock:test endpoint instead of cxf the program terminates
> automatically.  So I believe when I am using some other components such as
> cxf then camel is creating some threads and not stopping them.
>
> This may cause memory leaks in my project.  Can you guys help?
>
> Thanks,
> Syed.
>
>
>
> --
> View this message in context: 
> http://camel.465427.n5.nabble.com/After-camelContext-shutdown-is-any-way-to-exit-the-Java-main-method-tp5735993p5736105.html
> Sent from the Camel - Users mailing list archive at Nabble.com.



-- 
Claus Ibsen
-----------------
Red Hat, Inc.
Email: cib...@redhat.com
Twitter: davsclaus
Blog: http://davsclaus.com
Author of Camel in Action: http://www.manning.com/ibsen

Reply via email to