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 2018/07/12 07:37:41 UTC

[camel] branch master updated (02826fb -> 572f021)

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

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


    from 02826fb  Upgrade Async Http Client to version 2.5.1
     new 81243a0  CAMEL-12633: camel-jmx - Allow consumer to alos filter observed attribute.
     new 1315674  CAMEL-12633: Polished
     new 572f021  CAMEL-12633: camel-jmx - You can now observe attribute and use stringToCompare for the attribute to only trigger when matching in the regular consumer.

The 3 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:
 .../camel-jmx/src/main/docs/jmx-component.adoc     |  8 +--
 .../apache/camel/component/jmx/JMXConsumer.java    | 10 +++-
 .../jmx/JMXConsumerNotificationFilter.java         | 61 ++++++++++++++++++++++
 .../apache/camel/component/jmx/JMXEndpoint.java    | 17 +++---
 ...umerObserveAttributeMatchStringDifferTest.java} | 22 ++++++--
 ...mxConsumerObserveAttributeMatchStringTest.java} | 21 ++++++--
 ...a => CamelJmxConsumerObserveAttributeTest.java} | 11 ++--
 7 files changed, 127 insertions(+), 23 deletions(-)
 create mode 100644 components/camel-jmx/src/main/java/org/apache/camel/component/jmx/JMXConsumerNotificationFilter.java
 copy components/camel-jmx/src/test/java/org/apache/camel/component/jmx/{CamelJmxConsumerTest.java => CamelJmxConsumerObserveAttributeMatchStringDifferTest.java} (70%)
 copy components/camel-jmx/src/test/java/org/apache/camel/component/jmx/{CamelJmxConsumerTest.java => CamelJmxConsumerObserveAttributeMatchStringTest.java} (71%)
 copy components/camel-jmx/src/test/java/org/apache/camel/component/jmx/{CamelJmxConsumerTest.java => CamelJmxConsumerObserveAttributeTest.java} (81%)


[camel] 01/03: CAMEL-12633: camel-jmx - Allow consumer to alos filter observed attribute.

Posted by da...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit 81243a00e8f27fa68e8e2e582267c6cc3ab07eae
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Wed Jul 11 10:09:58 2018 +0200

    CAMEL-12633: camel-jmx - Allow consumer to alos filter observed attribute.
---
 .../camel-jmx/src/main/docs/jmx-component.adoc     |  2 +-
 .../apache/camel/component/jmx/JMXConsumer.java    |  8 +++
 .../apache/camel/component/jmx/JMXEndpoint.java    |  2 +-
 .../jmx/CamelJmxConsumerObserveAttributeTest.java  | 64 ++++++++++++++++++++++
 4 files changed, 74 insertions(+), 2 deletions(-)

diff --git a/components/camel-jmx/src/main/docs/jmx-component.adoc b/components/camel-jmx/src/main/docs/jmx-component.adoc
index ecabd57..0e7677d 100644
--- a/components/camel-jmx/src/main/docs/jmx-component.adoc
+++ b/components/camel-jmx/src/main/docs/jmx-component.adoc
@@ -57,7 +57,7 @@ with the following path and query parameters:
 | *monitorType* (consumer) | The type of monitor to create. One of string, gauge, counter (monitor types only). |  | String
 | *objectDomain* (consumer) | *Required* The domain for the mbean you're connecting to |  | String
 | *objectName* (consumer) | The name key for the mbean you're connecting to. This value is mutually exclusive with the object properties that get passed. |  | String
-| *observedAttribute* (consumer) | The attribute to observe for the monitor bean (monitor types only). |  | String
+| *observedAttribute* (consumer) | The attribute to observe for the monitor bean or consumer. |  | String
 | *exceptionHandler* (consumer) | To let the consumer use a custom ExceptionHandler. Notice if the option bridgeErrorHandler is enabled then this options is not in use. By default the consumer will deal with exceptions, that will be logged at WARN or ERROR level and ignored. |  | ExceptionHandler
 | *exchangePattern* (consumer) | Sets the exchange pattern when the consumer creates an exchange. |  | ExchangePattern
 | *executorService* (advanced) | To use a custom shared thread pool for the consumers. By default each consume has their own thread-pool to process and route notifications. |  | ExecutorService
diff --git a/components/camel-jmx/src/main/java/org/apache/camel/component/jmx/JMXConsumer.java b/components/camel-jmx/src/main/java/org/apache/camel/component/jmx/JMXConsumer.java
index d2db3ae..3419afa 100644
--- a/components/camel-jmx/src/main/java/org/apache/camel/component/jmx/JMXConsumer.java
+++ b/components/camel-jmx/src/main/java/org/apache/camel/component/jmx/JMXConsumer.java
@@ -23,6 +23,7 @@ import java.util.Map;
 import java.util.concurrent.ExecutorService;
 import java.util.concurrent.ScheduledExecutorService;
 import java.util.concurrent.TimeUnit;
+import javax.management.AttributeChangeNotificationFilter;
 import javax.management.MBeanServerConnection;
 import javax.management.Notification;
 import javax.management.NotificationFilter;
@@ -250,6 +251,13 @@ public class JMXConsumer extends DefaultConsumer implements NotificationListener
         JMXEndpoint ep = getEndpoint();
         NotificationFilter nf = ep.getNotificationFilter();
 
+        // if we should observe a single attribute then use filter
+        if (nf == null && ep.getObservedAttribute() != null) {
+            AttributeChangeNotificationFilter acnf = new AttributeChangeNotificationFilter();
+            acnf.enableAttribute(ep.getObservedAttribute());
+            nf = acnf;
+        }
+
         ObjectName objectName = ep.getJMXObjectName();
 
         getServerConnection().addNotificationListener(objectName, this, nf, ep.getHandback());
diff --git a/components/camel-jmx/src/main/java/org/apache/camel/component/jmx/JMXEndpoint.java b/components/camel-jmx/src/main/java/org/apache/camel/component/jmx/JMXEndpoint.java
index 9833774..3f7d67f 100644
--- a/components/camel-jmx/src/main/java/org/apache/camel/component/jmx/JMXEndpoint.java
+++ b/components/camel-jmx/src/main/java/org/apache/camel/component/jmx/JMXEndpoint.java
@@ -79,7 +79,7 @@ public class JMXEndpoint extends DefaultEndpoint {
     private String objectName;
 
     /**
-     * The attribute to observe for the monitor bean (monitor types only).
+     * The attribute to observe for the monitor bean or consumer.
      */
     @UriParam
     private String observedAttribute;
diff --git a/components/camel-jmx/src/test/java/org/apache/camel/component/jmx/CamelJmxConsumerObserveAttributeTest.java b/components/camel-jmx/src/test/java/org/apache/camel/component/jmx/CamelJmxConsumerObserveAttributeTest.java
new file mode 100644
index 0000000..f42da21
--- /dev/null
+++ b/components/camel-jmx/src/test/java/org/apache/camel/component/jmx/CamelJmxConsumerObserveAttributeTest.java
@@ -0,0 +1,64 @@
+/**
+ * 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.component.jmx;
+
+import org.apache.camel.RoutesBuilder;
+import org.apache.camel.api.management.mbean.ManagedRouteMBean;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.test.junit4.CamelTestSupport;
+import org.junit.Test;
+
+public class CamelJmxConsumerObserveAttributeTest extends CamelTestSupport {
+
+    @Override
+    protected boolean useJmx() {
+        return true;
+    }
+
+    @Test
+    public void testJmxConsumer() throws Exception {
+        getMockEndpoint("mock:result").expectedMinimumMessageCount(1);
+        getMockEndpoint("mock:result").message(0).body().contains("<newValue>true</newValue>");
+        getMockEndpoint("mock:result").message(0).body().contains("<attributeName>Tracing</attributeName>");
+
+        // change the attribute so JMX triggers but should be filtered
+        ManagedRouteMBean mr = context.getManagedRoute("foo", ManagedRouteMBean.class);
+        mr.setStatisticsEnabled(true);
+
+        // change the attribute so JMX triggers
+        mr = context.getManagedRoute("foo", ManagedRouteMBean.class);
+        mr.setTracing(true);
+
+        assertMockEndpointsSatisfied();
+    }
+
+    @Override
+    protected RoutesBuilder createRouteBuilder() throws Exception {
+        return new RouteBuilder() {
+            @Override
+            public void configure() throws Exception {
+                String id = getContext().getName();
+
+                fromF("jmx:platform?objectDomain=org.apache.camel&key.context=%s&key.type=routes&key.name=\"foo\"&observedAttribute=Tracing", id).routeId("jmxRoute")
+                    .to("log:jmx")
+                    .to("mock:result");
+
+                from("direct:foo").routeId("foo").to("log:foo", "mock:foo");
+            }
+        };
+    }
+}


[camel] 03/03: CAMEL-12633: camel-jmx - You can now observe attribute and use stringToCompare for the attribute to only trigger when matching in the regular consumer.

Posted by da...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit 572f0211d6c0b94a93e82b508f5a5cdc4dd11bd7
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Thu Jul 12 09:37:23 2018 +0200

    CAMEL-12633: camel-jmx - You can now observe attribute and use stringToCompare for the attribute to only trigger when matching in the regular consumer.
---
 .../camel-jmx/src/main/docs/jmx-component.adoc     |  6 +-
 .../apache/camel/component/jmx/JMXConsumer.java    |  6 +-
 .../jmx/JMXConsumerNotificationFilter.java         | 61 ++++++++++++++++++
 .../apache/camel/component/jmx/JMXEndpoint.java    | 15 +++--
 ...sumerObserveAttributeMatchStringDifferTest.java | 73 ++++++++++++++++++++++
 ...JmxConsumerObserveAttributeMatchStringTest.java | 72 +++++++++++++++++++++
 6 files changed, 221 insertions(+), 12 deletions(-)

diff --git a/components/camel-jmx/src/main/docs/jmx-component.adoc b/components/camel-jmx/src/main/docs/jmx-component.adoc
index 0e7677d..9eb59f9 100644
--- a/components/camel-jmx/src/main/docs/jmx-component.adoc
+++ b/components/camel-jmx/src/main/docs/jmx-component.adoc
@@ -68,6 +68,9 @@ with the following path and query parameters:
 | *reconnectOnConnection Failure* (advanced) | If true the consumer will attempt to reconnect to the JMX server when any connection failure occurs. The consumer will attempt to re-establish the JMX connection every 'x' seconds until the connection is made-- where 'x' is the configured reconnectionDelay | false | boolean
 | *synchronous* (advanced) | Sets whether synchronous processing should be strictly used, or Camel is allowed to use asynchronous processing (if supported). | false | boolean
 | *testConnectionOnStartup* (advanced) | If true the consumer will throw an exception if unable to establish the JMX connection upon startup. If false, the consumer will attempt to establish the JMX connection every 'x' seconds until the connection is made -- where 'x' is the configured reconnectionDelay | true | boolean
+| *notifyDiffer* (string) | If true, will fire a notification when the string attribute differs from the string to compare (string monitor or consumer). By default the consumer will notify match if observed attribute and string to compare has been configured. | false | boolean
+| *notifyMatch* (string) | If true, will fire a notification when the string attribute matches the string to compare (string monitor or consumer). By default the consumer will notify match if observed attribute and string to compare has been configured. | false | boolean
+| *stringToCompare* (string) | Value for attribute to compare (string monitor or consumer). By default the consumer will notify match if observed attribute and string to compare has been configured. |  | String
 | *initThreshold* (counter) | Initial threshold for the monitor. The value must exceed this before notifications are fired (counter monitor only). |  | int
 | *modulus* (counter) | The value at which the counter is reset to zero (counter monitor only). |  | int
 | *offset* (counter) | The amount to increment the threshold after it's been exceeded (counter monitor only). |  | int
@@ -78,9 +81,6 @@ with the following path and query parameters:
 | *thresholdLow* (gauge) | Value for the gauge's low threshold (gauge monitor only). |  | Double
 | *password* (security) | Credentials for making a remote connection |  | String
 | *user* (security) | Credentials for making a remote connection |  | String
-| *notifyDiffer* (string) | If true, the string monitor will fire a notification when the string attribute differs from the string to compare (string monitor only). | false | boolean
-| *notifyMatch* (string) | If true, the string monitor will fire a notification when the string attribute matches the string to compare (string monitor only). | false | boolean
-| *stringToCompare* (string) | Value for the string monitor's string to compare (string monitor only). |  | String
 |===
 // endpoint options: END
 
diff --git a/components/camel-jmx/src/main/java/org/apache/camel/component/jmx/JMXConsumer.java b/components/camel-jmx/src/main/java/org/apache/camel/component/jmx/JMXConsumer.java
index ee02284..1e6e9a3 100644
--- a/components/camel-jmx/src/main/java/org/apache/camel/component/jmx/JMXConsumer.java
+++ b/components/camel-jmx/src/main/java/org/apache/camel/component/jmx/JMXConsumer.java
@@ -253,9 +253,9 @@ public class JMXConsumer extends DefaultConsumer implements NotificationListener
 
         // if we should observe a single attribute then use filter
         if (nf == null && ep.getObservedAttribute() != null) {
-            AttributeChangeNotificationFilter acnf = new AttributeChangeNotificationFilter();
-            acnf.enableAttribute(ep.getObservedAttribute());
-            nf = acnf;
+            LOG.debug("Observing attribute: {}", ep.getObservedAttribute());
+            boolean match = !ep.isNotifyDiffer();
+            nf = new JMXConsumerNotificationFilter(ep.getObservedAttribute(), ep.getStringToCompare(), match);
         }
 
         ObjectName objectName = ep.getJMXObjectName();
diff --git a/components/camel-jmx/src/main/java/org/apache/camel/component/jmx/JMXConsumerNotificationFilter.java b/components/camel-jmx/src/main/java/org/apache/camel/component/jmx/JMXConsumerNotificationFilter.java
new file mode 100644
index 0000000..d5620b0
--- /dev/null
+++ b/components/camel-jmx/src/main/java/org/apache/camel/component/jmx/JMXConsumerNotificationFilter.java
@@ -0,0 +1,61 @@
+/**
+ * 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.component.jmx;
+
+import javax.management.AttributeChangeNotification;
+import javax.management.AttributeChangeNotificationFilter;
+import javax.management.Notification;
+
+/**
+ * {@link javax.management.NotificationFilter} that observes an attribute and optionally
+ * matches when the new value matches a string.
+ */
+public class JMXConsumerNotificationFilter extends AttributeChangeNotificationFilter {
+
+    private final String stringToCompare;
+    private final boolean notifyMatch;
+
+    public JMXConsumerNotificationFilter(String observedAttribute, String stringToCompare, boolean notifyMatch) {
+        enableAttribute(observedAttribute);
+        this.stringToCompare = stringToCompare;
+        this.notifyMatch = notifyMatch;
+    }
+
+    @Override
+    public boolean isNotificationEnabled(Notification notification) {
+        boolean enabled = super.isNotificationEnabled(notification);
+        if (!enabled) {
+            return false;
+        }
+
+        boolean match = false;
+        if (stringToCompare != null) {
+            AttributeChangeNotification acn = (AttributeChangeNotification) notification;
+            Object newValue = acn.getNewValue();
+            // special for null
+            if ("null".equals(stringToCompare) && newValue == null) {
+                match = true;
+            } else if (newValue != null) {
+                match = stringToCompare.equals(newValue.toString());
+            }
+            return notifyMatch == match;
+        } else {
+            return true;
+        }
+    }
+
+}
diff --git a/components/camel-jmx/src/main/java/org/apache/camel/component/jmx/JMXEndpoint.java b/components/camel-jmx/src/main/java/org/apache/camel/component/jmx/JMXEndpoint.java
index 3f7d67f..b174b92 100644
--- a/components/camel-jmx/src/main/java/org/apache/camel/component/jmx/JMXEndpoint.java
+++ b/components/camel-jmx/src/main/java/org/apache/camel/component/jmx/JMXEndpoint.java
@@ -145,21 +145,24 @@ public class JMXEndpoint extends DefaultEndpoint {
     private Double thresholdLow;
 
     /**
-     * If true, the string monitor will fire a notification when the string attribute differs from the string to compare (string monitor only).
+     * If true, will fire a notification when the string attribute differs from the string to compare (string monitor or consumer).
+     * By default the consumer will notify match if observed attribute and string to compare has been configured.
      */
-    @UriParam(label = "string")
+    @UriParam(label = "consumer,string")
     private boolean notifyDiffer;
 
     /**
-     * If true, the string monitor will fire a notification when the string attribute matches the string to compare (string monitor only).
+     * If true, will fire a notification when the string attribute matches the string to compare (string monitor or consumer).
+     * By default the consumer will notify match if observed attribute and string to compare has been configured.
      */
-    @UriParam(label = "string")
+    @UriParam(label = "consumer,string")
     private boolean notifyMatch;
 
     /**
-     * Value for the string monitor's string to compare (string monitor only).
+     * Value for attribute to compare (string monitor or consumer).
+     * By default the consumer will notify match if observed attribute and string to compare has been configured.
      */
-    @UriParam(label = "string")
+    @UriParam(label = "consumer,string")
     private String stringToCompare;
     
     /**
diff --git a/components/camel-jmx/src/test/java/org/apache/camel/component/jmx/CamelJmxConsumerObserveAttributeMatchStringDifferTest.java b/components/camel-jmx/src/test/java/org/apache/camel/component/jmx/CamelJmxConsumerObserveAttributeMatchStringDifferTest.java
new file mode 100644
index 0000000..90534fb
--- /dev/null
+++ b/components/camel-jmx/src/test/java/org/apache/camel/component/jmx/CamelJmxConsumerObserveAttributeMatchStringDifferTest.java
@@ -0,0 +1,73 @@
+/**
+ * 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.component.jmx;
+
+import org.apache.camel.RoutesBuilder;
+import org.apache.camel.api.management.mbean.ManagedRouteMBean;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.test.junit4.CamelTestSupport;
+import org.junit.Test;
+
+public class CamelJmxConsumerObserveAttributeMatchStringDifferTest extends CamelTestSupport {
+
+    @Override
+    protected boolean useJmx() {
+        return true;
+    }
+
+    @Test
+    public void testJmxConsumer() throws Exception {
+        getMockEndpoint("mock:result").expectedMinimumMessageCount(1);
+        getMockEndpoint("mock:result").message(0).body().contains("<newValue>false</newValue>");
+        getMockEndpoint("mock:result").message(0).body().contains("<attributeName>Tracing</attributeName>");
+
+        // change the attribute so JMX triggers but should be filtered
+        ManagedRouteMBean mr = context.getManagedRoute("foo", ManagedRouteMBean.class);
+        mr.setStatisticsEnabled(true);
+
+        // change the attribute so JMX triggers
+        mr = context.getManagedRoute("foo", ManagedRouteMBean.class);
+        mr.setTracing(true);
+
+        // change the attribute so JMX triggers
+        mr = context.getManagedRoute("foo", ManagedRouteMBean.class);
+        mr.setTracing(false);
+
+        // change the attribute so JMX triggers
+        mr = context.getManagedRoute("foo", ManagedRouteMBean.class);
+        mr.setTracing(true);
+
+        assertMockEndpointsSatisfied();
+    }
+
+    @Override
+    protected RoutesBuilder createRouteBuilder() throws Exception {
+        return new RouteBuilder() {
+            @Override
+            public void configure() throws Exception {
+                String id = getContext().getName();
+
+                fromF("jmx:platform?objectDomain=org.apache.camel&key.context=%s&key.type=routes&key.name=\"foo\"&observedAttribute=Tracing&stringToCompare=true&notifyDiffer=true", id)
+                    .routeId("jmxRoute")
+                    .to("log:jmx")
+                    .to("mock:result");
+
+                from("direct:foo").routeId("foo").to("log:foo", "mock:foo");
+            }
+        };
+    }
+}
diff --git a/components/camel-jmx/src/test/java/org/apache/camel/component/jmx/CamelJmxConsumerObserveAttributeMatchStringTest.java b/components/camel-jmx/src/test/java/org/apache/camel/component/jmx/CamelJmxConsumerObserveAttributeMatchStringTest.java
new file mode 100644
index 0000000..764004c
--- /dev/null
+++ b/components/camel-jmx/src/test/java/org/apache/camel/component/jmx/CamelJmxConsumerObserveAttributeMatchStringTest.java
@@ -0,0 +1,72 @@
+/**
+ * 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.component.jmx;
+
+import org.apache.camel.RoutesBuilder;
+import org.apache.camel.api.management.mbean.ManagedRouteMBean;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.test.junit4.CamelTestSupport;
+import org.junit.Test;
+
+public class CamelJmxConsumerObserveAttributeMatchStringTest extends CamelTestSupport {
+
+    @Override
+    protected boolean useJmx() {
+        return true;
+    }
+
+    @Test
+    public void testJmxConsumer() throws Exception {
+        getMockEndpoint("mock:result").expectedMinimumMessageCount(1);
+        getMockEndpoint("mock:result").message(0).body().contains("<newValue>false</newValue>");
+        getMockEndpoint("mock:result").message(0).body().contains("<attributeName>Tracing</attributeName>");
+
+        // change the attribute so JMX triggers but should be filtered
+        ManagedRouteMBean mr = context.getManagedRoute("foo", ManagedRouteMBean.class);
+        mr.setStatisticsEnabled(true);
+
+        // change the attribute so JMX triggers
+        mr = context.getManagedRoute("foo", ManagedRouteMBean.class);
+        mr.setTracing(true);
+
+        // change the attribute so JMX triggers
+        mr = context.getManagedRoute("foo", ManagedRouteMBean.class);
+        mr.setTracing(false);
+
+        // change the attribute so JMX triggers
+        mr = context.getManagedRoute("foo", ManagedRouteMBean.class);
+        mr.setTracing(true);
+
+        assertMockEndpointsSatisfied();
+    }
+
+    @Override
+    protected RoutesBuilder createRouteBuilder() throws Exception {
+        return new RouteBuilder() {
+            @Override
+            public void configure() throws Exception {
+                String id = getContext().getName();
+
+                fromF("jmx:platform?objectDomain=org.apache.camel&key.context=%s&key.type=routes&key.name=\"foo\"&observedAttribute=Tracing&stringToCompare=false", id).routeId("jmxRoute")
+                    .to("log:jmx")
+                    .to("mock:result");
+
+                from("direct:foo").routeId("foo").to("log:foo", "mock:foo");
+            }
+        };
+    }
+}


[camel] 02/03: CAMEL-12633: Polished

Posted by da...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit 1315674ebded48e95e0d65aca8b5b513e9e29ff7
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Thu Jul 12 09:16:38 2018 +0200

    CAMEL-12633: Polished
---
 .../src/main/java/org/apache/camel/component/jmx/JMXConsumer.java       | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/components/camel-jmx/src/main/java/org/apache/camel/component/jmx/JMXConsumer.java b/components/camel-jmx/src/main/java/org/apache/camel/component/jmx/JMXConsumer.java
index 3419afa..ee02284 100644
--- a/components/camel-jmx/src/main/java/org/apache/camel/component/jmx/JMXConsumer.java
+++ b/components/camel-jmx/src/main/java/org/apache/camel/component/jmx/JMXConsumer.java
@@ -239,7 +239,7 @@ public class JMXConsumer extends DefaultConsumer implements NotificationListener
     private ScheduledExecutorService getExecutor() {
         if (this.mScheduledExecutor == null) {
             mScheduledExecutor = mJmxEndpoint.getCamelContext().getExecutorServiceManager()
-                .newSingleThreadScheduledExecutor(this, "connectionExcutor");
+                .newSingleThreadScheduledExecutor(this, "JMXConnectionExecutor");
         }
         return mScheduledExecutor;
     }