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 2022/08/26 10:37:02 UTC

[camel] branch main updated (d65dbfd9c0d -> fa5a437e289)

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

davsclaus pushed a change to branch main
in repository https://gitbox.apache.org/repos/asf/camel.git


    from d65dbfd9c0d Revert "Maven surefire issue SUREFIRE-1831 is resolved, so bump surefire and failsafe to the latest version"
     new 19b05ef70b0 CAMEL-18425: camel-cli - Make regular Camel applications work with Camel CLI
     new 463899970d7 CAMEL-18430: Added unit test
     new 462c4e8ff30 CAMEL-18425: camel-cli - Make regular Camel applications work with Camel CLI
     new fa5a437e289 CAMEL-18425: camel-cli - Make regular Camel applications work with Camel CLI

The 4 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/spi/CliConnectorFactory.java  |  10 ++
 .../camel/impl/engine/SimpleCamelContext.java      |   6 +
 .../EnricherLambdaAggregateTest.java}              |  20 +--
 .../EnricherLambdaPojoAggregateTest.java}          |  21 ++--
 .../modules/ROOT/pages/camel-jbang.adoc            |  50 ++++----
 .../cli/connector/DefaultCliConnectorFactory.java  |  11 ++
 .../camel/cli/connector/LocalCliConnector.java     |  14 ++-
 .../core/commands/process/CamelContextStatus.java  | 103 +++++++---------
 .../core/commands/process/CamelRouteStatus.java    | 134 +++++++++------------
 .../jbang/core/commands/process/ListProcess.java   |  62 ++++++----
 .../core/commands/process/ProcessBaseCommand.java  | 120 ++++++++++++++----
 11 files changed, 325 insertions(+), 226 deletions(-)
 copy core/camel-core/src/test/java/org/apache/camel/processor/{aggregator/AggregateStrategyServiceTest.java => enricher/EnricherLambdaAggregateTest.java} (67%)
 copy core/camel-core/src/test/java/org/apache/camel/processor/{aggregator/AggregateStrategyServiceTest.java => enricher/EnricherLambdaPojoAggregateTest.java} (68%)


[camel] 02/04: CAMEL-18430: Added unit test

Posted by da...@apache.org.
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 463899970d7baa92549bf83c03f25182bf89588a
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Fri Aug 26 09:45:24 2022 +0200

    CAMEL-18430: Added unit test
---
 .../enricher/EnricherLambdaAggregateTest.java      | 52 +++++++++++++++++++++
 .../enricher/EnricherLambdaPojoAggregateTest.java  | 53 ++++++++++++++++++++++
 2 files changed, 105 insertions(+)

diff --git a/core/camel-core/src/test/java/org/apache/camel/processor/enricher/EnricherLambdaAggregateTest.java b/core/camel-core/src/test/java/org/apache/camel/processor/enricher/EnricherLambdaAggregateTest.java
new file mode 100644
index 00000000000..7ed69ce435d
--- /dev/null
+++ b/core/camel-core/src/test/java/org/apache/camel/processor/enricher/EnricherLambdaAggregateTest.java
@@ -0,0 +1,52 @@
+/*
+ * 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.processor.enricher;
+
+import org.apache.camel.ContextTestSupport;
+import org.apache.camel.builder.RouteBuilder;
+import org.junit.jupiter.api.Test;
+
+public class EnricherLambdaAggregateTest extends ContextTestSupport {
+
+    @Test
+    public void testEnrich() throws Exception {
+        getMockEndpoint("mock:result").expectedBodiesReceived("A+B");
+
+        template.sendBody("direct:start", "A");
+
+        assertMockEndpointsSatisfied();
+    }
+
+    @Override
+    protected RouteBuilder createRouteBuilder() throws Exception {
+        return new RouteBuilder() {
+            @Override
+            public void configure() throws Exception {
+                from("direct:start")
+                        .enrich("direct:b", (e1, e2) -> {
+                            String b = e1.getMessage().getBody(String.class) + "+" + e2.getMessage().getBody(String.class);
+                            e1.getMessage().setBody(b);
+                            return e1;
+                        })
+                        .to("mock:result");
+
+                from("direct:b").setBody(constant("B"));
+            }
+        };
+    }
+
+}
diff --git a/core/camel-core/src/test/java/org/apache/camel/processor/enricher/EnricherLambdaPojoAggregateTest.java b/core/camel-core/src/test/java/org/apache/camel/processor/enricher/EnricherLambdaPojoAggregateTest.java
new file mode 100644
index 00000000000..b558940d7ce
--- /dev/null
+++ b/core/camel-core/src/test/java/org/apache/camel/processor/enricher/EnricherLambdaPojoAggregateTest.java
@@ -0,0 +1,53 @@
+/*
+ * 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.processor.enricher;
+
+import org.apache.camel.ContextTestSupport;
+import org.apache.camel.builder.AggregationStrategies;
+import org.apache.camel.builder.RouteBuilder;
+import org.junit.jupiter.api.Test;
+
+public class EnricherLambdaPojoAggregateTest extends ContextTestSupport {
+
+    @Test
+    public void testEnrich() throws Exception {
+        getMockEndpoint("mock:result").expectedBodiesReceived("A+B");
+
+        template.sendBody("direct:start", "A");
+
+        assertMockEndpointsSatisfied();
+    }
+
+    @Override
+    protected RouteBuilder createRouteBuilder() throws Exception {
+        return new RouteBuilder() {
+            @Override
+            public void configure() throws Exception {
+                from("direct:start")
+                        .enrich("direct:b", AggregationStrategies.bean(EnricherLambdaPojoAggregateTest.class, "merge"))
+                        .to("mock:result");
+
+                from("direct:b").setBody(constant("B"));
+            }
+        };
+    }
+
+    public String merge(String a, String b) {
+        return a + "+" + b;
+    }
+
+}


[camel] 03/04: CAMEL-18425: camel-cli - Make regular Camel applications work with Camel CLI

Posted by da...@apache.org.
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 462c4e8ff30a1fca46c1ba6d3e5b75d7c2d70c61
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Fri Aug 26 12:30:07 2022 +0200

    CAMEL-18425: camel-cli - Make regular Camel applications work with Camel CLI
---
 .../org/apache/camel/spi/CliConnectorFactory.java  |  10 ++
 .../cli/connector/DefaultCliConnectorFactory.java  |  11 ++
 .../camel/cli/connector/LocalCliConnector.java     |  12 +-
 .../core/commands/process/CamelContextStatus.java  | 101 +++++++---------
 .../core/commands/process/CamelRouteStatus.java    | 134 +++++++++------------
 .../jbang/core/commands/process/ListProcess.java   |  62 ++++++----
 .../core/commands/process/ProcessBaseCommand.java  |  84 +++++++++++--
 7 files changed, 240 insertions(+), 174 deletions(-)

diff --git a/core/camel-api/src/main/java/org/apache/camel/spi/CliConnectorFactory.java b/core/camel-api/src/main/java/org/apache/camel/spi/CliConnectorFactory.java
index 6d34675eace..ef323b6025d 100644
--- a/core/camel-api/src/main/java/org/apache/camel/spi/CliConnectorFactory.java
+++ b/core/camel-api/src/main/java/org/apache/camel/spi/CliConnectorFactory.java
@@ -60,6 +60,16 @@ public interface CliConnectorFactory {
      */
     String getRuntimeVersion();
 
+    /**
+     * The main class used by the runtime to start.
+     */
+    void setRuntimeStartClass(String className);
+
+    /**
+     * The main class used by the runtime to start.
+     */
+    String getRuntimeStartClass();
+
     /**
      * Creates the connector which will be added as a {@link Service} to {@link org.apache.camel.CamelContext} as the
      * lifecycle to start and stop the connector.
diff --git a/dsl/camel-cli-connector/src/main/java/org/apache/camel/cli/connector/DefaultCliConnectorFactory.java b/dsl/camel-cli-connector/src/main/java/org/apache/camel/cli/connector/DefaultCliConnectorFactory.java
index 07f59815f6e..2f70726cbf0 100644
--- a/dsl/camel-cli-connector/src/main/java/org/apache/camel/cli/connector/DefaultCliConnectorFactory.java
+++ b/dsl/camel-cli-connector/src/main/java/org/apache/camel/cli/connector/DefaultCliConnectorFactory.java
@@ -26,6 +26,7 @@ public class DefaultCliConnectorFactory implements CliConnectorFactory {
     private boolean enabled = true;
     private String runtime;
     private String runtimeVersion;
+    private String runtimeStartClass;
 
     @Override
     public boolean isEnabled() {
@@ -55,6 +56,16 @@ public class DefaultCliConnectorFactory implements CliConnectorFactory {
         this.runtimeVersion = runtimeVersion;
     }
 
+    @Override
+    public String getRuntimeStartClass() {
+        return runtimeStartClass;
+    }
+
+    @Override
+    public void setRuntimeStartClass(String runtimeStartClass) {
+        this.runtimeStartClass = runtimeStartClass;
+    }
+
     @Override
     public Service createConnector() {
         if (enabled) {
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 60500113d95..34fbb5a62ff 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
@@ -49,6 +49,7 @@ public class LocalCliConnector extends ServiceSupport implements CamelContextAwa
     private int delay = 2000;
     private String platform;
     private String platformVersion;
+    private String mainClass;
     private ScheduledExecutorService executor;
     private File lockFile;
     private File statusFile;
@@ -76,10 +77,11 @@ public class LocalCliConnector extends ServiceSupport implements CamelContextAwa
         if (lockFile != null) {
             statusFile = createLockFile(lockFile.getName() + "-status.json");
         }
-        executor.scheduleWithFixedDelay(this::statusTask, 1000, delay, TimeUnit.MILLISECONDS);
+        executor.scheduleWithFixedDelay(this::statusTask, 0, delay, TimeUnit.MILLISECONDS);
 
         // what platform are we running
         CliConnectorFactory ccf = camelContext.adapt(ExtendedCamelContext.class).getCliConnectorFactory();
+        mainClass = ccf.getRuntimeStartClass();
         platform = ccf.getRuntime();
         if (platform == null) {
             // use camel context name to guess platform if not specified
@@ -125,10 +127,18 @@ public class LocalCliConnector extends ServiceSupport implements CamelContextAwa
 
             // what runtime are in use
             JsonObject rc = new JsonObject();
+            String dir = new File(".").getAbsolutePath();
+            dir = FileUtil.onlyPath(dir);
+            rc.put("pid", ProcessHandle.current().pid());
+            rc.put("directory", dir);
+            ProcessHandle.current().info().user().ifPresent(u -> rc.put("user", u));
             rc.put("platform", platform);
             if (platformVersion != null) {
                 rc.put("version", platformVersion);
             }
+            if (mainClass != null) {
+                rc.put("mainClass", mainClass);
+            }
             root.put("runtime", rc);
 
             // collect details via console
diff --git a/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/process/CamelContextStatus.java b/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/process/CamelContextStatus.java
index 64edfda5faf..9e43658d841 100644
--- a/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/process/CamelContextStatus.java
+++ b/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/process/CamelContextStatus.java
@@ -16,8 +16,6 @@
  */
 package org.apache.camel.dsl.jbang.core.commands.process;
 
-import java.io.File;
-import java.io.FileInputStream;
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.List;
@@ -29,12 +27,8 @@ import com.github.freva.asciitable.Column;
 import com.github.freva.asciitable.HorizontalAlign;
 import com.github.freva.asciitable.OverflowBehaviour;
 import org.apache.camel.dsl.jbang.core.commands.CamelJBangMain;
-import org.apache.camel.util.IOHelper;
-import org.apache.camel.util.ObjectHelper;
-import org.apache.camel.util.StringHelper;
 import org.apache.camel.util.TimeUtils;
 import org.apache.camel.util.json.JsonObject;
-import org.apache.camel.util.json.Jsoner;
 import picocli.CommandLine;
 import picocli.CommandLine.Command;
 
@@ -60,50 +54,40 @@ public class CamelContextStatus extends ProcessBaseCommand {
         List<Long> pids = findPids(name);
         ProcessHandle.allProcesses()
                 .filter(ph -> pids.contains(ph.pid()))
-                .sorted((o1, o2) -> {
-                    switch (sort) {
-                        case "pid":
-                            return Long.compare(o1.pid(), o2.pid());
-                        case "name":
-                            return extractName(o1).compareTo(extractName(o2));
-                        case "age":
-                            // we want newest in top
-                            return Long.compare(extractSince(o1), extractSince(o2)) * -1;
-                        default:
-                            return 0;
-                    }
-                })
                 .forEach(ph -> {
-                    Row row = new Row();
-                    row.name = extractName(ph);
-                    if (ObjectHelper.isNotEmpty(row.name)) {
+                    JsonObject root = loadStatus(ph.pid());
+                    // there must be a status file for the running Camel integration
+                    if (root != null) {
+                        Row row = new Row();
+                        row.name = extractName(root, ph);
                         row.pid = "" + ph.pid();
-                        row.ago = TimeUtils.printSince(extractSince(ph));
-                        JsonObject root = loadStatus(ph.pid());
-                        if (root != null) {
-                            JsonObject runtime = (JsonObject) root.get("runtime");
-                            row.platform = runtime != null ? runtime.getString("platform") : null;
-                            row.platformVersion = runtime != null ? runtime.getString("version") : null;
-                            JsonObject context = (JsonObject) root.get("context");
-                            row.state = context.getString("state").toLowerCase(Locale.ROOT);
-                            row.camelVersion = context.getString("version");
-                            Map<String, ?> stats = context.getMap("statistics");
-                            if (stats != null) {
-                                row.total = stats.get("exchangesTotal").toString();
-                                row.inflight = stats.get("exchangesInflight").toString();
-                                row.failed = stats.get("exchangesFailed").toString();
-                                Object last = stats.get("sinceLastExchange");
-                                if (last != null) {
-                                    row.sinceLast = last.toString();
-                                }
+                        row.uptime = extractSince(ph);
+                        row.ago = TimeUtils.printSince(row.uptime);
+                        JsonObject runtime = (JsonObject) root.get("runtime");
+                        row.platform = runtime != null ? runtime.getString("platform") : null;
+                        row.platformVersion = runtime != null ? runtime.getString("version") : null;
+                        JsonObject context = (JsonObject) root.get("context");
+                        row.state = context.getString("state").toLowerCase(Locale.ROOT);
+                        row.camelVersion = context.getString("version");
+                        Map<String, ?> stats = context.getMap("statistics");
+                        if (stats != null) {
+                            row.total = stats.get("exchangesTotal").toString();
+                            row.inflight = stats.get("exchangesInflight").toString();
+                            row.failed = stats.get("exchangesFailed").toString();
+                            Object last = stats.get("sinceLastExchange");
+                            if (last != null) {
+                                row.sinceLast = last.toString();
                             }
-                            JsonObject hc = (JsonObject) root.get("healthChecks");
-                            row.ready = hc != null ? hc.getString("ready") + "/" + hc.getString("total") : null;
                         }
+                        JsonObject hc = (JsonObject) root.get("healthChecks");
+                        row.ready = hc != null ? hc.getString("ready") + "/" + hc.getString("total") : null;
                         rows.add(row);
                     }
                 });
 
+        // sort rows
+        rows.sort(this::sortRow);
+
         if (!rows.isEmpty()) {
             System.out.println(AsciiTable.getTable(AsciiTable.NO_BORDERS, rows, Arrays.asList(
                     new Column().header("PID").headerAlign(HorizontalAlign.CENTER).with(r -> r.pid),
@@ -112,8 +96,8 @@ public class CamelContextStatus extends ProcessBaseCommand {
                     new Column().header("CAMEL").dataAlign(HorizontalAlign.LEFT).with(r -> r.camelVersion),
                     new Column().header("PLATFORM").dataAlign(HorizontalAlign.LEFT).with(this::getPlatform),
                     new Column().header("READY").dataAlign(HorizontalAlign.CENTER).with(r -> r.ready),
-                    new Column().header("STATE").headerAlign(HorizontalAlign.CENTER)
-                            .with(r -> StringHelper.capitalize(r.state)),
+                    new Column().header("STATUS").headerAlign(HorizontalAlign.CENTER)
+                            .with(r -> extractState(r.state)),
                     new Column().header("AGE").headerAlign(HorizontalAlign.CENTER).with(r -> r.ago),
                     new Column().header("TOTAL").with(r -> r.total),
                     new Column().header("FAILED").with(r -> r.failed),
@@ -124,6 +108,19 @@ public class CamelContextStatus extends ProcessBaseCommand {
         return 0;
     }
 
+    protected int sortRow(Row o1, Row o2) {
+        switch (sort) {
+            case "pid":
+                return Long.compare(Long.parseLong(o1.pid), Long.parseLong(o2.pid));
+            case "name":
+                return o1.name.compareToIgnoreCase(o2.name);
+            case "age":
+                return Long.compare(o1.uptime, o2.uptime);
+            default:
+                return 0;
+        }
+    }
+
     private String getPlatform(Row r) {
         if (r.platformVersion != null) {
             return r.platform + " v" + r.platformVersion;
@@ -132,21 +129,6 @@ public class CamelContextStatus extends ProcessBaseCommand {
         }
     }
 
-    private JsonObject loadStatus(long pid) {
-        try {
-            File f = getStatusFile("" + pid);
-            if (f != null) {
-                FileInputStream fis = new FileInputStream(f);
-                String text = IOHelper.loadText(fis);
-                IOHelper.close(fis);
-                return (JsonObject) Jsoner.deserialize(text);
-            }
-        } catch (Throwable e) {
-            // ignore
-        }
-        return null;
-    }
-
     private static class Row {
         String pid;
         String platform;
@@ -156,6 +138,7 @@ public class CamelContextStatus extends ProcessBaseCommand {
         String ready;
         String state;
         String ago;
+        long uptime;
         String total;
         String failed;
         String inflight;
diff --git a/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/process/CamelRouteStatus.java b/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/process/CamelRouteStatus.java
index 62267d0efca..9bcdf49c06d 100644
--- a/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/process/CamelRouteStatus.java
+++ b/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/process/CamelRouteStatus.java
@@ -16,8 +16,6 @@
  */
 package org.apache.camel.dsl.jbang.core.commands.process;
 
-import java.io.File;
-import java.io.FileInputStream;
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.List;
@@ -30,12 +28,10 @@ import com.github.freva.asciitable.HorizontalAlign;
 import com.github.freva.asciitable.OverflowBehaviour;
 import org.apache.camel.dsl.jbang.core.commands.CamelJBangMain;
 import org.apache.camel.util.FileUtil;
-import org.apache.camel.util.IOHelper;
-import org.apache.camel.util.ObjectHelper;
 import org.apache.camel.util.StringHelper;
+import org.apache.camel.util.TimeUtils;
 import org.apache.camel.util.json.JsonArray;
 import org.apache.camel.util.json.JsonObject;
-import org.apache.camel.util.json.Jsoner;
 import picocli.CommandLine;
 import picocli.CommandLine.Command;
 
@@ -68,63 +64,49 @@ public class CamelRouteStatus extends ProcessBaseCommand {
         List<Long> pids = findPids(name);
         ProcessHandle.allProcesses()
                 .filter(ph -> pids.contains(ph.pid()))
-                .sorted((o1, o2) -> {
-                    switch (sort) {
-                        case "pid":
-                            return Long.compare(o1.pid(), o2.pid());
-                        case "name":
-                            return extractName(o1).compareTo(extractName(o2));
-                        case "age":
-                            // we want newest in top
-                            return Long.compare(extractSince(o1), extractSince(o2)) * -1;
-                        default:
-                            return 0;
-                    }
-                })
                 .forEach(ph -> {
-                    String name = extractName(ph);
-                    if (ObjectHelper.isNotEmpty(name)) {
-                        JsonObject status = loadStatus(ph.pid());
-                        if (status != null) {
-                            JsonArray array = (JsonArray) status.get("routes");
-                            for (int i = 0; i < array.size(); i++) {
-                                JsonObject o = (JsonObject) array.get(i);
-                                Row row = new Row();
-                                row.pid = "" + ph.pid();
-                                row.name = name;
-                                row.routeId = o.getString("routeId");
-                                row.from = o.getString("from");
-                                row.source = o.getString("source");
-                                row.state = o.getString("state").toLowerCase(Locale.ROOT);
-                                row.uptime = o.getString("uptime");
-                                Map<String, ?> stats = o.getMap("statistics");
-                                if (stats != null) {
-                                    row.total = stats.get("exchangesTotal").toString();
-                                    row.inflight = stats.get("exchangesInflight").toString();
-                                    row.failed = stats.get("exchangesFailed").toString();
-                                    row.mean = stats.get("meanProcessingTime").toString();
-                                    if ("-1".equals(row.mean)) {
-                                        row.mean = null;
-                                    }
-                                    row.max = stats.get("maxProcessingTime").toString();
-                                    row.min = stats.get("minProcessingTime").toString();
-                                    Object last = stats.get("sinceLastExchange");
-                                    if (last != null) {
-                                        row.sinceLast = last.toString();
-                                    }
-                                }
-
-                                boolean add = true;
-                                if (mean > 0 && row.mean != null && Long.parseLong(row.mean) < mean) {
-                                    add = false;
-                                }
-                                if (limit > 0 && rows.size() >= limit) {
-                                    add = false;
+                    JsonObject root = loadStatus(ph.pid());
+                    if (root != null) {
+                        String name = extractName(root, ph);
+                        JsonArray array = (JsonArray) root.get("routes");
+                        for (int i = 0; i < array.size(); i++) {
+                            JsonObject o = (JsonObject) array.get(i);
+                            Row row = new Row();
+                            row.name = name;
+                            row.pid = "" + ph.pid();
+                            row.routeId = o.getString("routeId");
+                            row.from = o.getString("from");
+                            row.source = o.getString("source");
+                            row.state = o.getString("state").toLowerCase(Locale.ROOT);
+                            row.age = o.getString("uptime");
+                            row.uptime = row.age != null ? TimeUtils.toMilliSeconds(row.age) : 0;
+                            Map<String, ?> stats = o.getMap("statistics");
+                            if (stats != null) {
+                                row.total = stats.get("exchangesTotal").toString();
+                                row.inflight = stats.get("exchangesInflight").toString();
+                                row.failed = stats.get("exchangesFailed").toString();
+                                row.mean = stats.get("meanProcessingTime").toString();
+                                if ("-1".equals(row.mean)) {
+                                    row.mean = null;
                                 }
-                                if (add) {
-                                    rows.add(row);
+                                row.max = stats.get("maxProcessingTime").toString();
+                                row.min = stats.get("minProcessingTime").toString();
+                                Object last = stats.get("sinceLastExchange");
+                                if (last != null) {
+                                    row.sinceLast = last.toString();
                                 }
                             }
+
+                            boolean add = true;
+                            if (mean > 0 && row.mean != null && Long.parseLong(row.mean) < mean) {
+                                add = false;
+                            }
+                            if (limit > 0 && rows.size() >= limit) {
+                                add = false;
+                            }
+                            if (add) {
+                                rows.add(row);
+                            }
                         }
                     }
                 });
@@ -143,9 +125,9 @@ public class CamelRouteStatus extends ProcessBaseCommand {
                             .with(r -> r.routeId),
                     new Column().header("FROM").dataAlign(HorizontalAlign.LEFT).maxWidth(40, OverflowBehaviour.ELLIPSIS)
                             .with(r -> r.from),
-                    new Column().header("STATE").headerAlign(HorizontalAlign.CENTER)
-                            .with(r -> StringHelper.capitalize(r.state)),
-                    new Column().header("AGE").headerAlign(HorizontalAlign.CENTER).with(r -> r.uptime),
+                    new Column().header("STATUS").headerAlign(HorizontalAlign.CENTER)
+                            .with(r -> extractState(r.state)),
+                    new Column().header("AGE").headerAlign(HorizontalAlign.CENTER).with(r -> r.age),
                     new Column().header("TOTAL").with(r -> r.total),
                     new Column().header("FAILED").with(r -> r.failed),
                     new Column().header("INFLIGHT").with(r -> r.inflight),
@@ -158,21 +140,6 @@ public class CamelRouteStatus extends ProcessBaseCommand {
         return 0;
     }
 
-    private JsonObject loadStatus(long pid) {
-        try {
-            File f = getStatusFile("" + pid);
-            if (f != null) {
-                FileInputStream fis = new FileInputStream(f);
-                String text = IOHelper.loadText(fis);
-                IOHelper.close(fis);
-                return (JsonObject) Jsoner.deserialize(text);
-            }
-        } catch (Throwable e) {
-            // ignore
-        }
-        return null;
-    }
-
     protected String sourceLocLine(String location) {
         while (StringHelper.countChar(location, ':') > 1) {
             location = location.substring(location.indexOf(':') + 1);
@@ -190,18 +157,27 @@ public class CamelRouteStatus extends ProcessBaseCommand {
     }
 
     protected int sortRow(Row o1, Row o2) {
-        // no sort by default
-        return 0;
+        switch (sort) {
+            case "pid":
+                return Long.compare(Long.parseLong(o1.pid), Long.parseLong(o2.pid));
+            case "name":
+                return o1.name.compareToIgnoreCase(o2.name);
+            case "age":
+                return Long.compare(o1.uptime, o2.uptime);
+            default:
+                return 0;
+        }
     }
 
     static class Row {
         String pid;
         String name;
+        long uptime;
         String routeId;
         String from;
         String source;
-        String uptime;
         String state;
+        String age;
         String total;
         String failed;
         String inflight;
diff --git a/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/process/ListProcess.java b/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/process/ListProcess.java
index cb1046c55c8..0c00c56ddaf 100644
--- a/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/process/ListProcess.java
+++ b/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/process/ListProcess.java
@@ -19,14 +19,15 @@ package org.apache.camel.dsl.jbang.core.commands.process;
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.List;
+import java.util.Locale;
 
 import com.github.freva.asciitable.AsciiTable;
 import com.github.freva.asciitable.Column;
 import com.github.freva.asciitable.HorizontalAlign;
 import com.github.freva.asciitable.OverflowBehaviour;
 import org.apache.camel.dsl.jbang.core.commands.CamelJBangMain;
-import org.apache.camel.util.ObjectHelper;
 import org.apache.camel.util.TimeUtils;
+import org.apache.camel.util.json.JsonObject;
 import picocli.CommandLine;
 import picocli.CommandLine.Command;
 
@@ -45,47 +46,62 @@ public class ListProcess extends ProcessBaseCommand {
     public Integer call() throws Exception {
         List<Row> rows = new ArrayList<>();
 
-        final long cur = ProcessHandle.current().pid();
+        List<Long> pids = findPids("*");
         ProcessHandle.allProcesses()
-                .filter(ph -> ph.pid() != cur)
-                .sorted((o1, o2) -> {
-                    switch (sort) {
-                        case "pid":
-                            return Long.compare(o1.pid(), o2.pid());
-                        case "name":
-                            return extractName(o1).compareTo(extractName(o2));
-                        case "age":
-                            // we want newest in top
-                            return Long.compare(extractSince(o1), extractSince(o2)) * -1;
-                        default:
-                            return 0;
-                    }
-                })
+                .filter(ph -> pids.contains(ph.pid()))
                 .forEach(ph -> {
-                    Row row = new Row();
-                    row.name = extractName(ph);
-                    if (ObjectHelper.isNotEmpty(row.name)) {
+                    JsonObject root = loadStatus(ph.pid());
+                    if (root != null) {
+                        Row row = new Row();
+                        row.name = extractName(root, ph);
                         row.pid = "" + ph.pid();
-                        row.age = TimeUtils.printSince(extractSince(ph));
+                        row.uptime = extractSince(ph);
+                        row.ago = TimeUtils.printSince(row.uptime);
+                        JsonObject context = (JsonObject) root.get("context");
+                        row.state = context.getString("state").toLowerCase(Locale.ROOT);
+                        JsonObject hc = (JsonObject) root.get("healthChecks");
+                        row.ready = hc != null ? hc.getString("ready") + "/" + hc.getString("total") : null;
                         rows.add(row);
                     }
                 });
 
+        // sort rows
+        rows.sort(this::sortRow);
+
         if (!rows.isEmpty()) {
             System.out.println(AsciiTable.getTable(AsciiTable.NO_BORDERS, rows, Arrays.asList(
                     new Column().header("PID").headerAlign(HorizontalAlign.CENTER).with(r -> r.pid),
-                    new Column().header("NAME").dataAlign(HorizontalAlign.LEFT).maxWidth(40, OverflowBehaviour.ELLIPSIS)
+                    new Column().header("NAME").dataAlign(HorizontalAlign.LEFT).maxWidth(30, OverflowBehaviour.ELLIPSIS)
                             .with(r -> r.name),
-                    new Column().header("AGE").headerAlign(HorizontalAlign.CENTER).with(r -> r.age))));
+                    new Column().header("READY").dataAlign(HorizontalAlign.CENTER).with(r -> r.ready),
+                    new Column().header("STATUS").headerAlign(HorizontalAlign.CENTER)
+                            .with(r -> extractState(r.state)),
+                    new Column().header("AGE").headerAlign(HorizontalAlign.CENTER).with(r -> r.ago))));
         }
 
         return 0;
     }
 
+    protected int sortRow(Row o1, Row o2) {
+        switch (sort) {
+            case "pid":
+                return Long.compare(Long.parseLong(o1.pid), Long.parseLong(o2.pid));
+            case "name":
+                return o1.name.compareToIgnoreCase(o2.name);
+            case "age":
+                return Long.compare(o1.uptime, o2.uptime);
+            default:
+                return 0;
+        }
+    }
+
     private static class Row {
         String pid;
         String name;
-        String age;
+        String ready;
+        String state;
+        String ago;
+        long uptime;
     }
 
 }
diff --git a/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/process/ProcessBaseCommand.java b/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/process/ProcessBaseCommand.java
index 14075f5f92e..222774f586b 100644
--- a/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/process/ProcessBaseCommand.java
+++ b/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/process/ProcessBaseCommand.java
@@ -16,6 +16,8 @@
  */
 package org.apache.camel.dsl.jbang.core.commands.process;
 
+import java.io.File;
+import java.io.FileInputStream;
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.List;
@@ -27,7 +29,10 @@ import org.apache.camel.dsl.jbang.core.commands.CamelCommand;
 import org.apache.camel.dsl.jbang.core.commands.CamelJBangMain;
 import org.apache.camel.support.PatternHelper;
 import org.apache.camel.util.FileUtil;
+import org.apache.camel.util.IOHelper;
 import org.apache.camel.util.StringHelper;
+import org.apache.camel.util.json.JsonObject;
+import org.apache.camel.util.json.Jsoner;
 
 abstract class ProcessBaseCommand extends CamelCommand {
 
@@ -38,7 +43,7 @@ abstract class ProcessBaseCommand extends CamelCommand {
         super(main);
     }
 
-    static List<Long> findPids(String name) {
+    List<Long> findPids(String name) {
         List<Long> pids = new ArrayList<>();
 
         // we need to know the pids of the running camel integrations
@@ -56,21 +61,50 @@ abstract class ProcessBaseCommand extends CamelCommand {
         ProcessHandle.allProcesses()
                 .filter(ph -> ph.pid() != cur)
                 .forEach(ph -> {
-                    String pName = extractName(ph);
-                    // ignore file extension, so it is easier to match by name
-                    pName = FileUtil.onlyName(pName);
-                    if (!pName.isEmpty() && PatternHelper.matchPattern(pName, pattern)) {
-                        pids.add(ph.pid());
+                    JsonObject root = loadStatus(ph.pid());
+                    // there must be a status file for the running Camel integration
+                    if (root != null) {
+                        String pName = extractName(root, ph);
+                        // ignore file extension, so it is easier to match by name
+                        pName = FileUtil.onlyName(pName);
+                        if (pName != null && !pName.isEmpty() && PatternHelper.matchPattern(pName, pattern)) {
+                            pids.add(ph.pid());
+                        }
                     }
                 });
 
         return pids;
     }
 
-    static String extractName(ProcessHandle ph) {
+    static String extractMainClass(JsonObject root) {
+        JsonObject runtime = (JsonObject) root.get("runtime");
+        return runtime != null ? runtime.getString("mainClass") : null;
+    }
+
+    static String extractName(JsonObject root, ProcessHandle ph) {
+        String name = doExtractName(root, ph);
+        return FileUtil.stripPath(name);
+    }
+
+    static String doExtractName(JsonObject root, ProcessHandle ph) {
+        // favour main class if known
+        if (root != null) {
+            String mc = extractMainClass(root);
+            if (mc != null) {
+                return mc;
+            }
+        }
         String cl = ph.info().commandLine().orElse("");
 
-        // TODO: parent/child when mvn spring-boot:run etc
+        // this may be a maven plugin run that spawns a child process where Camel actually runs (link to child)
+        String mvn = extractMavenPluginName(cl);
+        if (mvn != null) {
+            // is camel running in any of the children?
+            boolean camel = ph.children().anyMatch(ch -> !extractName(root, ch).isEmpty());
+            if (camel) {
+                return ""; // skip parent as we want only the child process with camel
+            }
+        }
 
         // try first camel-jbang
         String name = extractCamelJBangName(cl);
@@ -78,8 +112,8 @@ abstract class ProcessBaseCommand extends CamelCommand {
             return name;
         }
 
-        // this may be a maven plugin run, so check that first
-        String mvn = extractMavenPluginName(cl);
+        // this may be a maven plugin run that spawns a child process where Camel actually runs (link to parent)
+        mvn = extractMavenPluginName(cl);
         if (mvn == null && ph.parent().isPresent()) {
             // try parent as it may spawn a sub process
             String clp = ph.parent().get().info().commandLine().orElse("");
@@ -100,8 +134,12 @@ abstract class ProcessBaseCommand extends CamelCommand {
 
     private static String extractCamelName(String cl, String mvn) {
         if (cl != null) {
-            if (cl.contains("camel-spring-boot") && mvn != null) {
-                return mvn;
+            if (cl.contains("camel-spring-boot")) {
+                if (mvn != null) {
+                    return mvn;
+                } else {
+                    return "camel-spring-boot";
+                }
             } else if (cl.contains("camel-quarkus") && mvn != null) {
                 return mvn;
             } else if ((cl.contains("camel-main") || cl.contains("camel-core")) && mvn != null) {
@@ -149,4 +187,26 @@ abstract class ProcessBaseCommand extends CamelCommand {
         return since;
     }
 
+    static String extractState(String status) {
+        if ("started".equalsIgnoreCase(status)) {
+            status = "Running"; // favour using running instead of started
+        }
+        return StringHelper.capitalize(status);
+    }
+
+    JsonObject loadStatus(long pid) {
+        try {
+            File f = getStatusFile("" + pid);
+            if (f != null) {
+                FileInputStream fis = new FileInputStream(f);
+                String text = IOHelper.loadText(fis);
+                IOHelper.close(fis);
+                return (JsonObject) Jsoner.deserialize(text);
+            }
+        } catch (Throwable e) {
+            // ignore
+        }
+        return null;
+    }
+
 }


[camel] 04/04: CAMEL-18425: camel-cli - Make regular Camel applications work with Camel CLI

Posted by da...@apache.org.
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 fa5a437e28931897b4e9630c98ab2657854f398e
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Fri Aug 26 12:36:48 2022 +0200

    CAMEL-18425: camel-cli - Make regular Camel applications work with Camel CLI
---
 .../modules/ROOT/pages/camel-jbang.adoc            | 50 +++++++++++-----------
 1 file changed, 26 insertions(+), 24 deletions(-)

diff --git a/docs/user-manual/modules/ROOT/pages/camel-jbang.adoc b/docs/user-manual/modules/ROOT/pages/camel-jbang.adoc
index c98b9f078fe..e65f8d7b6d8 100644
--- a/docs/user-manual/modules/ROOT/pages/camel-jbang.adoc
+++ b/docs/user-manual/modules/ROOT/pages/camel-jbang.adoc
@@ -521,13 +521,14 @@ camel run clipboard.xml
 
 === Controlling local Camel integrations
 
-To list the currently running Camel JBang integrations you use the `ps` command:
+To list the currently running Camel integrations you use the `ps` command:
 
 [source,bash]
 ----
 camel ps
-37928 camel run foo.yaml (age: 20h18m)
-44805 camel run dude.java (age: 58s)
+  PID   NAME                          READY  STATUS    AGE
+ 61818  sample.camel.MyCamelApplica…   1/1   Running  26m38s
+ 62506  dude.java                      1/1   Running   4m34s
 ----
 
 This lists the PID, the name and age of the integration.
@@ -538,15 +539,15 @@ For example to stop dude, you can do
 [source,bash]
 ----
 camel stop dude
-Stopping running Camel integration (pid: 44805)
+Stopping running Camel integration (pid: 62506)
 ----
 
 You can also stop by the PID:
 
 [source,bash]
 ----
-camel stop 44805
-Stopping running Camel integration (pid: 44805)
+camel stop 62506
+Stopping running Camel integration (pid: 62506)
 ----
 
 TIP: You do not have to type the full name, as the stop command will match using integrations
@@ -558,13 +559,13 @@ To stop all integrations then you need to use the `--all` option as follows:
 [source,bash]
 ----
 camel stop --all
-Stopping running Camel integration (pid: 42171)
-Stopping running Camel integration (pid: 44805)
+Stopping running Camel integration (pid: 61818)
+Stopping running Camel integration (pid: 62506)
 ----
 
 === Get status of Camel integrations
 
-The `get` command in Camel JBang is used for getting status for one
+The `get` command in Camel JBang is used for getting Camel specific status for one
 or all of the running Camel integrations.
 
 To display the status of the running Camel integrations:
@@ -572,10 +573,10 @@ To display the status of the running Camel integrations:
 [source,bash]
 ----
 camel get
-  PID   NAME         READY   STATE   AGE  TOTAL  FAILED  INFLIGHT  SINCE-LAST
- 38780  routes.yaml   1/1   Started  10s      2       0         0          1s
- 38793  dude.java     1/1   Started   9s      6       0         0          0s
- 38806  gro.groovy    1/1   Started   8s      3       0         0          0s
+  PID   NAME                          CAMEL            PLATFORM            READY  STATUS    AGE    TOTAL  FAILED  INFLIGHT  SINCE-LAST
+ 61818  sample.camel.MyCamelApplica…  3.19.0-SNAPSHOT  Spring Boot v2.7.3   1/1   Running  28m34s    854       0         0          0s
+ 63051  dude.java                     3.19.0-SNAPSHOT  JBang                1/1   Running     18s     14       0         0          0s
+ 63068  gro.groovy                    3.19.0-SNAPSHOT  JBang                1/1   Running      5s      2       0         0          0s
 ----
 
 The `camel get` command will default display integrations, which is equivalent to
@@ -591,10 +592,10 @@ You can also see the status of every routes, from all the local Camel integratio
 [source,bash]
 ----
 camel get route
-  PID   SOURCE          ID      FROM                         STATE   AGE  TOTAL  FAILED  INFLIGHT  MEAN  MIN  MAX  SINCE-LAST
- 38911  routes.yaml:18  route1  timer://tick?period=5000    Started  11s      3       0         0    13    0   37          0s
- 38924  dude.java:11    java    timer://java?period=1000    Started  10s     10       0         0     1    0    5          0s
- 38937  gro.groovy      groovy  timer://groovy?period=1000  Started   8s      8       0         0     1    0   11          0s
+  PID   NAME                          ID      FROM                        STATUS    AGE   TOTAL  FAILED  INFLIGHT  MEAN  MIN  MAX  SINCE-LAST
+ 61818  sample.camel.MyCamelApplica…  hello   timer://hello?period=2000   Running  29m2s    870       0         0     0    0   14          0s
+ 63051  dude.java                     java    timer://java?period=1000    Running    46s     46       0         0     0    0    9          0s
+ 63068  gro.groovy                    groovy  timer://groovy?period=1000  Running    34s     34       0         0     0    0    5          0s
 ----
 
 TIP: Use `camel get --help` to display all the available commands as additional will be added in upcoming releases.
@@ -613,16 +614,17 @@ must be installed in the running integration, this can be done, either explicit
 [source,bash]
 ----
 camel ps
-37928 camel run foo.yaml (age: 20h18m)
-44805 camel run dude.java (age: 58s)
+  PID   NAME                          READY  STATUS    AGE
+ 61818  sample.camel.MyCamelApplica…   1/1   Running  26m38s
+ 62506  dude.java                      1/1   Running   4m34s
 ----
 
 With the PID you can then attach Jolokia:
 
 [source,bash]
 ----
-camel jolokia 37928
-Started Jolokia for PID 37928
+camel jolokia 62506
+Started Jolokia for PID 62506
 http://127.0.0.1:8778/jolokia/
 ----
 
@@ -633,7 +635,7 @@ without knowing the PID as follows:
 [source,bash]
 ----
 camel jolokia du
-Started Jolokia for PID 44805
+Started Jolokia for PID 62506
 http://127.0.0.1:8778/jolokia/
 ----
 
@@ -658,8 +660,8 @@ You can uninstall the Jolokia JVM Agent in a running Camel integration when no l
 
 [source,bash]
 ----
-camel jolokia 37928 --stop
-Stopped Jolokia for PID 37928
+camel jolokia 62506 --stop
+Stopped Jolokia for PID 62506
 ----
 
 It is also possible to do this with only one command, as follows:


[camel] 01/04: CAMEL-18425: camel-cli - Make regular Camel applications work with Camel CLI

Posted by da...@apache.org.
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 19b05ef70b08954c5ca8b3d321b77407e2f3e89e
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Fri Aug 26 06:36:07 2022 +0200

    CAMEL-18425: camel-cli - Make regular Camel applications work with Camel CLI
---
 .../camel/impl/engine/SimpleCamelContext.java      |  6 +++
 .../camel/cli/connector/LocalCliConnector.java     |  2 -
 .../core/commands/process/CamelContextStatus.java  |  4 +-
 .../core/commands/process/ProcessBaseCommand.java  | 46 ++++++++++++++--------
 4 files changed, 38 insertions(+), 20 deletions(-)

diff --git a/core/camel-base-engine/src/main/java/org/apache/camel/impl/engine/SimpleCamelContext.java b/core/camel-base-engine/src/main/java/org/apache/camel/impl/engine/SimpleCamelContext.java
index 0ea1c69b103..81ec3100073 100644
--- a/core/camel-base-engine/src/main/java/org/apache/camel/impl/engine/SimpleCamelContext.java
+++ b/core/camel-base-engine/src/main/java/org/apache/camel/impl/engine/SimpleCamelContext.java
@@ -412,6 +412,12 @@ public class SimpleCamelContext extends AbstractCamelContext {
 
     @Override
     protected CliConnectorFactory createCliConnectorFactory() {
+        // lookup in registry first
+        CliConnectorFactory ccf = getCamelContextReference().getRegistry().findSingleByType(CliConnectorFactory.class);
+        if (ccf != null) {
+            return ccf;
+        }
+        // then classpath scanning
         Optional<CliConnectorFactory> result = ResolverHelper.resolveService(
                 getCamelContextReference(),
                 getBootstrapFactoryFinder(),
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 affeb5dc93a..60500113d95 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
@@ -96,8 +96,6 @@ public class LocalCliConnector extends ServiceSupport implements CamelContextAwa
                 platform = "CDI";
             } else if (sn.contains("kamelet") || camelContext.getName().equals("CamelJBang")) {
                 platform = "JBang";
-                // dev.jbang.BuildConfig
-                // dev.jbang.util.getJBangVersion
             } else {
                 platform = "Camel";
             }
diff --git a/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/process/CamelContextStatus.java b/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/process/CamelContextStatus.java
index 73fba159cf0..64edfda5faf 100644
--- a/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/process/CamelContextStatus.java
+++ b/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/process/CamelContextStatus.java
@@ -83,7 +83,7 @@ public class CamelContextStatus extends ProcessBaseCommand {
                         if (root != null) {
                             JsonObject runtime = (JsonObject) root.get("runtime");
                             row.platform = runtime != null ? runtime.getString("platform") : null;
-                            row.platformVersion = runtime != null ? runtime.getString("platformVersion") : null;
+                            row.platformVersion = runtime != null ? runtime.getString("version") : null;
                             JsonObject context = (JsonObject) root.get("context");
                             row.state = context.getString("state").toLowerCase(Locale.ROOT);
                             row.camelVersion = context.getString("version");
@@ -126,7 +126,7 @@ public class CamelContextStatus extends ProcessBaseCommand {
 
     private String getPlatform(Row r) {
         if (r.platformVersion != null) {
-            return r.platform + " v" + r.platformVersion + ")";
+            return r.platform + " v" + r.platformVersion;
         } else {
             return r.platform;
         }
diff --git a/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/process/ProcessBaseCommand.java b/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/process/ProcessBaseCommand.java
index 8181e14150a..14075f5f92e 100644
--- a/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/process/ProcessBaseCommand.java
+++ b/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/process/ProcessBaseCommand.java
@@ -70,36 +70,50 @@ abstract class ProcessBaseCommand extends CamelCommand {
     static String extractName(ProcessHandle ph) {
         String cl = ph.info().commandLine().orElse("");
 
+        // TODO: parent/child when mvn spring-boot:run etc
+
+        // try first camel-jbang
         String name = extractCamelJBangName(cl);
-        if (name == null) {
-            name = extractCamelMavenName(cl);
+        if (name != null) {
+            return name;
         }
-        if (name == null) {
-            name = extractCamelMain(cl);
+
+        // this may be a maven plugin run, so check that first
+        String mvn = extractMavenPluginName(cl);
+        if (mvn == null && ph.parent().isPresent()) {
+            // try parent as it may spawn a sub process
+            String clp = ph.parent().get().info().commandLine().orElse("");
+            mvn = extractMavenPluginName(clp);
         }
 
+        name = extractCamelName(cl, mvn);
         return name == null ? "" : name;
     }
 
-    private static String extractCamelMavenName(String cl) {
-        String name = StringHelper.before(cl, " camel:run");
+    private static String extractMavenPluginName(String cl) {
+        String name = StringHelper.after(cl, "org.codehaus.plexus.classworlds.launcher.Launcher");
         if (name != null) {
-            if (name.contains("org.codehaus.plexus.classworlds.launcher.Launcher")) {
-                return "mvn camel:run";
-            }
+            return name.trim();
         }
-
         return null;
     }
 
-    private static String extractCamelMain(String cl) {
+    private static String extractCamelName(String cl, String mvn) {
         if (cl != null) {
-            if (cl.contains("camel-main")) {
+            if (cl.contains("camel-spring-boot") && mvn != null) {
+                return mvn;
+            } else if (cl.contains("camel-quarkus") && mvn != null) {
+                return mvn;
+            } else if ((cl.contains("camel-main") || cl.contains("camel-core")) && mvn != null) {
+                return mvn;
+            } else if (cl.contains("camel-core") && mvn == null) {
                 int pos = cl.lastIndexOf(" ");
-                String after = cl.substring(pos);
-                after = after.trim();
-                if (after.matches("[\\w|.]+")) {
-                    return "camel-main";
+                if (pos != -1) {
+                    String after = cl.substring(pos);
+                    after = after.trim();
+                    if (after.matches("[\\w|.]+")) {
+                        return cl.contains("camel-main") ? "camel-main" : "camel-core";
+                    }
                 }
             }
         }