camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From conflue...@apache.org
Subject [CONF] Apache Camel > JMX
Date Fri, 14 Sep 2012 14:29:00 GMT
<html>
<head>
    <base href="https://cwiki.apache.org/confluence">
            <link rel="stylesheet" href="/confluence/s/2042/9/1/_/styles/combined.css?spaceKey=CAMEL&amp;forWysiwyg=true"
type="text/css">
    </head>
<body style="background: white;" bgcolor="white" class="email-body">
<div id="pageContent">
<div id="notificationFormat">
<div class="wiki-content">
<div class="email">
    <h2><a href="https://cwiki.apache.org/confluence/display/CAMEL/JMX">JMX</a></h2>
    <h4>Page <b>edited</b> by             <a href="https://cwiki.apache.org/confluence/display/~rnewcomb">Rich
Newcomb</a>
    </h4>
        <br/>
                         <h4>Changes (1)</h4>
                                 
    
<div id="page-diffs">
                    <table class="diff" cellpadding="0" cellspacing="0">
    
            <tr><td class="diff-snipped" >...<br></td></tr>
            <tr><td class="diff-unchanged" >|notificationFilter | | | Reference
to a bean that implements the {{NotificationFilter}}. The #ref syntax should be used to reference
the bean via the [Registry]. | <br>|handback | | | Value to handback to the listener
when a notification is received. This value will be put in the message header with the key
&quot;jmx.handback&quot; | <br></td></tr>
            <tr><td class="diff-added-lines" style="background-color: #dfd;">|testConnectionOnStartup
| | true | *Camel 2.11*  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 &#39;x&#39; seconds until the connection is made – where &#39;x&#39;
is the configured reconnectDelay.| <br>|reconnectOnConnectionFailure | | false | *Camel
2.11*  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 &#39;x&#39;
seconds until the connection is made-- where &#39;x&#39; is the configured reconnectDelay.
| <br>|reconnectDelay | | _10_ seconds | *Camel 2.11*  The number of seconds to wait
before attempting to retry establishment of the initial connection or attempt to reconnect
a lost connection. | <br></td></tr>
            <tr><td class="diff-unchanged" >{div} <br> <br></td></tr>
            <tr><td class="diff-snipped" >...<br></td></tr>
    
            </table>
    </div>                            <h4>Full Content</h4>
                    <div class="notificationGreySide">
        <h2><a name="JMX-JMXComponent"></a>JMX Component</h2>
<p><b>Available as of Camel 2.6</b></p>

<h3><a name="JMX-StandardJMXConsumerConfiguration"></a>Standard JMX Consumer
Configuration</h3>

<p>Component allows consumers to subscribe to an mbean's Notifications. The component
supports passing the Notification object directly through the Exchange or serializing it to
XML according to the schema provided within this project. This is a consumer only component.
Exceptions are thrown if you attempt to create a producer for it.</p>

<p>Maven users will need to add the following dependency to their <tt>pom.xml</tt>
for this component:</p>
<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="code-xml">
<span class="code-tag">&lt;dependency&gt;</span>
    <span class="code-tag">&lt;groupId&gt;</span>org.apache.camel<span
class="code-tag">&lt;/groupId&gt;</span>
    <span class="code-tag">&lt;artifactId&gt;</span>camel-jmx<span
class="code-tag">&lt;/artifactId&gt;</span>
    <span class="code-tag">&lt;version&gt;</span>x.x.x<span class="code-tag">&lt;/version&gt;</span>
    <span class="code-tag"><span class="code-comment">&lt;!-- use the same
version as your Camel core version --&gt;</span></span>
<span class="code-tag">&lt;/dependency&gt;</span>
</pre>
</div></div>

<h4><a name="JMX-URIFormat"></a>URI Format</h4>
<p>The component can connect to the local platform mbean server with the following URI:</p>

<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="code-java">
jmx:<span class="code-comment">//platform?options</span>
</pre>
</div></div>
<p>A remote mbean server url can be provided following the initial JMX scheme like so:</p>

<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="code-java">
jmx:service:jmx:rmi:<span class="code-comment">///jndi/rmi://localhost:1099/jmxrmi?options</span>
</pre>
</div></div>
<p>You can append query options to the URI in the following format, ?options=value&amp;option2=value&amp;...</p>

<h4><a name="JMX-URIOptions"></a>URI Options</h4>
<div class="confluenceTableSmall"><div class='table-wrap'>
<table class='confluenceTable'><tbody>
<tr>
<th class='confluenceTh'>Property </th>
<th class='confluenceTh'> Required </th>
<th class='confluenceTh'> Default </th>
<th class='confluenceTh'> Description </th>
</tr>
<tr>
<td class='confluenceTd'> format  </td>
<td class='confluenceTd'>&nbsp;</td>
<td class='confluenceTd'> xml </td>
<td class='confluenceTd'> 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.</td>
</tr>
<tr>
<td class='confluenceTd'> user </td>
<td class='confluenceTd'>&nbsp;</td>
<td class='confluenceTd'>&nbsp;</td>
<td class='confluenceTd'> Credentials for making a remote connection. </td>
</tr>
<tr>
<td class='confluenceTd'> password </td>
<td class='confluenceTd'>&nbsp;</td>
<td class='confluenceTd'>&nbsp;</td>
<td class='confluenceTd'> Credentials for making a remote connection. </td>
</tr>
<tr>
<td class='confluenceTd'> objectDomain </td>
<td class='confluenceTd'> yes </td>
<td class='confluenceTd'>&nbsp;</td>
<td class='confluenceTd'> The domain for the mbean you're connecting to. </td>
</tr>
<tr>
<td class='confluenceTd'> objectName </td>
<td class='confluenceTd'>&nbsp;</td>
<td class='confluenceTd'>&nbsp;</td>
<td class='confluenceTd'> The name key for the mbean you're connecting to. This value
is mutually exclusive with the object properties that get passed. (see below) </td>
</tr>
<tr>
<td class='confluenceTd'>notificationFilter </td>
<td class='confluenceTd'>&nbsp;</td>
<td class='confluenceTd'>&nbsp;</td>
<td class='confluenceTd'> Reference to a bean that implements the <tt>NotificationFilter</tt>.
The #ref syntax should be used to reference the bean via the <a href="/confluence/display/CAMEL/Registry"
title="Registry">Registry</a>. </td>
</tr>
<tr>
<td class='confluenceTd'>handback </td>
<td class='confluenceTd'>&nbsp;</td>
<td class='confluenceTd'>&nbsp;</td>
<td class='confluenceTd'> 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" </td>
</tr>
<tr>
<td class='confluenceTd'>testConnectionOnStartup </td>
<td class='confluenceTd'>&nbsp;</td>
<td class='confluenceTd'> true </td>
<td class='confluenceTd'> <b>Camel 2.11</b>  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 reconnectDelay.</td>
</tr>
<tr>
<td class='confluenceTd'>reconnectOnConnectionFailure </td>
<td class='confluenceTd'>&nbsp;</td>
<td class='confluenceTd'> false </td>
<td class='confluenceTd'> <b>Camel 2.11</b>  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 reconnectDelay. </td>
</tr>
<tr>
<td class='confluenceTd'>reconnectDelay </td>
<td class='confluenceTd'>&nbsp;</td>
<td class='confluenceTd'> <em>10</em> seconds </td>
<td class='confluenceTd'> <b>Camel 2.11</b>  The number of seconds to wait
before attempting to retry establishment of the initial connection or attempt to reconnect
a lost connection. </td>
</tr>
</tbody></table>
</div>
</div>

<h4><a name="JMX-ObjectNameConstruction"></a>ObjectName Construction</h4>
<p>The URI must always have the objectDomain property. In addition, the URI must contain
either objectName or one or more properties that start with "key."</p>

<h4><a name="JMX-DomainwithNameproperty"></a>Domain with Name property</h4>
<p>When the objectName property is provided, the following constructor is used to build
the ObjectName? for the mbean:</p>

<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="code-java">
ObjectName(<span class="code-object">String</span> domain, <span class="code-object">String</span>
key, <span class="code-object">String</span> value)
</pre>
</div></div>
<p>The key value in the above will be "name" and the value will be the value of the
objectName property.</p>

<h4><a name="JMX-DomainwithHashtable"></a>Domain with Hashtable</h4>
<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="code-java">
ObjectName(<span class="code-object">String</span> domain, Hashtable&lt;<span
class="code-object">String</span>,<span class="code-object">String</span>&gt;
table)
</pre>
</div></div>

<p>The Hashtable is constructed by extracting properties that start with "key." The
properties will have the "key." prefixed stripped prior to building the Hashtable. This allows
the URI to contain a variable number of properties to identify the mbean.</p>

<h4><a name="JMX-Example"></a>Example</h4>
<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="code-java">from(<span class="code-quote">"jmx:platform?objectDomain=jmxExample&amp;key.name=simpleBean"</span>).
        to(<span class="code-quote">"log:jmxEvent"</span>);
</pre>
</div></div>

<p><a href="http://camel.apache.org/jmx-component-example.html" class="external-link"
rel="nofollow">Full example</a></p>

<h3><a name="JMX-MonitorTypeConsumer"></a>Monitor Type Consumer</h3>
<p><b>Available as of Camel 2.8</b><br/>
One popular use case for JMX is creating a monitor bean to monitor an attribute on a deployed
bean. This requires writing a few lines of Java code to create the JMX monitor and deploy
it. As shown below:</p>

<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="code-java">
CounterMonitor monitor = <span class="code-keyword">new</span> CounterMonitor();
monitor.addObservedObject(makeObjectName(<span class="code-quote">"simpleBean"</span>));
monitor.setObservedAttribute(<span class="code-quote">"MonitorNumber"</span>);
monitor.setNotify(<span class="code-keyword">true</span>);
monitor.setInitThreshold(1);
monitor.setGranularityPeriod(500);
registerBean(monitor, makeObjectName(<span class="code-quote">"counter"</span>));
monitor.start();
</pre>
</div></div>

<p>The 2.8 version introduces a new type of consumer that automatically creates and
registers a monitor bean for the specified objectName and attribute. Additional endpoint attributes
allow the user to specify the attribute to monitor, type of monitor to create, and any other
required properties. The code snippet above is condensed into a set of endpoint properties.
The consumer uses these properties to create the CounterMonitor, register it, and then subscribe
to its changes. All of the JMX monitor types are supported.</p>

<h4><a name="JMX-Example"></a>Example</h4>
<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="code-java">
   from(<span class="code-quote">"jmx:platform?objectDomain=myDomain&amp;objectName=simpleBean&amp;"</span>
+ 
        <span class="code-quote">"monitorType=counter&amp;observedAttribute=MonitorNumber&amp;initThreshold=1&amp;"</span>
+
        <span class="code-quote">"granularityPeriod=500"</span>).to(<span class="code-quote">"mock:sink"</span>);
</pre>
</div></div>

<p>The example above will cause a new Monitor Bean to be created and depoyed to the
local mbean server that monitors the "MonitorNumber" attribute on the "simpleBean." Additional
types of monitor beans and options are detailed below. The newly deployed monitor bean is
automatically undeployed when the consumer is stopped. </p>

<h4><a name="JMX-URIOptionsforMonitorType"></a>URI Options for Monitor Type</h4>

<div class='table-wrap'>
<table class='confluenceTable'><tbody>
<tr>
<th class='confluenceTh'>property</th>
<th class='confluenceTh'>type</th>
<th class='confluenceTh'>applies to</th>
<th class='confluenceTh'>description</th>
</tr>
<tr>
<td class='confluenceTd'> monitorType </td>
<td class='confluenceTd'>enum</td>
<td class='confluenceTd'> all </td>
<td class='confluenceTd'>  one of counter, guage, string </td>
</tr>
<tr>
<td class='confluenceTd'> observedAttribute </td>
<td class='confluenceTd'>string</td>
<td class='confluenceTd'> all </td>
<td class='confluenceTd'> the attribute being observed </td>
</tr>
<tr>
<td class='confluenceTd'> granualityPeriod </td>
<td class='confluenceTd'>long</td>
<td class='confluenceTd'> all </td>
<td class='confluenceTd'> granularity period (in millis) for the attribute being observed.
As per JMX, default is 10 seconds </td>
</tr>
<tr>
<td class='confluenceTd'> initThreshold </td>
<td class='confluenceTd'>number</td>
<td class='confluenceTd'> counter </td>
<td class='confluenceTd'> initial threshold value </td>
</tr>
<tr>
<td class='confluenceTd'> offset </td>
<td class='confluenceTd'>number</td>
<td class='confluenceTd'> counter </td>
<td class='confluenceTd'> offset value </td>
</tr>
<tr>
<td class='confluenceTd'> modulus </td>
<td class='confluenceTd'>number</td>
<td class='confluenceTd'> counter </td>
<td class='confluenceTd'> modulus value </td>
</tr>
<tr>
<td class='confluenceTd'> differenceMode </td>
<td class='confluenceTd'> boolean </td>
<td class='confluenceTd'> counter, gauge </td>
<td class='confluenceTd'> true if difference should be reported, false for actual value
</td>
</tr>
<tr>
<td class='confluenceTd'> notifyHigh </td>
<td class='confluenceTd'> boolean </td>
<td class='confluenceTd'> gauge </td>
<td class='confluenceTd'> high notification on/off switch </td>
</tr>
<tr>
<td class='confluenceTd'> notifyLow </td>
<td class='confluenceTd'> boolean </td>
<td class='confluenceTd'> gauge </td>
<td class='confluenceTd'> low notification on/off switch </td>
</tr>
<tr>
<td class='confluenceTd'> highThreshold </td>
<td class='confluenceTd'> number </td>
<td class='confluenceTd'> gauge </td>
<td class='confluenceTd'> threshold for reporting high notification </td>
</tr>
<tr>
<td class='confluenceTd'> lowThreshold </td>
<td class='confluenceTd'> number </td>
<td class='confluenceTd'> gauge </td>
<td class='confluenceTd'> threshold for reporting low notificaton </td>
</tr>
<tr>
<td class='confluenceTd'> notifyDiffer </td>
<td class='confluenceTd'> boolean </td>
<td class='confluenceTd'> string </td>
<td class='confluenceTd'> true to fire notification when string differs </td>
</tr>
<tr>
<td class='confluenceTd'> notifyMatch </td>
<td class='confluenceTd'> boolean </td>
<td class='confluenceTd'> string </td>
<td class='confluenceTd'> true to fire notification when string matches </td>
</tr>
<tr>
<td class='confluenceTd'> stringToCompare </td>
<td class='confluenceTd'> string </td>
<td class='confluenceTd'> string </td>
<td class='confluenceTd'> string to compare against the attribute value </td>
</tr>
</tbody></table>
</div>


<p>The monitor style consumer is only supported for the local mbean server. JMX does
not currently support remote deployment of mbeans without either having the classes already
remotely deployed or an adapter library on both the client and server to facilitate a proxy
deployment.</p>

<h3><a name="JMX-SeeAlso"></a>See Also</h3>
<ul>
	<li><a href="/confluence/display/CAMEL/Configuring+Camel" title="Configuring Camel">Configuring
Camel</a></li>
	<li><a href="/confluence/display/CAMEL/Component" title="Component">Component</a></li>
	<li><a href="/confluence/display/CAMEL/Endpoint" title="Endpoint">Endpoint</a></li>
	<li><a href="/confluence/display/CAMEL/Getting+Started" title="Getting Started">Getting
Started</a></li>
</ul>

<ul class="alternate" type="square">
	<li><a href="/confluence/display/CAMEL/Camel+JMX" title="Camel JMX">Camel JMX</a></li>
</ul>

    </div>
        <div id="commentsSection" class="wiki-content pageSection">
        <div style="float: right;">
            <a href="https://cwiki.apache.org/confluence/users/viewnotifications.action"
class="grey">Change Notification Preferences</a>
        </div>
        <a href="https://cwiki.apache.org/confluence/display/CAMEL/JMX">View Online</a>
        |
        <a href="https://cwiki.apache.org/confluence/pages/diffpagesbyversion.action?pageId=24185433&revisedVersion=5&originalVersion=4">View
Changes</a>
                |
        <a href="https://cwiki.apache.org/confluence/display/CAMEL/JMX?showComments=true&amp;showCommentArea=true#addcomment">Add
Comment</a>
            </div>
</div>
</div>
</div>
</div>
</body>
</html>

Mime
View raw message