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 58ba20a42e9 CAMEL-20977: WARN log if failing to start/stop routes via
jbang or JMX
58ba20a42e9 is described below
commit 58ba20a42e980114cef720d55c8f8592cafe733f
Author: Claus Ibsen <[email protected]>
AuthorDate: Fri Jul 12 16:59:52 2024 +0200
CAMEL-20977: WARN log if failing to start/stop routes via jbang or JMX
---
.../apache/camel/impl/console/RouteDevConsole.java | 6 +++++-
.../camel/management/mbean/ManagedRoute.java | 22 ++++++++++++++++++++--
.../camel/cli/connector/LocalCliConnector.java | 12 +++++++-----
3 files changed, 32 insertions(+), 8 deletions(-)
diff --git
a/core/camel-console/src/main/java/org/apache/camel/impl/console/RouteDevConsole.java
b/core/camel-console/src/main/java/org/apache/camel/impl/console/RouteDevConsole.java
index 0624230c452..6252d267003 100644
---
a/core/camel-console/src/main/java/org/apache/camel/impl/console/RouteDevConsole.java
+++
b/core/camel-console/src/main/java/org/apache/camel/impl/console/RouteDevConsole.java
@@ -42,10 +42,14 @@ 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 org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
@DevConsole(name = "route", description = "Route information")
public class RouteDevConsole extends AbstractDevConsole {
+ private static final Logger LOG =
LoggerFactory.getLogger(RouteDevConsole.class);
+
/**
* Filters the routes matching by route id, route uri, and source location
*/
@@ -550,7 +554,7 @@ public class RouteDevConsole extends AbstractDevConsole {
}
}
} catch (Exception e) {
- // ignore
+ LOG.warn("Error {} route: {} due to: {}. This exception is
ignored.", command, id, e.getMessage(), e);
}
}
}
diff --git
a/core/camel-management/src/main/java/org/apache/camel/management/mbean/ManagedRoute.java
b/core/camel-management/src/main/java/org/apache/camel/management/mbean/ManagedRoute.java
index ecbed4766b1..6242ab06a99 100644
---
a/core/camel-management/src/main/java/org/apache/camel/management/mbean/ManagedRoute.java
+++
b/core/camel-management/src/main/java/org/apache/camel/management/mbean/ManagedRoute.java
@@ -319,7 +319,12 @@ public class ManagedRoute extends
ManagedPerformanceCounter implements TimerList
if (!context.getStatus().isStarted()) {
throw new IllegalArgumentException("CamelContext is not started");
}
- context.getRouteController().startRoute(getRouteId());
+ try {
+ context.getRouteController().startRoute(getRouteId());
+ } catch (Exception e) {
+ LOG.warn("Error starting route: {} due to: {}. This exception is
ignored.", getRouteId(), e.getMessage(), e);
+ throw e;
+ }
}
@Override
@@ -327,7 +332,12 @@ public class ManagedRoute extends
ManagedPerformanceCounter implements TimerList
if (!context.getStatus().isStarted()) {
throw new IllegalArgumentException("CamelContext is not started");
}
- context.getRouteController().stopRoute(getRouteId());
+ try {
+ context.getRouteController().stopRoute(getRouteId());
+ } catch (Exception e) {
+ LOG.warn("Error stopping route: {} due to: {}. This exception is
ignored.", getRouteId(), e.getMessage(), e);
+ throw e;
+ }
}
@Override
@@ -355,6 +365,10 @@ public class ManagedRoute extends
ManagedPerformanceCounter implements TimerList
return context.getRouteController().stopRoute(getRouteId(), timeout,
TimeUnit.SECONDS, abortAfterTimeout);
}
+ /**
+ * @deprecated not in use
+ */
+ @Deprecated(since = "4.8.0")
public void shutdown() throws Exception {
if (!context.getStatus().isStarted()) {
throw new IllegalArgumentException("CamelContext is not started");
@@ -364,6 +378,10 @@ public class ManagedRoute extends
ManagedPerformanceCounter implements TimerList
context.removeRoute(routeId);
}
+ /**
+ * @deprecated not in use
+ */
+ @Deprecated(since = "4.8.0")
public void shutdown(long timeout) throws Exception {
if (!context.getStatus().isStarted()) {
throw new IllegalArgumentException("CamelContext is not started");
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 6812bcb72d4..e49741cd9be 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
@@ -222,6 +222,7 @@ public class LocalCliConnector extends ServiceSupport
implements CliConnector, C
}
protected void actionTask() {
+ String action = null;
try {
JsonObject root = loadAction();
if (root == null || root.isEmpty()) {
@@ -232,7 +233,7 @@ public class LocalCliConnector extends ServiceSupport
implements CliConnector, C
LOG.debug("Action: {}", root);
}
- String action = root.getString("action");
+ action = root.getString("action");
if ("route".equals(action)) {
doActionRouteTask(root);
} else if ("logger".equals(action)) {
@@ -270,7 +271,8 @@ public class LocalCliConnector extends ServiceSupport
implements CliConnector, C
}
} catch (Exception e) {
// ignore
- LOG.debug("Error executing action file: {} due to: {}. This
exception is ignored.", actionFile, e.getMessage(),
+ LOG.warn("Error executing action: {} due to: {}. This exception is
ignored.", action != null ? action : actionFile,
+ e.getMessage(),
e);
} finally {
// action done so delete file
@@ -794,7 +796,7 @@ public class LocalCliConnector extends ServiceSupport
implements CliConnector, C
LoggerHelper.changeLoggingLevel(logger, level);
}
} catch (Exception e) {
- // ignore
+ LOG.warn("Error changing logging level due to {}. This exception
is ignored.", e.getMessage(), e);
}
}
@@ -814,8 +816,8 @@ public class LocalCliConnector extends ServiceSupport
implements CliConnector, C
})
.toList();
for (String id : ids) {
+ String command = root.getString("command");
try {
- String command = root.getString("command");
if ("start".equals(command)) {
if ("*".equals(id)) {
camelContext.getRouteController().startAllRoutes();
@@ -846,7 +848,7 @@ public class LocalCliConnector extends ServiceSupport
implements CliConnector, C
}
}
} catch (Exception e) {
- // ignore
+ LOG.warn("Error {} route: {} due to: {}. This exception is
ignored.", command, id, e.getMessage(), e);
}
}
}