camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From conflue...@apache.org
Subject [CONF] Apache Camel > Camel JMX
Date Tue, 28 Jul 2009 08:32:00 GMT
<html>
<head>
    <base href="http://cwiki.apache.org/confluence">
            <link rel="stylesheet" href="/confluence/s/1519/1/1/_/styles/combined.css?spaceKey=CAMEL&amp;forWysiwyg=true"
type="text/css">
    </head>
<body style="background-color: white" bgcolor="white">
<div id="pageContent">
<div id="notificationFormat">
<div class="wiki-content">
<div class="email">
     <h2><a href="http://cwiki.apache.org/confluence/display/CAMEL/Camel+JMX">Camel
JMX</a></h2>
     <h4>Page <b>edited</b> by             <a href="http://cwiki.apache.org/confluence/display/~davsclaus">Claus
Ibsen</a>
    </h4>
     
          <br/>
     <div class="notificationGreySide">
         <h2><a name="CamelJMX-CamelJMX"></a>Camel JMX</h2>

<p>Apache Camel has extensive support for JMX to allow you to monitor and control the
Camel managed objects a JMX client.</p>

<div>
<ul>
    <li><a href='#CamelJMX-CamelJMX'>Camel JMX</a></li>
<ul>
    <li><a href='#CamelJMX-SpringDependency'>Spring Dependency</a></li>
    <li><a href='#CamelJMX-UsingJMXtomanageApacheCamel'>Using JMX to manage Apache
Camel</a></li>
    <li><a href='#CamelJMX-DisablingJMXinstrumentationagentinCamel'>Disabling
JMX instrumentation agent in Camel</a></li>
    <li><a href='#CamelJMX-LocatingaMBeanServerintheJavaVM'>Locating a MBeanServer
in the Java VM</a></li>
    <li><a href='#CamelJMX-CreatingJMXRMIConnectorServer'>Creating JMX RMI Connector
Server</a></li>
    <li><a href='#CamelJMX-JMXServiceURL'>JMX Service URL</a></li>
    <li><a href='#CamelJMX-UsingJConsoletomonitorCamel'>Using JConsole to monitor
Camel</a></li>
    <li><a href='#CamelJMX-TheSystemPropertiesforCamelJMXsupport'>The SystemProperties
for Camel JMX support</a></li>
    <li><a href='#CamelJMX-JMXinsideanApplicationServer'>JMX inside an Application
Server</a></li>
<ul>
    <li><a href='#CamelJMX-JBossAS4'>JBoss AS 4</a></li>
    <li><a href='#CamelJMX-WebSphere'>WebSphere</a></li>
</ul>
    <li><a href='#CamelJMX-AdvancedJMXConfiguration'>Advanced JMX Configuration</a></li>
<ul>
    <li><a href='#CamelJMX-Example%3A'>Example:</a></li>
    <li><a href='#CamelJMX-jmxAgentPropertiesReference'>jmxAgent Properties Reference</a></li>
</ul>
    <li><a href='#CamelJMX-RegisteringyourownManagedEndpoints'>Registering your
own Managed Endpoints</a></li>
</ul>
</ul></div>

<h3><a name="CamelJMX-SpringDependency"></a>Spring Dependency</h3>
<p><b>spring-context.jar</b> is needed on the classpath by Camel to be able
to use JMX instrumentation. If this .jar is <b>not</b> on the classpath Camel
will fallback to non JMX mode. This situation is logged at <tt>WARN</tt> level
using logger name <tt>org.apache.camel.impl.DefaultCamelContext</tt>.</p>

<h3><a name="CamelJMX-UsingJMXtomanageApacheCamel"></a>Using JMX to manage
Apache Camel</h3>

<div class='panelMacro'><table class='warningMacro'><colgroup><col width='24'><col></colgroup><tr><td
valign='top'><img src="/confluence/images/icons/emoticons/forbidden.gif" width="16"
height="16" align="absmiddle" alt="" border="0"></td><td><b>Some platforms
do not allow access to its platform mbean server</b><br /><p>The Oracle
OC4J J2EE application server will not allow Camel to access the platform mbean server. You
can identify this in the log as Camel will log a WARNING.</p>
<style type="text/css">
@import url(/confluence/download/resources/confluence.ext.code:code/shStyles.css);
</style>
<!--[if IE]>
<style type="text/css">
    .code textarea, .code input { padding: 0 !important; }
</style>
<![endif]-->
<script class="javascript" src="/confluence/download/resources/confluence.ext.code:code/shCore.js"></script>
<script class="javascript" src="/confluence/download/resources/confluence.ext.code:code/shBrushCSharp.js"></script>
<script class="javascript" src="/confluence/download/resources/confluence.ext.code:code/shBrushPhp.js"></script>
<script class="javascript" src="/confluence/download/resources/confluence.ext.code:code/shBrushJScript.js"></script>
<script class="javascript" src="/confluence/download/resources/confluence.ext.code:code/shBrushVb.js"></script>
<script class="javascript" src="/confluence/download/resources/confluence.ext.code:code/shBrushSql.js"></script>
<script class="javascript" src="/confluence/download/resources/confluence.ext.code:code/shBrushXml.js"></script>
<script class="javascript" src="/confluence/download/resources/confluence.ext.code:code/shBrushShell.js"></script>
<script class="javascript" src="/confluence/download/resources/confluence.ext.code:code/shBrushDelphi.js"></script>
<script class="javascript" src="/confluence/download/resources/confluence.ext.code:code/shBrushPython.js"></script>
<script class="javascript" src="/confluence/download/resources/confluence.ext.code:code/shBrushJava.js"></script>
<div class="code">
<textarea name="newcodemacro" class="java:nocontrols:nogutter" rows="10" readonly="readonly">xxx
xx, xxxx xx:xx:xx xx org.apache.camel.management.InstrumentationLifecycleStrategy onContextStart
WARNING: Could not register CamelContext MBean
java.lang.SecurityException: Unauthorized access from application: xx to MBean: java.lang:type=ClassLoading
        at oracle.oc4j.admin.jmx.shared.UserMBeanServer.checkRegisterAccess(UserMBeanServer.java:873)</textarea>
<script class="javascript">
    if(!window.newcodemacro_initialised)
    {
        window.newcodemacro_initialised = true;
        window.oldonloadmethod = window.onload;
        window.onload = function(){
            dp.SyntaxHighlighter.HighlightAll('newcodemacro');
            if(window.oldonloadmethod)
            {
                window.oldonloadmethod();
            }
        }
    }

</script>
</div>

<p>To resolve this you should disable the JMX agent in Camel, see section <em>Disabling
JMX instrumentation agent in Camel</em></p></td></tr></table></div>

<p>By default, JMX instrumentation agent is enabled in Camel which means that Camel
runtime creates and registers MBean management objects with a MBeanServer instance in the
VM. This allows Camel users instantly obtain insights into how Camel routes perform down to
the individual processor's level.</p>

<p>The supported types of management objects are <a href="http://activemq.apache.org/camel/maven/camel-core/apidocs/org/apache/camel/management/ManagedEndpoint.html"
rel="nofollow">endpoint </a>, <a href="http://activemq.apache.org/camel/maven/camel-core/apidocs/org/apache/camel/management/ManagedRoute.html"
rel="nofollow">route</a>, <a href="http://activemq.apache.org/camel/maven/camel-core/apidocs/org/apache/camel/management/ManagedService.html"
rel="nofollow">service</a>, and <a href="http://activemq.apache.org/camel/maven/camel-core/apidocs/org/apache/camel/management/PerformanceCounter.html"
rel="nofollow">processor</a>. Some of these management objects also expose lifecycle
operations in addition to performance counter attributes.</p>

<p>The <a href="http://activemq.apache.org/camel/maven/camel-core/apidocs/org/apache/camel/management/CamelNamingStrategy.html"
rel="nofollow">CamelNamingStrategy</a> is the default naming strategy which builds
object names used for MBean registration. By default, <b>org.apache.camel</b>
is the domain name for all object names created by CamelNamingStrategy. The domain name of
the MBean object can be configured by Java VM system property:</p>
<div class="code">
<textarea name="newcodemacro" class="java:nocontrols:nogutter" rows="10" readonly="readonly">-Dorg.apache.camel.jmx.mbeanObjectDomainName=your.domain.name</textarea>
<script class="javascript">
    if(!window.newcodemacro_initialised)
    {
        window.newcodemacro_initialised = true;
        window.oldonloadmethod = window.onload;
        window.onload = function(){
            dp.SyntaxHighlighter.HighlightAll('newcodemacro');
            if(window.oldonloadmethod)
            {
                window.oldonloadmethod();
            }
        }
    }

</script>
</div>

<p>Or, by adding a <b>jmxAgent</b> element inside the camelContext element
in Spring configuration:</p>
<div class="code">
<textarea name="newcodemacro" class="java:nocontrols:nogutter" rows="10" readonly="readonly">&lt;camelContext
id="camel" xmlns="http://activemq.apache.org/camel/schema/spring"&gt;
  &lt;jmxAgent id="agent" mbeanObjectDomainName="your.domain.name"/&gt;
    ...
&lt;/camelContext&gt;</textarea>
<script class="javascript">
    if(!window.newcodemacro_initialised)
    {
        window.newcodemacro_initialised = true;
        window.oldonloadmethod = window.onload;
        window.onload = function(){
            dp.SyntaxHighlighter.HighlightAll('newcodemacro');
            if(window.oldonloadmethod)
            {
                window.oldonloadmethod();
            }
        }
    }

</script>
</div>

<p>Spring configuration always takes precedence over system properties when they both
present. It is true for all of JMX related configurations.</p>

<h3><a name="CamelJMX-DisablingJMXinstrumentationagentinCamel"></a>Disabling
JMX instrumentation agent in Camel</h3>

<p>You can disable JMX instrumentation agent by setting Java VM system property as follow.
The property value is treated as boolean.</p>
<div class="code">
<textarea name="newcodemacro" class="java:nocontrols:nogutter" rows="10" readonly="readonly">-Dorg.apache.camel.jmx.disabled=True</textarea>
<script class="javascript">
    if(!window.newcodemacro_initialised)
    {
        window.newcodemacro_initialised = true;
        window.oldonloadmethod = window.onload;
        window.onload = function(){
            dp.SyntaxHighlighter.HighlightAll('newcodemacro');
            if(window.oldonloadmethod)
            {
                window.oldonloadmethod();
            }
        }
    }

</script>
</div>

<p>Or, by adding a <b>jmxAgent</b> element inside the camelContext element
in Spring configuration:</p>
<div class="code">
<textarea name="newcodemacro" class="java:nocontrols:nogutter" rows="10" readonly="readonly">&lt;camelContext
id="camel" xmlns="http://activemq.apache.org/camel/schema/spring"&gt;
  &lt;jmxAgent id="agent" disabled="true"/&gt;
    ...
&lt;/camelContext&gt;</textarea>
<script class="javascript">
    if(!window.newcodemacro_initialised)
    {
        window.newcodemacro_initialised = true;
        window.oldonloadmethod = window.onload;
        window.onload = function(){
            dp.SyntaxHighlighter.HighlightAll('newcodemacro');
            if(window.oldonloadmethod)
            {
                window.oldonloadmethod();
            }
        }
    }

</script>
</div>


<h3><a name="CamelJMX-LocatingaMBeanServerintheJavaVM"></a>Locating a MBeanServer
in the Java VM</h3>

<p>Each CamelContext can have an instance of <a href="http://activemq.apache.org/camel/maven/camel-core/apidocs/org/apache/camel/spi/InstrumentationAgent.html"
rel="nofollow">InstrumentationAgent</a> wrapped insider the <a href="http://activemq.apache.org/camel/maven/camel-core/apidocs/org/apache/camel/management/InstrumentationLifecycleStrategy.html"
rel="nofollow">InstrumentationLifecycleStrategy</a>. The InstrumentationAgent is
the object that interfaces with a <a href="http://java.sun.com/j2se/1.5.0/docs/api/javax/management/MBeanServer.html"
rel="nofollow">MBeanServer</a> to register/unregister Camel MBeans. Multiple CamelContexts/InstrumentationAgents
can/should share a MBeanServer. By default, Camel runtime picks the first MBeanServer returned
by <a href="http://java.sun.com/j2se/1.5.0/docs/api/javax/management/MBeanServerFactory.html#findMBeanServer(java.lang.String)"
rel="nofollow">MBeanServerFactory.findMBeanServer method</a> that matches the default
domain name of <b>org.apache.camel</b>.&nbsp; You may want to change the default
domain name to match the MBeanServer instance that you are already using in your application.&nbsp;
Especially, if your MBeanServer is attached to a JMX connector server, you will not need to
create a connector server in Camel.</p>

<p>You can configure the matching default domain name via system property.</p>
<div class="code">
<textarea name="newcodemacro" class="java:nocontrols:nogutter" rows="10" readonly="readonly">-Dorg.apache.camel.jmx.mbeanServerDefaultDomain=&lt;your.domain.name&gt;</textarea>
<script class="javascript">
    if(!window.newcodemacro_initialised)
    {
        window.newcodemacro_initialised = true;
        window.oldonloadmethod = window.onload;
        window.onload = function(){
            dp.SyntaxHighlighter.HighlightAll('newcodemacro');
            if(window.oldonloadmethod)
            {
                window.oldonloadmethod();
            }
        }
    }

</script>
</div>

<p>Or, by adding a <b>jmxAgent</b> element inside the camelContext element
in Spring configuration:</p>
<div class="code">
<textarea name="newcodemacro" class="java:nocontrols:nogutter" rows="10" readonly="readonly">&lt;camelContext
id="camel" xmlns="http://activemq.apache.org/camel/schema/spring"&gt;
  &lt;jmxAgent id="agent" mbeanServerDefaultDomain="your.domain.name"/&gt;
    ...
&lt;/camelContext&gt;</textarea>
<script class="javascript">
    if(!window.newcodemacro_initialised)
    {
        window.newcodemacro_initialised = true;
        window.oldonloadmethod = window.onload;
        window.onload = function(){
            dp.SyntaxHighlighter.HighlightAll('newcodemacro');
            if(window.oldonloadmethod)
            {
                window.oldonloadmethod();
            }
        }
    }

</script>
</div>

<p>If no matching MBeanServer can be found, a new one is created and the new MBeanServer's
default domain name is set according to the default and configuration as mentioned above.</p>

<p>It is also possible to use the <a href="http://java.sun.com/j2se/1.5.0/docs/api/java/lang/management/ManagementFactory.html#getPlatformMBeanServer()"
rel="nofollow">PlatformMBeanServer</a> when it is desirable to manage JVM MBeans&nbsp;by
setting the system property.&nbsp; The MBeanServer default domain name configuration is
ignored as it is not applicable.&nbsp; <b>Starting in next release (1.5), the default
value of usePlatformMBeanServer will be changed to "True".&nbsp; You can set the property
to "False" to disable using platform MBean server.</b></p>
<div class="code">
<textarea name="newcodemacro" class="java:nocontrols:nogutter" rows="10" readonly="readonly">-Dorg.apache.camel.jmx.usePlatformMBeanServer=True</textarea>
<script class="javascript">
    if(!window.newcodemacro_initialised)
    {
        window.newcodemacro_initialised = true;
        window.oldonloadmethod = window.onload;
        window.onload = function(){
            dp.SyntaxHighlighter.HighlightAll('newcodemacro');
            if(window.oldonloadmethod)
            {
                window.oldonloadmethod();
            }
        }
    }

</script>
</div>

<p>Or, by adding a <b>jmxAgent</b> element inside the camelContext element
in Spring configuration:</p>
<div class="code">
<textarea name="newcodemacro" class="java:nocontrols:nogutter" rows="10" readonly="readonly">&lt;camelContext
id="camel" xmlns="http://activemq.apache.org/camel/schema/spring"&gt;
  &lt;jmxAgent id="agent" usePlatformMBeanServer="true"/&gt;
    ...
&lt;/camelContext&gt;</textarea>
<script class="javascript">
    if(!window.newcodemacro_initialised)
    {
        window.newcodemacro_initialised = true;
        window.oldonloadmethod = window.onload;
        window.onload = function(){
            dp.SyntaxHighlighter.HighlightAll('newcodemacro');
            if(window.oldonloadmethod)
            {
                window.oldonloadmethod();
            }
        }
    }

</script>
</div>


<h3><a name="CamelJMX-CreatingJMXRMIConnectorServer"></a>Creating JMX RMI
Connector Server</h3>

<p>JMX connector server enables MBeans to be remotely managed by a JMX client such as
JConsole.&nbsp; Camel JMX RMI connector server can be optionally turned on by setting
system property and the MBeanServer used by Camel is attached to that connector server.</p>
<div class="code">
<textarea name="newcodemacro" class="java:nocontrols:nogutter" rows="10" readonly="readonly">-Dorg.apache.camel.jmx.createRmiConnector=True</textarea>
<script class="javascript">
    if(!window.newcodemacro_initialised)
    {
        window.newcodemacro_initialised = true;
        window.oldonloadmethod = window.onload;
        window.onload = function(){
            dp.SyntaxHighlighter.HighlightAll('newcodemacro');
            if(window.oldonloadmethod)
            {
                window.oldonloadmethod();
            }
        }
    }

</script>
</div>

<p>Or, by adding a <b>jmxAgent</b> element inside the camelContext element
in Spring configuration:</p>
<div class="code">
<textarea name="newcodemacro" class="java:nocontrols:nogutter" rows="10" readonly="readonly">&lt;camelContext
id="camel" xmlns="http://activemq.apache.org/camel/schema/spring"&gt;
  &lt;jmxAgent id="agent" createConnector="true"/&gt;
    ...
&lt;/camelContext&gt;</textarea>
<script class="javascript">
    if(!window.newcodemacro_initialised)
    {
        window.newcodemacro_initialised = true;
        window.oldonloadmethod = window.onload;
        window.onload = function(){
            dp.SyntaxHighlighter.HighlightAll('newcodemacro');
            if(window.oldonloadmethod)
            {
                window.oldonloadmethod();
            }
        }
    }

</script>
</div>


<h3><a name="CamelJMX-JMXServiceURL"></a>JMX Service URL</h3>

<p>The default JMX Service URL has the format:</p>
<div class="code">
<textarea name="newcodemacro" class="java:nocontrols:nogutter" rows="10" readonly="readonly">service:jmx:rmi:///jndi/rmi://localhost:&lt;registryPort&gt;/&lt;serviceUrlPath&gt;</textarea>
<script class="javascript">
    if(!window.newcodemacro_initialised)
    {
        window.newcodemacro_initialised = true;
        window.oldonloadmethod = window.onload;
        window.onload = function(){
            dp.SyntaxHighlighter.HighlightAll('newcodemacro');
            if(window.oldonloadmethod)
            {
                window.oldonloadmethod();
            }
        }
    }

</script>
</div>

<p><em>registryPort</em> is the RMI registry port and the default value
is <b>1099</b>.</p>

<p>You can set the RMI registry port by system property.</p>
<div class="code">
<textarea name="newcodemacro" class="java:nocontrols:nogutter" rows="10" readonly="readonly">-Dorg.apache.camel.jmx.rmiConnector.registryPort=&lt;port
number&gt;</textarea>
<script class="javascript">
    if(!window.newcodemacro_initialised)
    {
        window.newcodemacro_initialised = true;
        window.oldonloadmethod = window.onload;
        window.onload = function(){
            dp.SyntaxHighlighter.HighlightAll('newcodemacro');
            if(window.oldonloadmethod)
            {
                window.oldonloadmethod();
            }
        }
    }

</script>
</div>

<p>Or, by adding a <b>jmxAgent</b> element inside the camelContext element
in Spring configuration:</p>
<div class="code">
<textarea name="newcodemacro" class="java:nocontrols:nogutter" rows="10" readonly="readonly">&lt;camelContext
id="camel" xmlns="http://activemq.apache.org/camel/schema/spring"&gt;
  &lt;jmxAgent id="agent" createConnector="true" registryPort="port number"/&gt;
    ...
&lt;/camelContext&gt;</textarea>
<script class="javascript">
    if(!window.newcodemacro_initialised)
    {
        window.newcodemacro_initialised = true;
        window.oldonloadmethod = window.onload;
        window.onload = function(){
            dp.SyntaxHighlighter.HighlightAll('newcodemacro');
            if(window.oldonloadmethod)
            {
                window.oldonloadmethod();
            }
        }
    }

</script>
</div>

<p><em>serviceUrlPath</em> is the path name in the URL and the default value
is <b>/jmxrmi/camel</b>.</p>

<p>You can set the service URL path by system property.</p>
<div class="code">
<textarea name="newcodemacro" class="java:nocontrols:nogutter" rows="10" readonly="readonly">-Dorg.apache.camel.jmx.serviceUrlPath=&lt;path&gt;</textarea>
<script class="javascript">
    if(!window.newcodemacro_initialised)
    {
        window.newcodemacro_initialised = true;
        window.oldonloadmethod = window.onload;
        window.onload = function(){
            dp.SyntaxHighlighter.HighlightAll('newcodemacro');
            if(window.oldonloadmethod)
            {
                window.oldonloadmethod();
            }
        }
    }

</script>
</div>

<p>Or, by adding a <b>jmxAgent</b> element inside the camelContext element
in Spring configuration:</p>
<div class="code">
<textarea name="newcodemacro" class="java:nocontrols:nogutter" rows="10" readonly="readonly">&lt;camelContext
id="camel" xmlns="http://activemq.apache.org/camel/schema/spring"&gt;
  &lt;jmxAgent id="agent" createConnector="true" serviceUrlPath="path"/&gt;
    ...
&lt;/camelContext&gt;</textarea>
<script class="javascript">
    if(!window.newcodemacro_initialised)
    {
        window.newcodemacro_initialised = true;
        window.oldonloadmethod = window.onload;
        window.onload = function(){
            dp.SyntaxHighlighter.HighlightAll('newcodemacro');
            if(window.oldonloadmethod)
            {
                window.oldonloadmethod();
            }
        }
    }

</script>
</div>

<p>By default, RMI server object listens on a dynamically generated port which can be
a problem for connection established through a firewall. In such situation, RMI connection
port can be explicitly set by the system property.</p>
<div class="code">
<textarea name="newcodemacro" class="java:nocontrols:nogutter" rows="10" readonly="readonly">-Dorg.apache.camel.jmx.rmiConnector.connectorPort=&lt;port
number&gt;</textarea>
<script class="javascript">
    if(!window.newcodemacro_initialised)
    {
        window.newcodemacro_initialised = true;
        window.oldonloadmethod = window.onload;
        window.onload = function(){
            dp.SyntaxHighlighter.HighlightAll('newcodemacro');
            if(window.oldonloadmethod)
            {
                window.oldonloadmethod();
            }
        }
    }

</script>
</div>

<p>Or, by adding a <b>jmxAgent</b> element inside the camelContext element
in Spring configuration:</p>
<div class="code">
<textarea name="newcodemacro" class="java:nocontrols:nogutter" rows="10" readonly="readonly">&lt;camelContext
id="camel" xmlns="http://activemq.apache.org/camel/schema/spring"&gt;
  &lt;jmxAgent id="agent" createConnector="true" connectorPort="port number"/&gt;
    ...
&lt;/camelContext&gt;</textarea>
<script class="javascript">
    if(!window.newcodemacro_initialised)
    {
        window.newcodemacro_initialised = true;
        window.oldonloadmethod = window.onload;
        window.onload = function(){
            dp.SyntaxHighlighter.HighlightAll('newcodemacro');
            if(window.oldonloadmethod)
            {
                window.oldonloadmethod();
            }
        }
    }

</script>
</div>

<p>When the connector port option is set, the JMX service URL will become:</p>
<div class="code">
<textarea name="newcodemacro" class="java:nocontrols:nogutter" rows="10" readonly="readonly">service:jmx:rmi://localhost:&lt;connectorPort&gt;/jndi/rmi://localhost:&lt;registryPort&gt;/&lt;serviceUrlPath&gt;</textarea>
<script class="javascript">
    if(!window.newcodemacro_initialised)
    {
        window.newcodemacro_initialised = true;
        window.oldonloadmethod = window.onload;
        window.onload = function(){
            dp.SyntaxHighlighter.HighlightAll('newcodemacro');
            if(window.oldonloadmethod)
            {
                window.oldonloadmethod();
            }
        }
    }

</script>
</div>


<h3><a name="CamelJMX-UsingJConsoletomonitorCamel"></a>Using JConsole to
monitor Camel</h3>

<p>The CamelContext should appear in the list of local connections, if you are running
JConsole on the same host as Camel.</p>

<p>To connect to a remote Camel instance, or if the local process does not show up,
use Remote Process option, and enter an URL. Here is an example localhost URL:</p>
<div class="code">
<textarea name="newcodemacro" class="java:nocontrols:nogutter" rows="10" readonly="readonly">service:jmx:rmi:///jndi/rmi://localhost:1099/jmxrmi/camel</textarea>
<script class="javascript">
    if(!window.newcodemacro_initialised)
    {
        window.newcodemacro_initialised = true;
        window.oldonloadmethod = window.onload;
        window.onload = function(){
            dp.SyntaxHighlighter.HighlightAll('newcodemacro');
            if(window.oldonloadmethod)
            {
                window.oldonloadmethod();
            }
        }
    }

</script>
</div>

<p>Using the Apache Camel which Jconsole<br/>
<a class="confluence-thumbnail-link 910x679" href='http://cwiki.apache.org/confluence/download/attachments/85697/camel-jmx.png'><img
src="/confluence/download/thumbnails/85697/camel-jmx.png" align="absmiddle" border="0" title="updated
version after fix for camel-865" /></a><br/>
&nbsp;</p>

<h3><a name="CamelJMX-TheSystemPropertiesforCamelJMXsupport"></a>The SystemProperties
for Camel JMX support</h3>

<table class='confluenceTable'><tbody>
<tr>
<th class='confluenceTh'> Property Name </th>
<th class='confluenceTh'> value </th>
<th class='confluenceTh'> Description </th>
</tr>
<tr>
<td class='confluenceTd'> org.apache.camel.jmx </td>
<td class='confluenceTd'> true or false </td>
<td class='confluenceTd'> if is true , it will enable jmx feature in Camel </td>
</tr>
</tbody></table>

<p>See more system properties in this section below: <em>jmxAgent Properties Reference</em></p>

<h3><a name="CamelJMX-JMXinsideanApplicationServer"></a>JMX inside an Application
Server</h3>

<h4><a name="CamelJMX-JBossAS4"></a>JBoss AS 4</h4>

<p>By default JBoss creates its own MBean server.  To allow Camel to expose to the same
server follow these steps:</p>

<p>1. Tell Camel to use the Platform MBean Server (This defaults to true in Camel 1.5)</p>
<div class="code">
<textarea name="newcodemacro" class="java:nocontrols:nogutter" rows="10" readonly="readonly">&lt;camel:camelContext
id="camelContext"&gt;
  &lt;camel:jmxAgent id="jmxAgent" mbeanObjectDomainName="org.yourname" usePlatformMBeanServer="true"
 /&gt;
&lt;/camel:camelContext&gt;</textarea>
<script class="javascript">
    if(!window.newcodemacro_initialised)
    {
        window.newcodemacro_initialised = true;
        window.oldonloadmethod = window.onload;
        window.onload = function(){
            dp.SyntaxHighlighter.HighlightAll('newcodemacro');
            if(window.oldonloadmethod)
            {
                window.oldonloadmethod();
            }
        }
    }

</script>
</div>


<p>2. Alter your JBoss instance to use the Platform MBean server.<br/>
Add the following property to your JAVA_OPTS by editing run.sh or run.conf {{ -Djboss.platform.mbeanserver
}} See <a href="http://wiki.jboss.org/wiki/JBossMBeansInJConsole" rel="nofollow">http://wiki.jboss.org/wiki/JBossMBeansInJConsole</a></p>

<h4><a name="CamelJMX-WebSphere"></a>WebSphere</h4>

<p>Alter the mbeanServerDefaultDomain to be "WebSphere"</p>

<div class="code">
<textarea name="newcodemacro" class="java:nocontrols:nogutter" rows="10" readonly="readonly">&lt;camel:jmxAgent
id="agent" createConnector="true" mbeanObjectDomainName="org.yourname" mbeanServerDefaultDomain="WebSphere"/&gt;</textarea>
<script class="javascript">
    if(!window.newcodemacro_initialised)
    {
        window.newcodemacro_initialised = true;
        window.oldonloadmethod = window.onload;
        window.onload = function(){
            dp.SyntaxHighlighter.HighlightAll('newcodemacro');
            if(window.oldonloadmethod)
            {
                window.oldonloadmethod();
            }
        }
    }

</script>
</div>



<h3><a name="CamelJMX-AdvancedJMXConfiguration"></a>Advanced JMX Configuration</h3>

<p>The spring configuration file allows you to configure how Camel is exposed to JMX
for management. In some cases, you could specify more information here, like the connector's
port or the path name.</p>

<h4><a name="CamelJMX-Example%3A"></a>Example:</h4>

<div class="code">
<textarea name="newcodemacro" class="java:nocontrols:nogutter" rows="10" readonly="readonly">&lt;camelContext
id="camel" xmlns="http://activemq.apache.org/camel/schema/spring"&gt;
  &lt;jmxAgent id="agent" createConnector="true" registryPort="2000" mbeanServerDefaultDomain="org.apache.camel.test"/&gt;
    &lt;route&gt;
      &lt;from uri="seda:start"/&gt;
      &lt;to uri="mock:result"/&gt;
    &lt;/route&gt;
&lt;/camelContext&gt;</textarea>
<script class="javascript">
    if(!window.newcodemacro_initialised)
    {
        window.newcodemacro_initialised = true;
        window.oldonloadmethod = window.onload;
        window.onload = function(){
            dp.SyntaxHighlighter.HighlightAll('newcodemacro');
            if(window.oldonloadmethod)
            {
                window.oldonloadmethod();
            }
        }
    }

</script>
</div>

<p>If you wish to change the Java 5 JMX settings you can use various <a href="http://java.sun.com/j2se/1.5.0/docs/guide/management/agent.html#properties"
rel="nofollow">JMX system properties</a></p>

<p>For example you can enable remote JMX connections to the Sun JMX connector, via setting
the following environment variable (using <b>set</b> or <b>export</b>
depending on your platform). These settings only configure the Sun JMX connector within Java
1.5+, not the JMX connector that Camel creates by default.</p>
<div class="code">
<textarea name="newcodemacro" class="java:nocontrols:nogutter" rows="10" readonly="readonly">SUNJMX=-Dcom.sun.management.jmxremote=true
-Dcom.sun.management.jmxremote.port=1616 \
-Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.ssl=false</textarea>
<script class="javascript">
    if(!window.newcodemacro_initialised)
    {
        window.newcodemacro_initialised = true;
        window.oldonloadmethod = window.onload;
        window.onload = function(){
            dp.SyntaxHighlighter.HighlightAll('newcodemacro');
            if(window.oldonloadmethod)
            {
                window.oldonloadmethod();
            }
        }
    }

</script>
</div>

<p>(The SUNJMX environment variable is simple used by the startup script for Camel,
as additional startup parameters for the JVM. If you start Camel directly, you'll have to
pass these parameters yourself.)</p>

<h4><a name="CamelJMX-jmxAgentPropertiesReference"></a>jmxAgent Properties
Reference</h4>

<table class='confluenceTable'><tbody>
<tr>
<th class='confluenceTh'> Spring property </th>
<th class='confluenceTh'> System property </th>
<th class='confluenceTh'> Default Value </th>
<th class='confluenceTh'> Description </th>
</tr>
<tr>
<td class='confluenceTd'> id </td>
<td class='confluenceTd'>&nbsp;</td>
<td class='confluenceTd'>&nbsp;</td>
<td class='confluenceTd'> The JMX agent name, and it is not optional </td>
</tr>
<tr>
<td class='confluenceTd'> usePlatformMBeanServer </td>
<td class='confluenceTd'> org.apache.camel.jmx.usePlatformMBeanServer </td>
<td class='confluenceTd'> false, true - Release 1.5 or later </td>
<td class='confluenceTd'> If true then it will use the plateform MBean server form the
JVM </td>
</tr>
<tr>
<td class='confluenceTd'> mbeanServerDefaultDomain </td>
<td class='confluenceTd'> org.apache.camel.jmx.mbeanServerDefaultDomain </td>
<td class='confluenceTd'> org.apache.camel </td>
<td class='confluenceTd'> The default JMX domain of the MBeanServer </td>
</tr>
<tr>
<td class='confluenceTd'> mbeanObjectDomainName </td>
<td class='confluenceTd'> org.apache.camel.jmx.mbeanObjectDomainName </td>
<td class='confluenceTd'> org.apache.camel </td>
<td class='confluenceTd'> The JMX domain that all objects names will use </td>
</tr>
<tr>
<td class='confluenceTd'> createConnector </td>
<td class='confluenceTd'> org.apache.camel.jmx.createRmiConnect </td>
<td class='confluenceTd'> false </td>
<td class='confluenceTd'> If we should create a JMX connector (to allow remote management)
for the MBeanServer </td>
</tr>
<tr>
<td class='confluenceTd'> registryPort </td>
<td class='confluenceTd'> org.apache.camel.jmx.rmiConnector.registryPort </td>
<td class='confluenceTd'> 1099 </td>
<td class='confluenceTd'> The port that the JMX RMI registry will use </td>
</tr>
<tr>
<td class='confluenceTd'> connectorPort </td>
<td class='confluenceTd'> org.apache.camel.jmx.rmiConnector.connectorPort </td>
<td class='confluenceTd'> &#45;1 (dynamic) </td>
<td class='confluenceTd'> The port that the JMX RMI server will use </td>
</tr>
<tr>
<td class='confluenceTd'> serviceUrlPath </td>
<td class='confluenceTd'> org.apache.camel.jmx.serviceUrlPath </td>
<td class='confluenceTd'> /jmxrmi/camel </td>
<td class='confluenceTd'> The path that JMX connector will be registered under </td>
</tr>
<tr>
<td class='confluenceTd'> onlyRegisterProcessorWithCustomId </td>
<td class='confluenceTd'> org.apache.camel.jmx.onlyRegisterProcessorWithCustomId </td>
<td class='confluenceTd'> false </td>
<td class='confluenceTd'> <b>Camel 2.0:</b> If this option is enabled then
only processors with a custom id set will be registered. This allows you to filer out unwanted
processors in the JMX console. </td>
</tr>
</tbody></table>

<h3><a name="CamelJMX-RegisteringyourownManagedEndpoints"></a>Registering
your own Managed Endpoints</h3>
<p><b>Available as of Camel 2.0</b><br/>
You can decorate your own endpoints with spring managed annotations <b>@ManagedResource</b>
to allow to register them in the Camel mbean server and thus access your custom mbeans using
JMX.</p>

<p>For example we have the following custom endpoint where we define some options to
be managed:</p>
<style type="text/css">
@import url(/confluence/download/resources/confluence.ext.code:code/shStyles.css);
</style>
<!--[if IE]>
<style type="text/css">
    .code textarea, .code input { padding: 0 !important; }
</style>
<![endif]-->
<script class="javascript" src="/confluence/download/resources/confluence.ext.code:code/shCore.js"></script>
<script class="javascript" src="/confluence/download/resources/confluence.ext.code:code/shBrushCSharp.js"></script>
<script class="javascript" src="/confluence/download/resources/confluence.ext.code:code/shBrushPhp.js"></script>
<script class="javascript" src="/confluence/download/resources/confluence.ext.code:code/shBrushJScript.js"></script>
<script class="javascript" src="/confluence/download/resources/confluence.ext.code:code/shBrushVb.js"></script>
<script class="javascript" src="/confluence/download/resources/confluence.ext.code:code/shBrushSql.js"></script>
<script class="javascript" src="/confluence/download/resources/confluence.ext.code:code/shBrushXml.js"></script>
<script class="javascript" src="/confluence/download/resources/confluence.ext.code:code/shBrushShell.js"></script>
<script class="javascript" src="/confluence/download/resources/confluence.ext.code:code/shBrushDelphi.js"></script>
<script class="javascript" src="/confluence/download/resources/confluence.ext.code:code/shBrushPython.js"></script>
<script class="javascript" src="/confluence/download/resources/confluence.ext.code:code/shBrushJava.js"></script>
<div class="code">
<textarea name="newcodemacro" class="java:nocontrols:nogutter" rows="10" readonly="readonly">@ManagedResource(objectName
= "testdomain:name=customEndpoint")
public class CustomEndpoint extends MockEndpoint {

    public CustomEndpoint(final String endpointUri, final Component component) {
        super(endpointUri, component);
    }

    public boolean isSingleton() {
        return true;
    }
    
    protected String createEndpointUri() {
        return "custom";
    }

    @ManagedAttribute
    public String getFoo() {
        return "bar";
    }
}</textarea>
<script class="javascript">
    if(!window.newcodemacro_initialised)
    {
        window.newcodemacro_initialised = true;
        window.oldonloadmethod = window.onload;
        window.onload = function(){
            dp.SyntaxHighlighter.HighlightAll('newcodemacro');
            if(window.oldonloadmethod)
            {
                window.oldonloadmethod();
            }
        }
    }

</script>
</div>


     </div>
     <div id="commentsSection" class="wiki-content pageSection">
       <div style="float: right;">
            <a href="http://cwiki.apache.org/confluence/users/viewnotifications.action"
class="grey">Change Notification Preferences</a>
       </div>

       <a href="http://cwiki.apache.org/confluence/display/CAMEL/Camel+JMX">View Online</a>
       |
       <a href="http://cwiki.apache.org/confluence/pages/diffpagesbyversion.action?pageId=85697&revisedVersion=21&originalVersion=20">View
Change</a>
              |
       <a href="http://cwiki.apache.org/confluence/display/CAMEL/Camel+JMX?showComments=true&amp;showCommentArea=true#addcomment">Add
Comment</a>
            </div>
</div>
</div>
</div>
</div>
</body>
</html>

Mime
View raw message