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/25 06:18:20 UTC
[camel] branch main updated: CAMEL-17228: Route reload issue when using Kamelet EIP.
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 3193d01 CAMEL-17228: Route reload issue when using Kamelet EIP.
3193d01 is described below
commit 3193d01d2fc1da1714b0bedcf724247ff901415e
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Thu Nov 25 07:17:13 2021 +0100
CAMEL-17228: Route reload issue when using Kamelet EIP.
---
.../camel/support/RouteWatcherReloadStrategy.java | 10 +++---
.../org/apache/camel/main/KameletMainTest.java | 15 +++++++++
.../src/test/resources/my-camel-k.yaml | 36 ++++++++++++++++++++++
3 files changed, 55 insertions(+), 6 deletions(-)
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 3555d55..89e56b6 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
@@ -117,13 +117,11 @@ public class RouteWatcherReloadStrategy extends FileWatcherResourceReloadStrateg
try {
// should all existing routes be stopped and removed first?
if (removeAllRoutes) {
+ // first stop all routes
+ getCamelContext().getRouteController().stopAllRoutes();
+ // then remove all routes
for (Route route : getCamelContext().getRoutes()) {
- boolean stopped
- = getCamelContext().getRouteController().getRouteStatus(route.getRouteId()).isStopped();
- if (!stopped) {
- getCamelContext().getRouteController().stopRoute(route.getRouteId());
- getCamelContext().removeRoute(route.getRouteId());
- }
+ getCamelContext().removeRoute(route.getRouteId());
}
}
Set<String> ids
diff --git a/dsl/camel-kamelet-main/src/test/java/org/apache/camel/main/KameletMainTest.java b/dsl/camel-kamelet-main/src/test/java/org/apache/camel/main/KameletMainTest.java
index 2442d1d..2592e70 100644
--- a/dsl/camel-kamelet-main/src/test/java/org/apache/camel/main/KameletMainTest.java
+++ b/dsl/camel-kamelet-main/src/test/java/org/apache/camel/main/KameletMainTest.java
@@ -45,4 +45,19 @@ public class KameletMainTest {
main.run();
}
+
+ @Test
+ public void testReloadCamelK() throws Exception {
+ KameletMain main = new KameletMain();
+ main.setDownload(true);
+ main.configure().withShutdownTimeout(5);
+ main.configure().withDurationMaxMessages(10);
+ main.configure().withDurationMaxAction("stop");
+ main.configure().withRoutesIncludePattern("file:src/test/resources/my-camel-k.yaml");
+ main.configure().withRoutesReloadEnabled(true);
+ main.configure().withRoutesReloadDirectory("src/test/resources");
+ main.configure().withRoutesReloadPattern("my-camel-k.yaml");
+
+ main.run();
+ }
}
diff --git a/dsl/camel-kamelet-main/src/test/resources/my-camel-k.yaml b/dsl/camel-kamelet-main/src/test/resources/my-camel-k.yaml
new file mode 100644
index 0000000..60b805e
--- /dev/null
+++ b/dsl/camel-kamelet-main/src/test/resources/my-camel-k.yaml
@@ -0,0 +1,36 @@
+# ---------------------------------------------------------------------------
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+# ---------------------------------------------------------------------------
+
+apiVersion: camel.apache.org/v1
+kind: Integration
+metadata:
+ name: my-camel-k.yaml
+spec:
+ flows:
+ - from:
+ uri: "kamelet:timer-source"
+ parameters:
+ message: Hello Camel K
+ period: 1000
+ steps:
+# this works
+# - to: "kamelet:log-sink?showHeaders=false"
+ - kamelet:
+ name: log-sink
+ parameters:
+ showStreams: true
+ showHeaders: false