camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Willem Jiang <willem.ji...@gmail.com>
Subject Re: After camelContext shutdown, is any way to exit the Java main() method?
Date Mon, 22 Jul 2013 03:30:04 GMT
As you are using camel main to start the camel context. You need to call
the System.exit() when the Camel context is stopped.


Willem Jiang

Red Hat, Inc.
FuseSource is now part of Red Hat
Web: http://www.fusesource.com | http://www.redhat.com
Blog: http://willemjiang.blogspot.com (http://willemjiang.blogspot.com/)
(English)
          http://jnn.iteye.com (http://jnn.javaeye.com/) (Chinese)
Twitter: willemjiang
Weibo: 姜宁willem


On Mon, Jul 22, 2013 at 10:40 AM, bonnahu <bonnahu@gmail.com> wrote:

> Hi guys,
> I got another question here. I start my camelContext in the main(), then in
> the route, I stop the camelContext
> in a Processor. Now I can see the camelContext is shutdown gracefully.
> However, the Java application is still running. My question is that whether
> there is a way to exit the Java main() automatically after the camelContext
> is shutdown.
>
>
> public static void main(String[] args) throws Exception {
>         String filename = "META-INF/spring/testingcontext.xml";
>         Main main = new Main();
>         main.setApplicationContextUri(filename);
>         main.enableHangupSupport();
>         main.run();
> }
>
>
> public class DownloadLogger implements Processor {
>         public void process(final Exchange exchange) throws Exception {
>         System.out.println("We just downloaded:  "
>                 + exchange.getIn().getHeader("CamelFileName"));
>         Thread stop = new Thread() {
>                 @Override
>                 public void run() {
>                     try {
>                         //exchange.getContext().stopRoute("myRoute");
>
> exchange.getContext().getShutdownStrategy().setTimeout(5);
>                         exchange.getContext().stop();
>                     } catch (Exception e) {
>                         // ignore
>                     }
>                 }
>             };
>         stop.start();
>         System.out.println("after camel context stop");
>     }
> }
> I
> thansk in advance!
>
> Lei
>
>
>
> --
> View this message in context:
> http://camel.465427.n5.nabble.com/After-camelContext-shutdown-is-any-way-to-exit-the-Java-main-method-tp5735993.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message