camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From davscl...@apache.org
Subject [2/4] camel git commit: Add warn logging when updating routes with xml over jmx api failed
Date Tue, 27 Oct 2015 13:12:11 GMT
Add warn logging when updating routes with xml over jmx api failed


Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/86782ae4
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/86782ae4
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/86782ae4

Branch: refs/heads/camel-2.16.x
Commit: 86782ae4751077e239e872ce266ba28eb0716df6
Parents: 7caa9bb
Author: Claus Ibsen <davsclaus@apache.org>
Authored: Tue Oct 27 13:53:46 2015 +0100
Committer: Claus Ibsen <davsclaus@apache.org>
Committed: Tue Oct 27 14:10:51 2015 +0100

----------------------------------------------------------------------
 .../management/mbean/ManagedCamelContext.java     | 16 ++++++++++++++--
 .../camel/management/mbean/ManagedRoute.java      | 18 ++++++++++++++++--
 2 files changed, 30 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/86782ae4/camel-core/src/main/java/org/apache/camel/management/mbean/ManagedCamelContext.java
----------------------------------------------------------------------
diff --git a/camel-core/src/main/java/org/apache/camel/management/mbean/ManagedCamelContext.java
b/camel-core/src/main/java/org/apache/camel/management/mbean/ManagedCamelContext.java
index cd3ed4a..758d3b1 100644
--- a/camel-core/src/main/java/org/apache/camel/management/mbean/ManagedCamelContext.java
+++ b/camel-core/src/main/java/org/apache/camel/management/mbean/ManagedCamelContext.java
@@ -37,6 +37,8 @@ import javax.management.openmbean.CompositeType;
 import javax.management.openmbean.TabularData;
 import javax.management.openmbean.TabularDataSupport;
 
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 import org.w3c.dom.Document;
 
 import org.apache.camel.CamelContext;
@@ -69,6 +71,9 @@ import org.apache.camel.util.ObjectHelper;
  */
 @ManagedResource(description = "Managed CamelContext")
 public class ManagedCamelContext extends ManagedPerformanceCounter implements TimerListener,
ManagedCamelContextMBean {
+
+    private static final Logger LOG = LoggerFactory.getLogger(ManagedCamelContext.class);
+
     private final ModelCamelContext context;
     private final LoadTriplet load = new LoadTriplet();
 
@@ -382,8 +387,15 @@ public class ManagedCamelContext extends ManagedPerformanceCounter implements
Ti
             return;
         }
 
-        // add will remove existing route first
-        context.addRouteDefinitions(def.getRoutes());
+        try {
+            // add will remove existing route first
+            context.addRouteDefinitions(def.getRoutes());
+        } catch (Exception e) {
+            // log the error as warn as the management api may be invoked remotely over JMX
which does not propagate such exception
+            String msg = "Error updating routes from xml: " + xml + " due: " + e.getMessage();
+            LOG.warn(msg, e);
+            throw e;
+        }
     }
 
     public String dumpRoutesStatsAsXml(boolean fullStats, boolean includeProcessors) throws
Exception {

http://git-wip-us.apache.org/repos/asf/camel/blob/86782ae4/camel-core/src/main/java/org/apache/camel/management/mbean/ManagedRoute.java
----------------------------------------------------------------------
diff --git a/camel-core/src/main/java/org/apache/camel/management/mbean/ManagedRoute.java
b/camel-core/src/main/java/org/apache/camel/management/mbean/ManagedRoute.java
index 2f11b41..a4722fa 100644
--- a/camel-core/src/main/java/org/apache/camel/management/mbean/ManagedRoute.java
+++ b/camel-core/src/main/java/org/apache/camel/management/mbean/ManagedRoute.java
@@ -48,9 +48,14 @@ import org.apache.camel.model.RouteDefinition;
 import org.apache.camel.spi.ManagementStrategy;
 import org.apache.camel.spi.RoutePolicy;
 import org.apache.camel.util.ObjectHelper;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 @ManagedResource(description = "Managed Route")
 public class ManagedRoute extends ManagedPerformanceCounter implements TimerListener, ManagedRouteMBean
{
+
+    private static final Logger LOG = LoggerFactory.getLogger(ManagedRoute.class);
+
     public static final String VALUE_UNKNOWN = "Unknown";
     protected final Route route;
     protected final String description;
@@ -275,8 +280,17 @@ public class ManagedRoute extends ManagedPerformanceCounter implements
TimerList
                     + getRouteId() + ", routeId from XML: " + def.getId());
         }
 
-        // add will remove existing route first
-        context.addRouteDefinition(def);
+        LOG.debug("Updating route: {} from xml: {}", def.getId(), xml);
+
+        try {
+            // add will remove existing route first
+            context.addRouteDefinition(def);
+        } catch (Exception e) {
+            // log the error as warn as the management api may be invoked remotely over JMX
which does not propagate such exception
+            String msg = "Error updating route: " + def.getId() + " from xml: " + xml + "
due: " + e.getMessage();
+            LOG.warn(msg, e);
+            throw e;
+        }
     }
 
     public String dumpRouteStatsAsXml(boolean fullStats, boolean includeProcessors) throws
Exception {


Mime
View raw message