Recommendation/Best Practice for shutting down Camel Spring Boot App

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

Recommendation/Best Practice for shutting down Camel Spring Boot App

jpcook01
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
Reply | Threaded
Open this post in threaded view
|

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

Mark Nuttall
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 <[hidden email]>
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
>
Reply | Threaded
Open this post in threaded view
|

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

Zoran Regvart-2
In reply to this post by jpcook01
Hi Jonathan,

On Wed, Apr 4, 2018 at 10:20 PM, Jonathan Cook
<[hidden email]> 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