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/11 07:30:33 UTC

[camel] branch master updated: CAMEL-12636: Polished camel-jmx

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


The following commit(s) were added to refs/heads/master by this push:
     new a550671  CAMEL-12636: Polished camel-jmx
a550671 is described below

commit a550671d51ff93679b469cf724d489525ad13bd3
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Wed Jul 11 09:30:22 2018 +0200

    CAMEL-12636: Polished camel-jmx
---
 .../camel-jmx/src/main/docs/jmx-component.adoc     | 52 +++++++++---------
 .../apache/camel/component/jmx/JMXEndpoint.java    | 62 +++++++++++-----------
 .../camel/component/jmx/CamelJmxConsumerTest.java  |  4 +-
 3 files changed, 60 insertions(+), 58 deletions(-)

diff --git a/components/camel-jmx/src/main/docs/jmx-component.adoc b/components/camel-jmx/src/main/docs/jmx-component.adoc
index 47517dc..e180f6f 100644
--- a/components/camel-jmx/src/main/docs/jmx-component.adoc
+++ b/components/camel-jmx/src/main/docs/jmx-component.adoc
@@ -52,35 +52,35 @@ with the following path and query parameters:
 |===
 | Name | Description | Default | Type
 | *bridgeErrorHandler* (consumer) | Allows for bridging the consumer to the Camel routing Error Handler, which mean any exceptions occurred while the consumer is trying to pickup incoming messages, or the likes, will now be processed as a message and handled by the routing Error Handler. By default the consumer will use the org.apache.camel.spi.ExceptionHandler to deal with exceptions, that will be logged at WARN or ERROR level and ignored. | false | boolean
-| *format* (consumer) | URI Property: Format for the message body. Either xml or raw. If xml, the notification is serialized to xml. If raw, then the raw java object is set as the body. | xml | String
-| *granularityPeriod* (consumer) | URI Property: monitor types only The frequency to poll the bean to check the monitor. | 10000 | long
-| *monitorType* (consumer) | URI Property: monitor types only The type of monitor to create. One of string, gauge, counter. |  | String
-| *objectDomain* (consumer) | *Required* URI Property: The domain for the mbean you're connecting to |  | String
-| *objectName* (consumer) | URI Property: 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) | URI Property: monitor types only The attribute to observe for the monitor bean. |  | String
+| *format* (consumer) | Format for the message body. Either xml or raw. If xml, the notification is serialized to xml. If raw, then the raw java object is set as the body. | xml | String
+| *granularityPeriod* (consumer) | monitor types only The frequency to poll the bean to check the monitor. | 10000 | long
+| *monitorType* (consumer) | monitor types only The type of monitor to create. One of string, gauge, counter. |  | 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) | monitor types only The attribute to observe for the monitor bean. |  | 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* (consumer) | 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
-| *handback* (advanced) | URI Property: Value to handback to the listener when a notification is received. This value will be put in the message header with the key jmx.handback |  | Object
-| *notificationFilter* (advanced) | URI Property: Reference to a bean that implements the NotificationFilter. |  | NotificationFilter
-| *objectProperties* (advanced) | URI Property: properties for the object name. These values will be used if the objectName param is not set |  | Map
-| *reconnectDelay* (advanced) | URI Property: The number of seconds to wait before attempting to retry establishment of the initial connection or attempt to reconnect a lost connection | 10 | int
-| *reconnectOnConnection Failure* (advanced) | URI Property: 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
+| *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
+| *handback* (advanced) | Value to handback to the listener when a notification is received. This value will be put in the message header with the key jmx.handback |  | Object
+| *notificationFilter* (advanced) | Reference to a bean that implements the NotificationFilter. |  | NotificationFilter
+| *objectProperties* (advanced) | Properties for the object name. These values will be used if the objectName param is not set |  | Map
+| *reconnectDelay* (advanced) | The number of seconds to wait before attempting to retry establishment of the initial connection or attempt to reconnect a lost connection | 10 | int
+| *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) | URI Property: 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
-| *initThreshold* (counter) | URI Property: counter monitor only Initial threshold for the monitor. The value must exceed this before notifications are fired. |  | int
-| *modulus* (counter) | URI Property: counter monitor only The value at which the counter is reset to zero |  | int
-| *offset* (counter) | URI Property: counter monitor only The amount to increment the threshold after it's been exceeded. |  | int
-| *differenceMode* (gauge) | URI Property: counter gauge monitor only If true, then the value reported in the notification is the difference from the threshold as opposed to the value itself. | false | boolean
-| *notifyHigh* (gauge) | URI Property: gauge monitor only If true, the gauge will fire a notification when the high threshold is exceeded | false | boolean
-| *notifyLow* (gauge) | URI Property: gauge monitor only If true, the gauge will fire a notification when the low threshold is exceeded | false | boolean
-| *thresholdHigh* (gauge) | URI Property: gauge monitor only Value for the gauge's high threshold |  | Double
-| *thresholdLow* (gauge) | URI Property: gauge monitor only Value for the gauge's low threshold |  | Double
-| *password* (security) | URI Property: credentials for making a remote connection |  | String
-| *user* (security) | URI Property: credentials for making a remote connection |  | String
-| *notifyDiffer* (string) | URI Property: string monitor only If true, the string monitor will fire a notification when the string attribute differs from the string to compare. | false | boolean
-| *notifyMatch* (string) | URI Property: string monitor only If true, the string monitor will fire a notification when the string attribute matches the string to compare. | false | boolean
-| *stringToCompare* (string) | URI Property: string monitor only Value for the string monitor's string to compare. |  | String
+| *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
+| *initThreshold* (counter) | counter monitor only Initial threshold for the monitor. The value must exceed this before notifications are fired. |  | int
+| *modulus* (counter) | counter monitor only The value at which the counter is reset to zero |  | int
+| *offset* (counter) | counter monitor only The amount to increment the threshold after it's been exceeded. |  | int
+| *differenceMode* (gauge) | counter gauge monitor only If true, then the value reported in the notification is the difference from the threshold as opposed to the value itself. | false | boolean
+| *notifyHigh* (gauge) | gauge monitor only If true, the gauge will fire a notification when the high threshold is exceeded | false | boolean
+| *notifyLow* (gauge) | gauge monitor only If true, the gauge will fire a notification when the low threshold is exceeded | false | boolean
+| *thresholdHigh* (gauge) | gauge monitor only Value for the gauge's high threshold |  | Double
+| *thresholdLow* (gauge) | gauge monitor only Value for the gauge's low threshold |  | Double
+| *password* (security) | Credentials for making a remote connection |  | String
+| *user* (security) | Credentials for making a remote connection |  | String
+| *notifyDiffer* (string) | string monitor only If true, the string monitor will fire a notification when the string attribute differs from the string to compare. | false | boolean
+| *notifyMatch* (string) | string monitor only If true, the string monitor will fire a notification when the string attribute matches the string to compare. | false | boolean
+| *stringToCompare* (string) | string monitor only Value for the string monitor's string to compare. |  | String
 |===
 // endpoint options: END
 
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 6891f20..58757a5 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
@@ -67,154 +67,154 @@ public class JMXEndpoint extends DefaultEndpoint {
     private String serverURL;
 
     /**
-     * URI Property: [monitor types only] The attribute to observe for the monitor bean.  
+     * [monitor types only] The attribute to observe for the monitor bean.
      */
     @UriParam
     private String observedAttribute;
 
     /**
-     * URI Property: [monitor types only] The frequency to poll the bean to check the monitor.  
+     * [monitor types only] The frequency to poll the bean to check the monitor.
      */
     @UriParam(defaultValue = "10000")
     private long granularityPeriod = 10000;
 
     /**
-     * URI Property: [monitor types only] The type of monitor to create. One of string, gauge, counter.  
+     * [monitor types only] The type of monitor to create. One of string, gauge, counter.
      */
     @UriParam(enums = "counter,gauge,string")
     private String monitorType;
 
     /**
-     * URI Property: [counter monitor only] Initial threshold for the monitor. The value must exceed this before notifications are fired.  
+     * [counter monitor only] Initial threshold for the monitor. The value must exceed this before notifications are fired.
      */
     @UriParam(label = "counter")
     private int initThreshold;
 
     /**
-     * URI Property: [counter monitor only] The amount to increment the threshold after it's been exceeded.  
+     * [counter monitor only] The amount to increment the threshold after it's been exceeded.
      */
     @UriParam(label = "counter")
     private int offset;
 
     /**
-     * URI Property: [counter monitor only] The value at which the counter is reset to zero  
+     * [counter monitor only] The value at which the counter is reset to zero
      */
     @UriParam(label = "counter")
     private int modulus;
 
     /**
-     * URI Property: [counter + gauge monitor only] If true, then the value reported in the notification is the difference from the threshold as opposed to the value itself.  
+     * [counter + gauge monitor only] If true, then the value reported in the notification is the difference from the threshold as opposed to the value itself.
      */
     @UriParam(label = "counter,gauge")
     private boolean differenceMode;
 
     /**
-     * URI Property: [gauge monitor only] If true, the gauge will fire a notification when the high threshold is exceeded  
+     * [gauge monitor only] If true, the gauge will fire a notification when the high threshold is exceeded
      */
     @UriParam(label = "gauge")
     private boolean notifyHigh;
 
     /**
-     * URI Property: [gauge monitor only] If true, the gauge will fire a notification when the low threshold is exceeded  
+     * [gauge monitor only] If true, the gauge will fire a notification when the low threshold is exceeded
      */
     @UriParam(label = "gauge")
     private boolean notifyLow;
 
     /**
-     * URI Property: [gauge monitor only] Value for the gauge's high threshold  
+     * [gauge monitor only] Value for the gauge's high threshold
      */
     @UriParam(label = "gauge")
     private Double thresholdHigh;
 
     /**
-     * URI Property: [gauge monitor only] Value for the gauge's low threshold  
+     * [gauge monitor only] Value for the gauge's low threshold
      */
     @UriParam(label = "gauge")
     private Double thresholdLow;
 
     /**
-     * URI Property: [string monitor only] If true, the string monitor will fire a notification when the string attribute differs from the string to compare.  
+     * [string monitor only] If true, the string monitor will fire a notification when the string attribute differs from the string to compare.
      */
     @UriParam(label = "string")
     private boolean notifyDiffer;
 
     /**
-     * URI Property: [string monitor only] If true, the string monitor will fire a notification when the string attribute matches the string to compare.  
+     * [string monitor only] If true, the string monitor will fire a notification when the string attribute matches the string to compare.
      */
     @UriParam(label = "string")
     private boolean notifyMatch;
 
     /**
-     * URI Property: [string monitor only] Value for the string monitor's string to compare.  
+     * [string monitor only] Value for the string monitor's string to compare.
      */
     @UriParam(label = "string")
     private String stringToCompare;
     
     /**
-     * URI Property: Format for the message body. Either "xml" or "raw". If xml, the notification is serialized to xml. If raw, then the raw java object is set as the body.
+     * Format for the message body. Either "xml" or "raw". If xml, the notification is serialized to xml. If raw, then the raw java object is set as the body.
      */
     @UriParam(defaultValue = "xml", enums = "xml,raw")
     private String format = "xml";
 
     /**
-     * URI Property: credentials for making a remote connection
+     * Credentials for making a remote connection
      */
     @UriParam(label = "security", secret = true)
     private String user;
 
     /**
-     * URI Property: credentials for making a remote connection
+     * Credentials for making a remote connection
      */
     @UriParam(label = "security", secret = true)
     private String password;
 
     /**
-     * URI Property: The domain for the mbean you're connecting to
+     * The domain for the mbean you're connecting to
      */
     @UriParam @Metadata(required = "true")
     private String objectDomain;
 
     /**
-     * URI Property: The name key for the mbean you're connecting to. This value is mutually exclusive with the object properties that get passed.
+     * The name key for the mbean you're connecting to. This value is mutually exclusive with the object properties that get passed.
      */
     @UriParam
     private String objectName;
 
     /**
-     * URI Property: Reference to a bean that implements the NotificationFilter.
+     * Reference to a bean that implements the NotificationFilter.
      */
     @UriParam(label = "advanced")
     private NotificationFilter notificationFilter;
 
     /**
-     * URI Property: Value to handback to the listener when a notification is received. This value will be put in the message header with the key "jmx.handback"
+     * Value to handback to the listener when a notification is received. This value will be put in the message header with the key "jmx.handback"
      */
     @UriParam(label = "advanced")
     private Object handback;
     
     /**
-     * URI Property:  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 
+     * 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
      */
     @UriParam(defaultValue = "true", label = "advanced")
     private boolean testConnectionOnStartup = true;
     
     
     /**
-     * URI Property:  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
+     * 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
      */
     @UriParam(label = "advanced")
     private boolean reconnectOnConnectionFailure;
      
-     /**
-      * URI Property:  The number of seconds to wait before attempting to retry establishment of the initial connection or attempt to reconnect a lost connection
-      */
+    /**
+     * The number of seconds to wait before attempting to retry establishment of the initial connection or attempt to reconnect a lost connection
+     */
     @UriParam(defaultValue = "10", label = "advanced")
     private int reconnectDelay = 10;
 
     /**
-     * URI Property: properties for the object name. These values will be used if the objectName param is not set
+     * Properties for the object name. These values will be used if the objectName param is not set
      */
     @UriParam(label = "advanced", prefix = "key.", multiValue = true)
     private Map<String, String> objectProperties;
@@ -222,11 +222,11 @@ public class JMXEndpoint extends DefaultEndpoint {
     /**
      * To use a custom shared thread pool for the consumers. By default each consume has their own thread-pool to process and route notifications.
      */
-    @UriParam(label = "consumer,advanced")
+    @UriParam(label = "advanced")
     private ExecutorService executorService;
 
     /**
-     * cached object name that was built from the objectName param or the hashtable
+     * Cached object name that was built from the objectName param or the hashtable
      */
     private transient ObjectName jmxObjectName;
 
diff --git a/components/camel-jmx/src/test/java/org/apache/camel/component/jmx/CamelJmxConsumerTest.java b/components/camel-jmx/src/test/java/org/apache/camel/component/jmx/CamelJmxConsumerTest.java
index eb50602..5e729df 100644
--- a/components/camel-jmx/src/test/java/org/apache/camel/component/jmx/CamelJmxConsumerTest.java
+++ b/components/camel-jmx/src/test/java/org/apache/camel/component/jmx/CamelJmxConsumerTest.java
@@ -46,7 +46,9 @@ public class CamelJmxConsumerTest extends CamelTestSupport {
         return new RouteBuilder() {
             @Override
             public void configure() throws Exception {
-                from("jmx:platform?objectDomain=org.apache.camel&key.context=camel-1&key.type=routes&key.name=\"foo\"").routeId("jmxRoute")
+                String id = getContext().getName();
+
+                fromF("jmx:platform?objectDomain=org.apache.camel&key.context=%s&key.type=routes&key.name=\"foo\"", id).routeId("jmxRoute")
                     .to("log:jmx")
                     .to("mock:result");