You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by kanmisc <ka...@gmail.com> on 2011/03/11 16:44:43 UTC
Shutting down camel from a test!
Hi All
I have a requirement of monitoring my system and it is implemented with the
help of camel sending messages often to different ports and checks for
system status. When i developed, i used mvn camel:run command and executed
the camel routes to send messages.
But now i have to automate it by executing this camel functionality from
unix cron. For this i have written a junit test which is called from cron
and it triggers the camel to send messages every hour. it starts and sends
messages fine but I am not able to shutdown the camel completely. I tried
shutdown strategy but it is not getting shut down.
Please provide suggestions -
1) Is it ok to call camel like this from a test class? Or is it possible to
execute camel from unix cron directly?
2) How to shutdown the camel (i.e until next triggering of messages so that
no resource consumption)
Thanks in advance.
--
View this message in context: http://camel.465427.n5.nabble.com/Shutting-down-camel-from-a-test-tp3425270p3425270.html
Sent from the Camel - Users mailing list archive at Nabble.com.
Re: Shutting down camel from a test!
Posted by Jon Anstey <ja...@gmail.com>.
If you just want to start a simple Camel app and then shutdown, there is no
requirement to use a test case - you can just use a standard main method
like in the jms-file example:
http://svn.apache.org/repos/asf/camel/trunk/examples/camel-example-jms-file/src/main/java/org/apache/camel/example/jmstofile/CamelJmsToFileExample.java
This uses the exec-maven-plugin to run the main method on the class with all
Maven deps on the classpath.
Alternatively, you can keep your Camel app running and use a Quartz endpoint
to do cron-like scheduling http://camel.apache.org/quartz.html
Cheers,
Jon
On Fri, Mar 11, 2011 at 12:14 PM, kanmisc <ka...@gmail.com> wrote:
> Hi All
>
> I have a requirement of monitoring my system and it is implemented with the
> help of camel sending messages often to different ports and checks for
> system status. When i developed, i used mvn camel:run command and executed
> the camel routes to send messages.
>
> But now i have to automate it by executing this camel functionality from
> unix cron. For this i have written a junit test which is called from cron
> and it triggers the camel to send messages every hour. it starts and sends
> messages fine but I am not able to shutdown the camel completely. I tried
> shutdown strategy but it is not getting shut down.
>
> Please provide suggestions -
> 1) Is it ok to call camel like this from a test class? Or is it possible to
> execute camel from unix cron directly?
> 2) How to shutdown the camel (i.e until next triggering of messages so that
> no resource consumption)
>
> Thanks in advance.
>
> --
> View this message in context:
> http://camel.465427.n5.nabble.com/Shutting-down-camel-from-a-test-tp3425270p3425270.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>
--
Cheers,
Jon
---------------
FuseSource
Email: jon@fusesource.com
Web: fusesource.com
Twitter: jon_anstey
Blog: http://janstey.blogspot.com
Author of Camel in Action: http://manning.com/ibsen
Re: Shutting down camel from a test!
Posted by Claus Ibsen <cl...@gmail.com>.
On Fri, Mar 11, 2011 at 4:44 PM, kanmisc <ka...@gmail.com> wrote:
> Hi All
>
> I have a requirement of monitoring my system and it is implemented with the
> help of camel sending messages often to different ports and checks for
> system status. When i developed, i used mvn camel:run command and executed
> the camel routes to send messages.
>
> But now i have to automate it by executing this camel functionality from
> unix cron. For this i have written a junit test which is called from cron
> and it triggers the camel to send messages every hour. it starts and sends
> messages fine but I am not able to shutdown the camel completely. I tried
> shutdown strategy but it is not getting shut down.
>
You should aim for any server or application etc. being able to
shutdown reliably.
So you should maybe take a bit time to investigate why it may not
shutdown properly.
Most often its sufficient to invoke the stop method on the
CamelContext to initiate a shutdown.
You can read more here
http://camel.apache.org/graceful-shutdown.html
Also chapter 13 in the Camel in Action book coves reliable startup and
shutdown of Camel.
> Please provide suggestions -
> 1) Is it ok to call camel like this from a test class? Or is it possible to
> execute camel from unix cron directly?
> 2) How to shutdown the camel (i.e until next triggering of messages so that
> no resource consumption)
>
> Thanks in advance.
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/Shutting-down-camel-from-a-test-tp3425270p3425270.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>
--
Claus Ibsen
-----------------
FuseSource
Email: cibsen@fusesource.com
Web: http://fusesource.com
Twitter: davsclaus
Blog: http://davsclaus.blogspot.com/
Author of Camel in Action: http://www.manning.com/ibsen/