You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by da...@apache.org on 2020/03/16 13:31:18 UTC

[camel-spring-boot] branch master updated (8ec796b -> 0bed921)

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

davsclaus pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/camel-spring-boot.git.


    from 8ec796b  CAMEL-14642: camel-spring-boot - Using max duration and shutdown before should terminate scheduled thread quicker
     new c6c4c24  CAMEL-14642: camel-spring-boot - Using max duration and shutdown before should terminate scheduled thread quicker
     new 0bed921  CAMEL-14642: camel-spring-boot - Using max duration and shutdown before should terminate scheduled thread quicker

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .../org/apache/camel/spring/boot/CamelMainRunController.java |  4 ++++
 .../spring/boot/CamelSpringBootApplicationController.java    |  4 ++++
 .../spring/boot/CamelSpringBootApplicationListener.java      | 12 +++++++++---
 3 files changed, 17 insertions(+), 3 deletions(-)


[camel-spring-boot] 01/02: CAMEL-14642: camel-spring-boot - Using max duration and shutdown before should terminate scheduled thread quicker

Posted by da...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

davsclaus pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/camel-spring-boot.git

commit c6c4c24c49d49b7522e6a982423e81691a02bb3b
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Mon Mar 16 14:04:45 2020 +0100

    CAMEL-14642: camel-spring-boot - Using max duration and shutdown before should terminate scheduled thread quicker
---
 .../apache/camel/spring/boot/CamelSpringBootApplicationListener.java    | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/core/camel-spring-boot/src/main/java/org/apache/camel/spring/boot/CamelSpringBootApplicationListener.java b/core/camel-spring-boot/src/main/java/org/apache/camel/spring/boot/CamelSpringBootApplicationListener.java
index 8f6c5d0..325731f 100644
--- a/core/camel-spring-boot/src/main/java/org/apache/camel/spring/boot/CamelSpringBootApplicationListener.java
+++ b/core/camel-spring-boot/src/main/java/org/apache/camel/spring/boot/CamelSpringBootApplicationListener.java
@@ -247,6 +247,8 @@ public class CamelSpringBootApplicationListener implements ApplicationListener<C
                 // we are stopping then cancel the task so we can shutdown quicker
                 if (!running.get()) {
                     future.cancel(true);
+                    // trigger shutdown
+                    latch.countDown();
                 }
             }
         });


[camel-spring-boot] 02/02: CAMEL-14642: camel-spring-boot - Using max duration and shutdown before should terminate scheduled thread quicker

Posted by da...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

davsclaus pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/camel-spring-boot.git

commit 0bed921705f0cea05db7df03c765088f4b1ed27c
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Mon Mar 16 14:31:04 2020 +0100

    CAMEL-14642: camel-spring-boot - Using max duration and shutdown before should terminate scheduled thread quicker
---
 .../org/apache/camel/spring/boot/CamelMainRunController.java   |  4 ++++
 .../spring/boot/CamelSpringBootApplicationController.java      |  4 ++++
 .../camel/spring/boot/CamelSpringBootApplicationListener.java  | 10 +++++++---
 3 files changed, 15 insertions(+), 3 deletions(-)

diff --git a/core/camel-spring-boot/src/main/java/org/apache/camel/spring/boot/CamelMainRunController.java b/core/camel-spring-boot/src/main/java/org/apache/camel/spring/boot/CamelMainRunController.java
index 6a9771f..1eaeba6 100644
--- a/core/camel-spring-boot/src/main/java/org/apache/camel/spring/boot/CamelMainRunController.java
+++ b/core/camel-spring-boot/src/main/java/org/apache/camel/spring/boot/CamelMainRunController.java
@@ -43,6 +43,10 @@ public class CamelMainRunController {
         return controller.getLatch();
     }
 
+    public Runnable getMainCompleteTask() {
+        return controller.getMainCompletedTask();
+    }
+
     public AtomicBoolean getCompleted() {
         return controller.getCompleted();
     }
diff --git a/core/camel-spring-boot/src/main/java/org/apache/camel/spring/boot/CamelSpringBootApplicationController.java b/core/camel-spring-boot/src/main/java/org/apache/camel/spring/boot/CamelSpringBootApplicationController.java
index eacf037..38a208a 100644
--- a/core/camel-spring-boot/src/main/java/org/apache/camel/spring/boot/CamelSpringBootApplicationController.java
+++ b/core/camel-spring-boot/src/main/java/org/apache/camel/spring/boot/CamelSpringBootApplicationController.java
@@ -77,6 +77,10 @@ public class CamelSpringBootApplicationController {
         return this.latch;
     }
 
+    public Runnable getMainCompletedTask() {
+        return main.getCompleteTask();
+    }
+
     public AtomicBoolean getCompleted() {
         return completed;
     }
diff --git a/core/camel-spring-boot/src/main/java/org/apache/camel/spring/boot/CamelSpringBootApplicationListener.java b/core/camel-spring-boot/src/main/java/org/apache/camel/spring/boot/CamelSpringBootApplicationListener.java
index 325731f..dd79b26 100644
--- a/core/camel-spring-boot/src/main/java/org/apache/camel/spring/boot/CamelSpringBootApplicationListener.java
+++ b/core/camel-spring-boot/src/main/java/org/apache/camel/spring/boot/CamelSpringBootApplicationListener.java
@@ -120,7 +120,7 @@ public class CamelSpringBootApplicationListener implements ApplicationListener<C
                     if (configurationProperties.getDurationMaxSeconds() > 0) {
                         LOG.info("CamelSpringBoot will terminate after {} seconds", configurationProperties.getDurationMaxSeconds());
                         terminateMainControllerAfter(camelContext, configurationProperties.getDurationMaxSeconds(),
-                                controller.getCompleted(), controller.getLatch());
+                                controller.getCompleted(), controller.getLatch(), controller.getMainCompleteTask());
                     }
 
                     camelContext.addStartupListener(new StartupListener() {
@@ -218,7 +218,8 @@ public class CamelSpringBootApplicationListener implements ApplicationListener<C
 
     // Helpers
 
-    private void terminateMainControllerAfter(final CamelContext camelContext, int seconds, final AtomicBoolean completed, final CountDownLatch latch) {
+    private void terminateMainControllerAfter(final CamelContext camelContext, int seconds, final AtomicBoolean completed,
+                                              final CountDownLatch latch, final Runnable mainCompletedTask) {
         ScheduledExecutorService executorService = camelContext.getExecutorServiceManager().newSingleThreadScheduledExecutor(this, "CamelSpringBootTerminateTask");
 
         final AtomicBoolean running = new AtomicBoolean();
@@ -234,6 +235,7 @@ public class CamelSpringBootApplicationListener implements ApplicationListener<C
                 } finally {
                     completed.set(true);
                     latch.countDown();
+                    mainCompletedTask.run();
                 }
                 running.set(false);
             };
@@ -249,6 +251,7 @@ public class CamelSpringBootApplicationListener implements ApplicationListener<C
                     future.cancel(true);
                     // trigger shutdown
                     latch.countDown();
+                    mainCompletedTask.run();
                 }
             }
         });
@@ -282,7 +285,8 @@ public class CamelSpringBootApplicationListener implements ApplicationListener<C
         });
     }
 
-    private void terminateApplicationContext(final ConfigurableApplicationContext applicationContext, final CamelContext camelContext, final CountDownLatch latch) {
+    private void terminateApplicationContext(final ConfigurableApplicationContext applicationContext, final CamelContext camelContext,
+                                             final CountDownLatch latch) {
         ExecutorService executorService = camelContext.getExecutorServiceManager().newSingleThreadExecutor(this, "CamelSpringBootTerminateTask");
 
         final AtomicBoolean running = new AtomicBoolean();