Starting camel context not blocking

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Starting camel context not blocking

jpcook01
Hi,

I noticed that calling start() on camel context doesn't block the thread anymore which it used to do in earlier versions of camel. I think this is the correct behavior of Camel 2.0.

But I wondered if there was a simple example of starting the context and stopping it exiting straight away without using Spring?

I've been looking at the MainSupport class from org.apache.camel.util as a starting point to have blocked until you hit ctrl + c or call stop() on CamelContext but the only example I can see has lots of Spring stuff in it?

Thanks
Reply | Threaded
Open this post in threaded view
|

Re: Starting camel context not blocking

David Roussel
There are some none-spring java examples in the Camel in Action book.  So I guess they can be found here: http://code.google.com/p/camelinaction/

This is about as simple as it gets:
http://code.google.com/p/camelinaction/source/browse/trunk/chapter1/file-copy/src/main/java/camelinaction/FileCopierWithCamel.java

David

jpcook wrote
Hi,

I noticed that calling start() on camel context doesn't block the thread anymore which it used to do in earlier versions of camel. I think this is the correct behavior of Camel 2.0.

But I wondered if there was a simple example of starting the context and stopping it exiting straight away without using Spring?

I've been looking at the MainSupport class from org.apache.camel.util as a starting point to have blocked until you hit ctrl + c or call stop() on CamelContext but the only example I can see has lots of Spring stuff in it?

Thanks
Reply | Threaded
Open this post in threaded view
|

Re: Starting camel context not blocking

Claus Ibsen-2
In reply to this post by jpcook01
On Thu, Feb 25, 2010 at 4:03 PM, jpcook <[hidden email]> wrote:
>
> Hi,
>
> I noticed that calling start() on camel context doesn't block the thread
> anymore which it used to do in earlier versions of camel. I think this is
> the correct behavior of Camel 2.0.
>

To my knowledge invoking start() have newer blocked. It should not block.
Its your choice to run Camel standalone and you must keep your app
running how you like it.

Most people run Camel in some existing container which have start /
stop scripts already.

> But I wondered if there was a simple example of starting the context and
> stopping it exiting straight away without using Spring?
>
> I've been looking at the MainSupport class from org.apache.camel.util as a
> starting point to have blocked until you hit ctrl + c or call stop() on
> CamelContext but the only example I can see has lots of Spring stuff in it?
>

We could maybe improve the MainSupport in camel-core to make it easier
to use for use cases like yours.
You can extend it and implement the needed methods.

Or frankly you can do a while(true) loop and have a shutdown hook
registered which will stop Camel.
This is done in those MainSupport classes.


> Thanks
> --
> View this message in context: http://old.nabble.com/Starting-camel-context-not-blocking-tp27714451p27714451.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>
>



--
Claus Ibsen
Apache Camel Committer

Author of Camel in Action: http://www.manning.com/ibsen/
Open Source Integration: http://fusesource.com
Blog: http://davsclaus.blogspot.com/
Twitter: http://twitter.com/davsclaus
Reply | Threaded
Open this post in threaded view
|

Re: Starting camel context not blocking

jpcook01
In version 1.4 it definitely does block.

I started off with a while loop but then implemented MainSupport and took the example from the Spring Example project but stripped out all Spring specific stuff. Works nicely.

I might put something on the wiki to make it a little bit more obvious.

Thanks


Claus Ibsen-2 wrote
On Thu, Feb 25, 2010 at 4:03 PM, jpcook <jonathan.cook@erars.plus.com> wrote:
>
> Hi,
>
> I noticed that calling start() on camel context doesn't block the thread
> anymore which it used to do in earlier versions of camel. I think this is
> the correct behavior of Camel 2.0.
>

To my knowledge invoking start() have newer blocked. It should not block.
Its your choice to run Camel standalone and you must keep your app
running how you like it.

Most people run Camel in some existing container which have start /
stop scripts already.

> But I wondered if there was a simple example of starting the context and
> stopping it exiting straight away without using Spring?
>
> I've been looking at the MainSupport class from org.apache.camel.util as a
> starting point to have blocked until you hit ctrl + c or call stop() on
> CamelContext but the only example I can see has lots of Spring stuff in it?
>

We could maybe improve the MainSupport in camel-core to make it easier
to use for use cases like yours.
You can extend it and implement the needed methods.

Or frankly you can do a while(true) loop and have a shutdown hook
registered which will stop Camel.
This is done in those MainSupport classes.


> Thanks
> --
> View this message in context: http://old.nabble.com/Starting-camel-context-not-blocking-tp27714451p27714451.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>
>



--
Claus Ibsen
Apache Camel Committer

Author of Camel in Action: http://www.manning.com/ibsen/
Open Source Integration: http://fusesource.com
Blog: http://davsclaus.blogspot.com/
Twitter: http://twitter.com/davsclaus