This is an automated email from the ASF dual-hosted git repository.

davsclaus pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel.git


The following commit(s) were added to refs/heads/main by this push:
     new 12219820ecc CAMEL-19359: camel-spring - Graceful shutdown in Spring 
Boot better s… (#10184)
12219820ecc is described below

commit 12219820ecc10b304636dd0f8bfb4a417b7e8313
Author: Claus Ibsen <[email protected]>
AuthorDate: Tue May 23 06:24:01 2023 +0200

    CAMEL-19359: camel-spring - Graceful shutdown in Spring Boot better s… 
(#10184)
    
    * CAMEL-19359: camel-spring - Graceful shutdown in Spring Boot better 
supported. Changed the shutdown phase in SpringCamelContext to be a bit later.
---
 .../main/java/org/apache/camel/spring/SpringCamelContext.java    | 6 +++++-
 docs/user-manual/modules/ROOT/pages/camel-4-migration-guide.adoc | 9 +++++++++
 2 files changed, 14 insertions(+), 1 deletion(-)

diff --git 
a/components/camel-spring/src/main/java/org/apache/camel/spring/SpringCamelContext.java
 
b/components/camel-spring/src/main/java/org/apache/camel/spring/SpringCamelContext.java
index 9a14cec06cf..65a2ea5689e 100644
--- 
a/components/camel-spring/src/main/java/org/apache/camel/spring/SpringCamelContext.java
+++ 
b/components/camel-spring/src/main/java/org/apache/camel/spring/SpringCamelContext.java
@@ -292,7 +292,11 @@ public class SpringCamelContext extends DefaultCamelContext
         // (explained in comment in the onApplicationEvent method)
         // we use LOWEST_PRECEDENCE here as this is taken into account
         // only when stopping and then in reversed order
-        return LOWEST_PRECEDENCE;
+        return Integer.MAX_VALUE - 2049;
+        // we need to be less than max value as spring-boot comes with
+        // graceful shutdown services (the http server in spring boot)
+        // that must shutdown before camel, and they have max value - 2048,
+        // so we use 2049 to have a higher gap
     }
 
     @Override
diff --git a/docs/user-manual/modules/ROOT/pages/camel-4-migration-guide.adoc 
b/docs/user-manual/modules/ROOT/pages/camel-4-migration-guide.adoc
index 3c7211f50bf..fd7c4516006 100644
--- a/docs/user-manual/modules/ROOT/pages/camel-4-migration-guide.adoc
+++ b/docs/user-manual/modules/ROOT/pages/camel-4-migration-guide.adoc
@@ -319,6 +319,15 @@ Solver Daemon solutions should be migrated to use 
SolverManager.
 The `camel-spring-boot` dependency no longer includes `camel-spring-xml`. To 
use legacy Spring XML files `<beans>`
 with Camel on Spring Boot, then include the `camel-spring-boot-xml-starter` 
dependency.
 
+=== Graceful Shutdown
+
+Camel now shutdowns a bit later during Spring Boot shutdown. This allows 
Spring Boot graceful shutdown
+to complete first (stopping Spring Boot HTTP server gracefully),
+and then afterward Camel is doing its own xref:graceful-shutdown.adoc[].
+
+Technically `camel-spring` has changed `getPhase()` from returning 
`Integer.MAX_VALUE` to
+`Integer.MAX_VALUE - 2049`. This gives room for Spring Boot services to shut 
down first.
+
 === camel-micrometer-starter
 
 The `uri` tags are now static instead of dynamic (by default), as potential 
too many tags generated due to URI with dynamic values.

Reply via email to