You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by Jonathan Cook <jo...@erars.plus.com> on 2018/04/04 20:20:33 UTC

Recommendation/Best Practice for shutting down Camel Spring Boot App

Hello,

I was wondering if there was a way to shutdown a camel application which 
uses Spring Boot in a graceful way? I've seen this page - 
http://camel.apache.org/graceful-shutdown.html but it doesn't really 
explain it. For example I have a shell script for starting the app which 
runs my standalone java app.

To shut it down I was thinking of another shell script but don't simply 
want to kill the process. I've see Spring Boot Actuator provides a way 
via http but my app is not a webapp in a fat jar, just a standalone java 
app. I've also seen Spring Boot has a ApplicationPidFileWriter which 
writes the pid to a file but again this approach uses a brute force kill.

There seems to be a couple of tests here related to it:
https://github.com/apache/camel/tree/master/components/camel-spring-boot/src/test/java/org/apache/camel/spring/boot

But it isn't clear, do I have to create some kind of custom shutdown 
hook which I can call externally and stop the camel context or shut the 
routes down gracefully or does something in Camel Spring Boot do this 
for me?

Thanks for any help

Re: Recommendation/Best Practice for shutting down Camel Spring Boot App

Posted by Zoran Regvart <zo...@regvart.com>.
Hi Jonathan,

On Wed, Apr 4, 2018 at 10:20 PM, Jonathan Cook
<jo...@erars.plus.com> wrote:
> But it isn't clear, do I have to create some kind of custom shutdown hook
> which I can call externally and stop the camel context or shut the routes
> down gracefully or does something in Camel Spring Boot do this for me?

When auto-configured under Spring Boot, or manually configured using
SpringCamelContext, Camel's context startup/shutdown is tied to Spring
context startup/shutdown.

> To shut it down I was thinking of another shell script but don't simply want
> to kill the process. I've see Spring Boot Actuator provides a way via http
> but my app is not a webapp in a fat jar, just a standalone java app. I've
> also seen Spring Boot has a ApplicationPidFileWriter which writes the pid to
> a file but again this approach uses a brute force kill.

I think you should be able just to use `kill` without specifying
signal (that is SIGTERM or -15), or `kill -2` to use SIGINT signal,
equivalent of sending CTRL+C.

zoran
-- 
Zoran Regvart

Re: Recommendation/Best Practice for shutting down Camel Spring Boot App

Posted by Mark Nuttall <mk...@gmail.com>.
even though your app is not a web app, adding "web" and actuator add value
for things like metrics and health status .... and things like this. Why
not just add those two items? That is what i do.

And fyi,  you might ask this on the spring forums as this really is a
Spring Boot question.

On Wed, Apr 4, 2018 at 4:20 PM, Jonathan Cook <jo...@erars.plus.com>
wrote:

> Hello,
>
> I was wondering if there was a way to shutdown a camel application which
> uses Spring Boot in a graceful way? I've seen this page -
> http://camel.apache.org/graceful-shutdown.html but it doesn't really
> explain it. For example I have a shell script for starting the app which
> runs my standalone java app.
>
> To shut it down I was thinking of another shell script but don't simply
> want to kill the process. I've see Spring Boot Actuator provides a way via
> http but my app is not a webapp in a fat jar, just a standalone java app.
> I've also seen Spring Boot has a ApplicationPidFileWriter which writes the
> pid to a file but again this approach uses a brute force kill.
>
> There seems to be a couple of tests here related to it:
> https://github.com/apache/camel/tree/master/components/camel
> -spring-boot/src/test/java/org/apache/camel/spring/boot
>
> But it isn't clear, do I have to create some kind of custom shutdown hook
> which I can call externally and stop the camel context or shut the routes
> down gracefully or does something in Camel Spring Boot do this for me?
>
> Thanks for any help
>