camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From conflue...@apache.org
Subject [CONF] Apache Camel > Why is my processor not showing up in JConsole
Date Wed, 14 Nov 2012 10:17: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/Why+is+my+processor+not+showing+up+in+JConsole">Why
is my processor not showing up in JConsole</a></h2>
    <h4>Page <b>edited</b> by             <a href="https://cwiki.apache.org/confluence/display/~bvahdat">Babak
Vahdat</a>
    </h4>
        <br/>
                         <h4>Changes (2)</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" >For example the minor ones such as
{{setHeader}} does not and thus is not visible in JConsole. <br> <br></td></tr>
            <tr><td class="diff-changed-lines" >From *Camel 2.6* onwards your
custom {{Processor}} should use the Spring JMX <span class="diff-changed-words">annotations<span
class="diff-added-chars"style="background-color: #dfd;"> (for *Camel 2</span>.<span
class="diff-added-chars"style="background-color: #dfd;">9* onwards see the tip box below).</span></span>
Just add {{@ManagedResource}} to the class, and the other annotations for the attributes and
operations. Then Camel will automatic use those when the processor is being registered in
JMX. <br></td></tr>
            <tr><td class="diff-unchanged" > <br>{snippet:id=e1|lang=java|title=Custom
processor|url=camel/trunk/camel-core/src/test/java/org/apache/camel/management/ManagedCustomProcessorTest.java}
<br></td></tr>
            <tr><td class="diff-snipped" >...<br></td></tr>
            <tr><td class="diff-unchanged" >{snippet:id=e1|lang=java|title=Custom
bean|url=camel/trunk/camel-core/src/test/java/org/apache/camel/management/ManagedCustomBeanTest.java}
<br> <br></td></tr>
            <tr><td class="diff-added-lines" style="background-color: #dfd;">{tip:title=Camel
2.9 onwards provides Camel&#39;s own JMX annotations} <br>Notice that from Camel
2.9 onwards its encouraged to use the {{@ManagedResource}}, {{@ManagedAttribute}} and {{@ManagedOperation}}
from the {{org.apache.camel.api.management}} package. This allows your custom code to not
depend on Spring JARs anymore. <br>{tip} <br></td></tr>
            <tr><td class="diff-unchanged" > <br>h3. See also <br></td></tr>
            <tr><td class="diff-snipped" >...<br></td></tr>
    
            </table>
    </div>                            <h4>Full Content</h4>
                    <div class="notificationGreySide">
        <h2><a name="WhyismyprocessornotshowingupinJConsole-WhyismyprocessornotshowingupinJConsole"></a>Why
is my processor not showing up in JConsole</h2>

<p>Not every processor is managed and thus not all is visible in the JConsole.</p>

<p>A processor must implement the <tt>org.apache.camel.Service</tt> to be
managed. Most EIP processors does this.<br/>
For example the minor ones such as <tt>setHeader</tt> does not and thus is not
visible in JConsole.</p>

<p>From <b>Camel 2.6</b> onwards your custom <tt>Processor</tt>
should use the Spring JMX annotations (for <b>Camel 2.9</b> onwards see the tip
box below). Just add <tt>@ManagedResource</tt> to the class, and the other annotations
for the attributes and operations. Then Camel will automatic use those when the processor
is being registered in JMX.</p>

<div class="code panel" style="border-width: 1px;"><div class="codeHeader panelHeader"
style="border-bottom-width: 1px;"><b>Custom processor</b></div><div
class="codeContent panelContent">
<pre class="code-java">@ManagedResource(description = <span class="code-quote">"My
Managed Component"</span>)
<span class="code-keyword">public</span> <span class="code-keyword">static</span>
class MyCustomProcessor <span class="code-keyword">implements</span> Processor
{
    <span class="code-keyword">private</span> <span class="code-object">String</span>
foo = <span class="code-quote">"hey"</span>;

    @ManagedAttribute
    <span class="code-keyword">public</span> <span class="code-object">String</span>
getFoo() {
        <span class="code-keyword">return</span> foo;
    }

    @ManagedAttribute
    <span class="code-keyword">public</span> void setFoo(<span class="code-object">String</span>
foo) {
        <span class="code-keyword">this</span>.foo = foo;
    }

    <span class="code-keyword">public</span> void process(Exchange exchange) <span
class="code-keyword">throws</span> Exception {
        exchange.getIn().setHeader(<span class="code-quote">"foo"</span>, getFoo());
    }
}
</pre>
</div></div>

<p>The same applies when using beans in your routes.</p>

<div class="code panel" style="border-width: 1px;"><div class="codeHeader panelHeader"
style="border-bottom-width: 1px;"><b>Custom bean</b></div><div class="codeContent
panelContent">
<pre class="code-java">@ManagedResource(description = <span class="code-quote">"My
Managed Bean"</span>)
<span class="code-keyword">public</span> <span class="code-keyword">static</span>
class MyCustomBean {
    <span class="code-keyword">private</span> <span class="code-object">String</span>
foo = <span class="code-quote">"hey"</span>;

    @ManagedAttribute
    <span class="code-keyword">public</span> <span class="code-object">String</span>
getFoo() {
        <span class="code-keyword">return</span> foo;
    }

    @ManagedAttribute
    <span class="code-keyword">public</span> void setFoo(<span class="code-object">String</span>
foo) {
        <span class="code-keyword">this</span>.foo = foo;
    }

    <span class="code-keyword">public</span> <span class="code-object">String</span>
doSomething(<span class="code-object">String</span> body, @Headers Map&lt;<span
class="code-object">Object</span>, <span class="code-object">Object</span>&gt;
headers) <span class="code-keyword">throws</span> Exception {
        headers.put(<span class="code-quote">"foo"</span>, foo);
        <span class="code-keyword">return</span> <span class="code-quote">"Hello
"</span> + body;
    }
}
</pre>
</div></div>

<div class='panelMacro'><table class='tipMacro'><colgroup><col width='24'><col></colgroup><tr><td
valign='top'><img src="/confluence/images/icons/emoticons/check.gif" width="16" height="16"
align="absmiddle" alt="" border="0"></td><td><b>Camel 2.9 onwards provides
Camel's own JMX annotations</b><br />Notice that from Camel 2.9 onwards its encouraged
to use the <tt>@ManagedResource</tt>, <tt>@ManagedAttribute</tt> and
<tt>@ManagedOperation</tt> from the <tt>org.apache.camel.api.management</tt>
package. This allows your custom code to not depend on Spring JARs anymore.</td></tr></table></div>

<h3><a name="WhyismyprocessornotshowingupinJConsole-Seealso"></a>See also</h3>
<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/Why+is+my+processor+not+showing+up+in+JConsole">View
Online</a>
        |
        <a href="https://cwiki.apache.org/confluence/pages/diffpagesbyversion.action?pageId=4587882&revisedVersion=5&originalVersion=4">View
Changes</a>
                |
        <a href="https://cwiki.apache.org/confluence/display/CAMEL/Why+is+my+processor+not+showing+up+in+JConsole?showComments=true&amp;showCommentArea=true#addcomment">Add
Comment</a>
            </div>
</div>
</div>
</div>
</div>
</body>
</html>

Mime
View raw message