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: Starting camel from my own class - Camel stops when main method stops
Date Sat, 14 Feb 2009 07:23:24 GMT
Hi

You can use ctrl + break or ctrl + \ on unix to dump the thread list
when you app hangs.
You can then identify what happens

We fixed an issue with the Main app not being able to stop properly,
that is fixed in Camel 1.6.0,
with a thread waiting for a countdown latch.

So try out the 1.6.0 when its released

On Fri, Feb 13, 2009 at 5:47 PM, James Strachan
<james.strachan@gmail.com> wrote:
> This looks like its down to daemon threads (I can never remember
> whether daemon on or off stops the JVM from terminating :).
>
> The easiest way to fix it might be having a loop in your main asking
> the user to enter 'quit' to terminate the application or something.
>
> Either that or just wait forever via an infinite loop...
>
> Object lock = new Object();
> while (true) {
>  synchronized { try { lock.wait(); } catch (Exception e) { } }
> }
>
>
> 2009/2/13 selezovikj <semir.elezovic@gmail.com>:
>>
>> I want to start Camel from my own class called Startup because I want to
>> start other services as well.
>> In the Startup class I do the following:
>>
>> // org.apache.camel.spring.Main
>> Main camelMain = new Main();
>> camelMain.setApplicationContextUri("../config/jms-routing.xml");
>>
>> try {
>>            camelMain.start();
>>
>>        } catch (Exception e) {
>>
>>            logger.error("Error starting camel", e);
>>            System.exit(-1);
>>        }
>>
>> Once the main method exits camel is stopped as well:
>>
>> 2009-02-13 10:40:03,509 [                          main] TransportConnector
>> INFO  Connector tcp Started
>> 2009-02-13 10:40:03,510 [                          main] BrokerService
>> INFO  ActiveMQ JMS Message Broker (localhost,
>> ID:semir.2e-systems.com-58933-1234518003268-0:0) started
>> 2009-02-13 10:40:08,824 [         ActiveMQ ShutdownHook] BrokerService
>> INFO  ActiveMQ Message Broker (localhost,
>> ID:semir.2e-systems.com-58933-1234518003268-0:0) is shutting down
>> 2009-02-13 10:40:09,512 [         ActiveMQ ShutdownHook] TransportConnector
>> INFO  Connector tcp Stopped
>> 2009-02-13 10:40:09,578 [         ActiveMQ ShutdownHook] BrokerService
>> INFO  ActiveMQ JMS Message Broker (localhost,
>> ID:semir.2e-systems.com-58933-1234518003268-0:0) stopped
>>
>>
>> If I put a thread sleep before the main method exits for 20 seconds ... then
>> Camel is up on 61617 for around 20 seconds.
>>
>> Am I doing something wrong ?
>> Can anybody help ?
>>
>> --
>> View this message in context: http://www.nabble.com/Starting-camel-from-my-own-class---Camel-stops-when-main-method-stops-tp21993387s22882p21993387.html
>> Sent from the Camel - Users mailing list archive at Nabble.com.
>>
>>
>
>
>
> --
> James
> -------
> http://macstrac.blogspot.com/
>
> Open Source Integration
> http://fusesource.com/
>



-- 
Claus Ibsen
Apache Camel Committer

Open Source Integration: http://fusesource.com
Blog: http://davsclaus.blogspot.com/

Mime
View raw message