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/08/29 09:24:28 UTC
[camel] 02/02: CAMEL-15481: camel-cluster - Should defer starting
routes if quickly elected leading during startup
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.git
commit 6a3935ec41c6ebe60f6df1213fce33d88b3a44b3
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Sat Aug 29 11:08:29 2020 +0200
CAMEL-15481: camel-cluster - Should defer starting routes if quickly elected leading during startup
---
.../apache/camel/impl/cluster/ClusteredRoutePolicy.java | 15 +++++++++++++++
1 file changed, 15 insertions(+)
diff --git a/core/camel-cluster/src/main/java/org/apache/camel/impl/cluster/ClusteredRoutePolicy.java b/core/camel-cluster/src/main/java/org/apache/camel/impl/cluster/ClusteredRoutePolicy.java
index 1d9106c..547fff8 100644
--- a/core/camel-cluster/src/main/java/org/apache/camel/impl/cluster/ClusteredRoutePolicy.java
+++ b/core/camel-cluster/src/main/java/org/apache/camel/impl/cluster/ClusteredRoutePolicy.java
@@ -65,6 +65,7 @@ public final class ClusteredRoutePolicy extends RoutePolicySupport implements Ca
private CamelClusterService clusterService;
private CamelClusterView clusterView;
private volatile boolean clusterViewAddListenerDone;
+ private volatile boolean startManagedRoutesEarly;
private Duration initialDelay;
private ScheduledExecutorService executorService;
@@ -251,6 +252,13 @@ public final class ClusteredRoutePolicy extends RoutePolicySupport implements Ca
}
private void doStartManagedRoutes() {
+ // if we are currently starting up Camel context then defer starting routes till its fully started
+ if (camelContext.isStarting()) {
+ LOG.debug("Will defer starting managed routes until camel context is fully started");
+ startManagedRoutesEarly = true;
+ return;
+ }
+
if (!isRunAllowed()) {
return;
}
@@ -318,6 +326,13 @@ public final class ClusteredRoutePolicy extends RoutePolicySupport implements Ca
// cluster view is not initialized yet, so lets add its listener in doStart
clusterViewAddListenerDone = false;
}
+
+ if (startManagedRoutesEarly) {
+ LOG.debug(
+ "CamelContext is now fully started, can now start managed routes eager as we were appointed leader during early startup");
+ startManagedRoutesEarly = false;
+ startManagedRoutes();
+ }
}
// ****************************************************