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 ea89079c200 camel-jbang - Add cmd for suspend/resume routes
ea89079c200 is described below
commit ea89079c2007c6c4ee64c62e12b0ef511c7d9401
Author: Claus Ibsen <[email protected]>
AuthorDate: Wed May 8 14:09:04 2024 +0200
camel-jbang - Add cmd for suspend/resume routes
---
.../camel/cli/connector/LocalCliConnector.java | 16 ++++++++--
.../dsl/jbang/core/commands/CamelJBangMain.java | 2 ++
.../commands/action/CamelRouteResumeAction.java | 36 ++++++++++++++++++++++
.../commands/action/CamelRouteSuspendAction.java | 36 ++++++++++++++++++++++
4 files changed, 88 insertions(+), 2 deletions(-)
diff --git
a/dsl/camel-cli-connector/src/main/java/org/apache/camel/cli/connector/LocalCliConnector.java
b/dsl/camel-cli-connector/src/main/java/org/apache/camel/cli/connector/LocalCliConnector.java
index 6f6521bb928..0a84c3294b3 100644
---
a/dsl/camel-cli-connector/src/main/java/org/apache/camel/cli/connector/LocalCliConnector.java
+++
b/dsl/camel-cli-connector/src/main/java/org/apache/camel/cli/connector/LocalCliConnector.java
@@ -771,9 +771,21 @@ public class LocalCliConnector extends ServiceSupport
implements CliConnector, C
camelContext.getRouteController().stopRoute(id);
}
} else if ("suspend".equals(command)) {
- camelContext.getRouteController().suspendRoute(id);
+ if ("*".equals(id)) {
+ for (Route r : camelContext.getRoutes()) {
+
camelContext.getRouteController().suspendRoute(r.getRouteId());
+ }
+ } else {
+ camelContext.getRouteController().suspendRoute(id);
+ }
} else if ("resume".equals(command)) {
- camelContext.getRouteController().resumeRoute(id);
+ if ("*".equals(id)) {
+ for (Route r : camelContext.getRoutes()) {
+
camelContext.getRouteController().resumeRoute(r.getRouteId());
+ }
+ } else {
+ camelContext.getRouteController().resumeRoute(id);
+ }
}
} catch (Exception e) {
// ignore
diff --git
a/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/CamelJBangMain.java
b/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/CamelJBangMain.java
index 934898d56f0..60844e1e3af 100644
---
a/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/CamelJBangMain.java
+++
b/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/CamelJBangMain.java
@@ -110,6 +110,8 @@ public class CamelJBangMain implements Callable<Integer> {
.addSubcommand("cmd", new CommandLine(new CamelAction(main))
.addSubcommand("start-route", new CommandLine(new
CamelRouteStartAction(main)))
.addSubcommand("stop-route", new CommandLine(new
CamelRouteStopAction(main)))
+ .addSubcommand("suspend-route", new CommandLine(new
CamelRouteSuspendAction(main)))
+ .addSubcommand("resume-route", new CommandLine(new
CamelRouteResumeAction(main)))
.addSubcommand("reset-stats", new CommandLine(new
CamelResetStatsAction(main)))
.addSubcommand("reload", new CommandLine(new
CamelReloadAction(main)))
.addSubcommand("send", new CommandLine(new
CamelSendAction(main)))
diff --git
a/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/action/CamelRouteResumeAction.java
b/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/action/CamelRouteResumeAction.java
new file mode 100644
index 00000000000..404060e6534
--- /dev/null
+++
b/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/action/CamelRouteResumeAction.java
@@ -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.
+ */
+package org.apache.camel.dsl.jbang.core.commands.action;
+
+import org.apache.camel.dsl.jbang.core.commands.CamelJBangMain;
+import org.apache.camel.util.json.JsonObject;
+import picocli.CommandLine;
+
[email protected](name = "resume-route",
+ description = "Resume Camel routes", sortOptions = false)
+public class CamelRouteResumeAction extends CamelRouteAction {
+
+ public CamelRouteResumeAction(CamelJBangMain main) {
+ super(main);
+ }
+
+ @Override
+ protected void onAction(JsonObject root) {
+ root.put("command", "resume");
+ }
+
+}
diff --git
a/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/action/CamelRouteSuspendAction.java
b/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/action/CamelRouteSuspendAction.java
new file mode 100644
index 00000000000..7f458ca539f
--- /dev/null
+++
b/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/action/CamelRouteSuspendAction.java
@@ -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.
+ */
+package org.apache.camel.dsl.jbang.core.commands.action;
+
+import org.apache.camel.dsl.jbang.core.commands.CamelJBangMain;
+import org.apache.camel.util.json.JsonObject;
+import picocli.CommandLine;
+
[email protected](name = "suspend-route",
+ description = "Suspend Camel routes", sortOptions = false)
+public class CamelRouteSuspendAction extends CamelRouteAction {
+
+ public CamelRouteSuspendAction(CamelJBangMain main) {
+ super(main);
+ }
+
+ @Override
+ protected void onAction(JsonObject root) {
+ root.put("command", "suspend");
+ }
+
+}