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 2021/11/23 09:24:04 UTC
[camel] 04/08: CAMEL-17223: camel-main - durationMaxAction to control whether to shutdown or stop all routes.
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
commit 352483bda8d30f182c13018168cced33bc4e94c7
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Mon Nov 22 16:02:47 2021 +0100
CAMEL-17223: camel-main - durationMaxAction to control whether to shutdown or stop all routes.
---
.../java/org/apache/camel/impl/engine/AbstractCamelContext.java | 5 ++++-
.../java/org/apache/camel/support/RouteWatcherReloadStrategy.java | 8 ++++++--
2 files changed, 10 insertions(+), 3 deletions(-)
diff --git a/core/camel-base-engine/src/main/java/org/apache/camel/impl/engine/AbstractCamelContext.java b/core/camel-base-engine/src/main/java/org/apache/camel/impl/engine/AbstractCamelContext.java
index db84220..bc5b795 100644
--- a/core/camel-base-engine/src/main/java/org/apache/camel/impl/engine/AbstractCamelContext.java
+++ b/core/camel-base-engine/src/main/java/org/apache/camel/impl/engine/AbstractCamelContext.java
@@ -1199,7 +1199,10 @@ public abstract class AbstractCamelContext extends BaseService
}
public void stopAllRoutes() throws Exception {
- // TODO: implement me
+ // stop all routes
+ if (shutdownStrategy != null) {
+ shutdownStrategy.shutdown(this, getRouteStartupOrder());
+ }
}
public synchronized void startRoute(String routeId) throws Exception {
diff --git a/core/camel-support/src/main/java/org/apache/camel/support/RouteWatcherReloadStrategy.java b/core/camel-support/src/main/java/org/apache/camel/support/RouteWatcherReloadStrategy.java
index 7007540..3555d55 100644
--- a/core/camel-support/src/main/java/org/apache/camel/support/RouteWatcherReloadStrategy.java
+++ b/core/camel-support/src/main/java/org/apache/camel/support/RouteWatcherReloadStrategy.java
@@ -118,8 +118,12 @@ public class RouteWatcherReloadStrategy extends FileWatcherResourceReloadStrateg
// should all existing routes be stopped and removed first?
if (removeAllRoutes) {
for (Route route : getCamelContext().getRoutes()) {
- getCamelContext().getRouteController().stopRoute(route.getRouteId());
- getCamelContext().removeRoute(route.getRouteId());
+ boolean stopped
+ = getCamelContext().getRouteController().getRouteStatus(route.getRouteId()).isStopped();
+ if (!stopped) {
+ getCamelContext().getRouteController().stopRoute(route.getRouteId());
+ getCamelContext().removeRoute(route.getRouteId());
+ }
}
}
Set<String> ids