cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From conflue...@apache.org
Subject [CONF] Apache CXF Documentation > JMX Management
Date Mon, 05 Apr 2010 19:21:00 GMT
<html>
<head>
    <base href="http://cwiki.apache.org/confluence">
            <link rel="stylesheet" href="/confluence/s/1519/1/1/_/styles/combined.css?spaceKey=CXF20DOC&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/CXF20DOC/JMX+Management">JMX
Management</a></h2>
     <h4>Page <b>edited</b> by             <a href="http://cwiki.apache.org/confluence/display/~dvaleri">David
Valeri</a>
    </h4>
     
          <br/>
     <div class="notificationGreySide">
         <h1><a name="JMXManagement-ConfiguringJMXIntegration"></a>Configuring
JMX Integration</h1>

<p>To enable the JMX integration, register an InstrumentationManager extension with
the CXF bus.  Using Spring XML, the following minimal XML snippet will enable JMX integration.</p>

<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="code-xml">
&lt;bean id=<span class="code-quote">"org.apache.cxf.management.InstrumentationManager"</span>
  class=<span class="code-quote">"org.apache.cxf.management.jmx.InstrumentationManagerImpl"</span>&gt;
  <span class="code-tag">&lt;property name=<span class="code-quote">"bus"</span>
ref=<span class="code-quote">"cxf"</span> /&gt;</span>
  <span class="code-tag">&lt;property name=<span class="code-quote">"enabled"</span>
value=<span class="code-quote">"true"</span> /&gt;</span>
<span class="code-tag">&lt;/bean&gt;</span>
</pre>
</div></div>

<p>The default InstrumentationManager accepts the following configuration options:</p>

<table class='confluenceTable'><tbody>
<tr>
<th class='confluenceTh'> Name </th>
<th class='confluenceTh'> Value </th>
<th class='confluenceTh'> Default </th>
</tr>
<tr>
<td class='confluenceTd'> enabled </td>
<td class='confluenceTd'> If the JMX integration should be enabled or not </td>
<td class='confluenceTd'> false </td>
</tr>
<tr>
<td class='confluenceTd'> bus </td>
<td class='confluenceTd'> The CXF bus instance to register the JMX extension with </td>
<td class='confluenceTd'> None </td>
</tr>
<tr>
<td class='confluenceTd'> server </td>
<td class='confluenceTd'> An optional reference to an MBeanServer instance to register
MBeans with.  If not supplied, an MBeanServer is resolved using the "usePlatformMbeanServer"
and/or "serverName" optoins. </td>
<td class='confluenceTd'> None </td>
</tr>
<tr>
<td class='confluenceTd'> usePlatformMbeanServer </td>
<td class='confluenceTd'> If true and no reference to an MBeanServer is supplied, the
JMX extension registers MBeans with the platform MBean server. </td>
<td class='confluenceTd'> false </td>
</tr>
<tr>
<td class='confluenceTd'> serverName </td>
<td class='confluenceTd'> If supplied, usePlatformMbeanServer is false, and no reference
to an MBeanServer is supplied, the JMX extension registers MBeans with the MBean server carrying
this name. </td>
<td class='confluenceTd'> None </td>
</tr>
<tr>
<td class='confluenceTd'> createMBServerConnectorFactory </td>
<td class='confluenceTd'> If true, a connector is created on the MBeanServer. </td>
<td class='confluenceTd'> true </td>
</tr>
<tr>
<td class='confluenceTd'> threaded </td>
<td class='confluenceTd'> Determines if the creation of the MBean connector is performed
in this thread or in a separate thread.  Only relevant if createMBServerConnectorFactory is
true. </td>
<td class='confluenceTd'> false </td>
</tr>
<tr>
<td class='confluenceTd'> daemon </td>
<td class='confluenceTd'> Determines if the MBean connector creation thread is marked
as a daemon thread or not.  Only relevant if createMBServerConnectorFactory is true. </td>
<td class='confluenceTd'> false </td>
</tr>
<tr>
<td class='confluenceTd'> JMXServiceURL </td>
<td class='confluenceTd'> The URL of the connector to create on the MBeanServer.   
Only relevant if createMBServerConnectorFactory is true. </td>
<td class='confluenceTd'> service:jmx:rmi:///jndi/rmi://localhost:9913/jmxrmi </td>
</tr>
</tbody></table>

<p>To avoid any unnecessary runtime overhead, the performance counters measuring response
time are disabled by default. Further <a href="#JMXManagement-responsetime">configuration</a>
is required to enable this instrumentation.</p>

<h2><a name="JMXManagement-ExampleConfiguration"></a>Example Configuration</h2>

<p>Enable JMX integration by adding the following XML to your CXF Spring context.</p>

<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="code-xml">
&lt;bean id=<span class="code-quote">"org.apache.cxf.management.InstrumentationManager"</span>
  class=<span class="code-quote">"org.apache.cxf.management.jmx.InstrumentationManagerImpl"</span>&gt;
  <span class="code-tag">&lt;property name=<span class="code-quote">"bus"</span>
ref=<span class="code-quote">"cxf"</span> /&gt;</span>
  <span class="code-tag">&lt;property name=<span class="code-quote">"enabled"</span>
value=<span class="code-quote">"true"</span> /&gt;</span>
  <span class="code-tag">&lt;property name=<span class="code-quote">"JMXServiceURL
"</span> value=<span class="code-quote">"service:jmx:rmi:///jndi/rmi://localhost:9914/jmxrmi"</span>
/&gt;</span>
<span class="code-tag">&lt;/bean&gt;</span>
</pre>
</div></div>

<p>To test the configuration start up your service and connect to it by using jconsole
from the JDK.<br/>
<img src="/confluence/download/attachments/70534/jconsole_connect2.png" align="absmiddle"
border="0" /><br/>
&nbsp;<br/>
Then you can browse to your endpoint:<br/>
&nbsp;<br/>
<img src="/confluence/download/attachments/70534/jconsole_service_endpoint.png" align="absmiddle"
border="0" /><br/>
&nbsp;</p>

<p><a name="JMXManagement-cxfinservicemix"></a></p>
<h1><a name="JMXManagement-ConfiguringCXFtoUsetheServiceMix4MBeanServer"></a>Configuring
CXF to Use the ServiceMix 4 MBeanServer</h1>

<p>If you are embedding a CXF service in a ServiceMix 4 container, the configuration
is slightly different from above. You don't want to start a new MBeanServer and you probably
don't want to create additional connectors as the container manages both of these for you.
 You can get a reference to the container's MBeanServer through the OSGi framework and by
inject this reference into the JMX integration extension. Don't forget to add the Spring OSGI
namespace and schemaLocation to your CXF configuration file if they are not already present.</p>

<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="code-xml">
<span class="code-tag"><span class="code-comment">&lt;!-- OSGi namespace and
schemaLocation required --&gt;</span></span>
&lt;beans ...
       <span class="code-keyword">xmlns:osgi</span>=<span class="code-quote">"http://www.springframework.org/schema/osgi"</span>
       ...      
       xsi:schemaLocation="...
       http://www.springframework.org/schema/osgi  http://www.springframework.org/schema/osgi/spring-osgi.xsd"&gt;

...

<span class="code-tag"><span class="code-comment">&lt;!-- Grab a reference
to the current MBeanServer --&gt;</span></span>
<span class="code-tag">&lt;osgi:reference id=<span class="code-quote">"mbeanServer"</span>
interface=<span class="code-quote">"javax.management.MBeanServer"</span> cardinality=<span
class="code-quote">"0..1"</span>/&gt;</span>

&lt;bean id=<span class="code-quote">"org.apache.cxf.management.InstrumentationManager"</span>
  class=<span class="code-quote">"org.apache.cxf.management.jmx.InstrumentationManagerImpl"</span>&gt;
  <span class="code-tag">&lt;property name=<span class="code-quote">"bus"</span>
ref=<span class="code-quote">"cxf"</span> /&gt;</span>
  <span class="code-tag">&lt;property name=<span class="code-quote">"enabled"</span>
value=<span class="code-quote">"true"</span> /&gt;</span>
  <span class="code-tag"><span class="code-comment">&lt;!-- Unless you really
want to open an additional connector, set this to false --&gt;</span></span>
  <span class="code-tag">&lt;property name=<span class="code-quote">"createMBServerConnectorFactory
"</span> value=<span class="code-quote">"false"</span> /&gt;</span>

  <span class="code-tag"><span class="code-comment">&lt;!-- Inject the reference
to the MBeanServer --&gt;</span></span>
  <span class="code-tag">&lt;property name=<span class="code-quote">"server"</span>
ref=<span class="code-quote">"mbeanServer"</span> /&gt;</span> 
<span class="code-tag">&lt;/bean&gt;</span>
</pre>
</div></div>

<p><a name="JMXManagement-responsetime"></a> </p>
<h1><a name="JMXManagement-HowtoGettheRequest%2FResponseHandlingTime%3F"></a>How
to Get the Request/Response Handling Time?</h1>

<p>The CXF management module also provides a feature which can get the aggregate statistics
for services running in the CXF Bus.</p>

<p>Here is the configuration snippet that you should add to your Spring context file
to enable response time collection.</p>

<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="code-xml">
    <span class="code-tag"><span class="code-comment">&lt;!-- Wiring the counter
repository --&gt;</span></span> 
    <span class="code-tag">&lt;bean id=<span class="code-quote">"CounterRepository"</span>
class=<span class="code-quote">"org.apache.cxf.management.counters.CounterRepository"</span>&gt;</span>
        <span class="code-tag">&lt;property name=<span class="code-quote">"bus"</span>
ref=<span class="code-quote">"cxf"</span> /&gt;</span>        
    <span class="code-tag">&lt;/bean&gt;</span>
</pre>
</div></div>

<p>The CounterRepository collects the following metrics: invocations, checked application
faults, unchecked application faults, runtime faults, logical runtime faults, total handling
time, max handling time, and min handling time.</p>

     </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/CXF20DOC/JMX+Management">View
Online</a>
       |
       <a href="http://cwiki.apache.org/confluence/pages/diffpagesbyversion.action?pageId=70534&revisedVersion=10&originalVersion=9">View
Change</a>
              |
       <a href="http://cwiki.apache.org/confluence/display/CXF20DOC/JMX+Management?showComments=true&amp;showCommentArea=true#addcomment">Add
Comment</a>
            </div>
</div>
</div>
</div>
</div>
</body>
</html>

Mime
View raw message