camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From conflue...@apache.org
Subject [CONF] Apache Camel > Debugger
Date Thu, 28 Oct 2010 12:27:00 GMT
<html>
<head>
    <base href="https://cwiki.apache.org/confluence">
            <link rel="stylesheet" href="/confluence/s/1810/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/Debugger">Debugger</a></h2>
    <h4>Page <b>edited</b> by             <a href="https://cwiki.apache.org/confluence/display/~davsclaus">Claus
Ibsen</a>
    </h4>
        <br/>
                         <h4>Changes (26)</h4>
                                 
    
<div id="page-diffs">
            <table class="diff" cellpadding="0" cellspacing="0">
            <tr><td class="diff-unchanged" >h2. Debugger  <br></td></tr>
            <tr><td class="diff-added-lines" style="background-color: #dfd;">*Available
as of Camel 2.6* <br></td></tr>
            <tr><td class="diff-unchanged" > <br>Camel [Debugger] is much
related to [Tracer], in fact they are sisters. Debugger is a enhanced tracer with a debugger
framework so that tooling can be developed to easily monitor Camel routes, trace messages
and set breakpoints at points in a route etc. <br> <br></td></tr>
            <tr><td class="diff-deleted-lines" style="color:#999;background-color:#fdd;text-decoration:line-through;">{warning:title=@deprecated}
<br>The debugger is @deprecated and is removed in Camel 2.0. <br></td></tr>
            <tr><td class="diff-added-lines" style="background-color: #dfd;">h3.
About the Debugger <br></td></tr>
            <tr><td class="diff-unchanged" > <br></td></tr>
            <tr><td class="diff-deleted-lines" style="color:#999;background-color:#fdd;text-decoration:line-through;">The
[Tracer] is sufficient in many cases, and if you want to do some debugging yourself then you
can use [Intercept]. <br>Or try out Eclipse based tooling that supports visual and integrated
debugger in Eclipse, being able to debug Camel routing - [FUSE Integration Designer|http://fusesource.com/products/fuse-integration-designer/]
<br>{warning} <br></td></tr>
            <tr><td class="diff-added-lines" style="background-color: #dfd;">The
Debugger allows tooling or the likes to attach breakpoints which is being invoked when [Exchange]s
is being routed. <br></td></tr>
            <tr><td class="diff-unchanged" > <br></td></tr>
            <tr><td class="diff-deleted-lines" style="color:#999;background-color:#fdd;text-decoration:line-through;">The
Debugger is an InterceptStrategy which can be applied to a DefaultCamelContext or SpringCamelContext
to ensure that there is a DebugInterceptor created for every node in the DSL. <br></td></tr>
            <tr><td class="diff-added-lines" style="background-color: #dfd;">h3.
Default implementation <br></td></tr>
            <tr><td class="diff-unchanged" > <br></td></tr>
            <tr><td class="diff-deleted-lines" style="color:#999;background-color:#fdd;text-decoration:line-through;">You
can grab the debugger via the {{Debugger.getDebugger(context)}} method or via the {{Main.getDebugger()}}
method - which returns null if it is not enabled. <br></td></tr>
            <tr><td class="diff-added-lines" style="background-color: #dfd;">Camel
provides a default implementation {{org.apache.camel.impl.DefaultDebugger}} which you can
set on the {{CamelContext}} using the {{setDebugger}} method. <br>Likewise you can get
hold of the [Debugger] using the {{getDebugger}} method on {{CamelContext}}. <br></td></tr>
            <tr><td class="diff-unchanged" > <br></td></tr>
            <tr><td class="diff-deleted-lines" style="color:#999;background-color:#fdd;text-decoration:line-through;">You
can enable or disable the debugger&#39;s logging dynamically, by calling the debugger&#39;s
setEnable method. <br></td></tr>
            <tr><td class="diff-added-lines" style="background-color: #dfd;">The
{{org.apache.camel.spi.Debugger}} has methods to attach and remove breakpoints. And to suspend/resume
all breakpoints etc. <br>You can also attach a condition to the breakpoint so it only
reacts if the condition matches. <br></td></tr>
            <tr><td class="diff-unchanged" > <br></td></tr>
            <tr><td class="diff-deleted-lines" style="color:#999;background-color:#fdd;text-decoration:line-through;">h3.
Enabling from Main <br>To enable debugging from the main run <br></td></tr>
            <tr><td class="diff-added-lines" style="background-color: #dfd;">h3.
Easily debugging Camel routes from {{camel-test}} <br></td></tr>
            <tr><td class="diff-unchanged" > <br></td></tr>
            <tr><td class="diff-added-lines" style="background-color: #dfd;">If
you are developing unit tests using the {{camel-test}} component, then the [Debugger] comes
out of the box. <br> <br>h4. Example  <br> <br>In this unit test <br></td></tr>
            <tr><td class="diff-unchanged" >{code} <br></td></tr>
            <tr><td class="diff-deleted-lines" style="color:#999;background-color:#fdd;text-decoration:line-through;">java
org.apache.camel.spring.Main -x <br></td></tr>
            <tr><td class="diff-added-lines" style="background-color: #dfd;">public
class DebugTest extends CamelTestSupport <br></td></tr>
            <tr><td class="diff-unchanged" >{code} <br></td></tr>
            <tr><td class="diff-deleted-lines" style="color:#999;background-color:#fdd;text-decoration:line-through;">or
 <br>{code} <br>java org.apache.camel.spring.Main -debug <br>{code} <br>
<br>and the debugger will be active. <br></td></tr>
            <tr><td class="diff-unchanged" > <br></td></tr>
            <tr><td class="diff-deleted-lines" style="color:#999;background-color:#fdd;text-decoration:line-through;">h3.
Programmatically using the debugger <br></td></tr>
            <tr><td class="diff-added-lines" style="background-color: #dfd;">We
want to debug the following route <br>TODO: e2 <br></td></tr>
            <tr><td class="diff-unchanged" > <br></td></tr>
            <tr><td class="diff-deleted-lines" style="color:#999;background-color:#fdd;text-decoration:line-through;">You
can use the Spring org.apache.camel.spring.Main class directly to invoke your Camel routes
using a spring XML file using debug as [the following test case|http://svn.apache.org/repos/asf/camel/branches/camel-1.x/components/camel-spring/src/test/java/org/apache/camel/spring/debug/DebugTest.java]...
<br></td></tr>
            <tr><td class="diff-added-lines" style="background-color: #dfd;">Which
can easily done by overriding the {{debugBefore}} method as shown <br>TODO: e1 <br></td></tr>
            <tr><td class="diff-unchanged" > <br></td></tr>
            <tr><td class="diff-deleted-lines" style="color:#999;background-color:#fdd;text-decoration:line-through;">{snippet:id=example|lang=java|url=camel/branches/camel-1.x/components/camel-spring/src/test/java/org/apache/camel/spring/debug/DebugTest.java}
<br></td></tr>
            <tr><td class="diff-added-lines" style="background-color: #dfd;">Then
from your Java editor just add a breakpoint inside the {{debugBefore}} method. Then fire up
the unit test and wait for the Java editor to hit the breakpoint. Then you can inspect the
[Exchange] during debugging while it advances during routing. The {{ProcessorDefinition}}
and the {{id}} and {{shortName}} parameters is all information which tells you where in the
route the breakpoint was hit. <br></td></tr>
            <tr><td class="diff-unchanged" > <br></td></tr>
            <tr><td class="diff-deleted-lines" style="color:#999;background-color:#fdd;text-decoration:line-through;">The
Debugger can also be added to the routes as an interceptor as the following unit test below
demonstrates: <br>{snippet:id=e1|lang=java|url=camel/branches/camel-1.x/camel-core/src/test/java/org/apache/camel/processor/DebugInterceptorTest.java}
<br></td></tr>
            <tr><td class="diff-unchanged" > <br></td></tr>
            <tr><td class="diff-deleted-lines" style="color:#999;background-color:#fdd;text-decoration:line-through;">h3.
About the Debugger <br> <br>The Debugger has access to every single DebugInterceptor
for each node in the Camel EIP route. You can look up the individual interceptor by the Node
ID where you can access <br> <br>* the Breakpoint object <br>* the list
of Exchanges sent to this node <br>* the Predicate used to determine if messages are
logged to the list <br> <br>h3. Accessing the Route Definitions <br> <br>You
can easily access all of the available route definitions from the Main instance via the *getRouteDefinitions()*
method. <br> <br>{code} <br>List&lt;RouteType&gt; routes = main.getRouteDefinitions();
<br>{code} <br> <br>you can then navigate the route and see its inputs and
outputs etc <br> <br></td></tr>
            <tr><td class="diff-unchanged" >h3. See Also <br>- [Tracer]
<br></td></tr>
            <tr><td class="diff-deleted-lines" style="color:#999;background-color:#fdd;text-decoration:line-through;">-
[Delay Interceptor] <br></td></tr>
        </table>
</div>                            <h4>Full Content</h4>
                    <div class="notificationGreySide">
        <h2><a name="Debugger-Debugger"></a>Debugger </h2>
<p><b>Available as of Camel 2.6</b></p>

<p>Camel <a href="/confluence/display/CAMEL/Debugger" title="Debugger">Debugger</a>
is much related to <a href="/confluence/display/CAMEL/Tracer" title="Tracer">Tracer</a>,
in fact they are sisters. Debugger is a enhanced tracer with a debugger framework so that
tooling can be developed to easily monitor Camel routes, trace messages and set breakpoints
at points in a route etc.</p>

<h3><a name="Debugger-AbouttheDebugger"></a>About the Debugger</h3>

<p>The Debugger allows tooling or the likes to attach breakpoints which is being invoked
when <a href="/confluence/display/CAMEL/Exchange" title="Exchange">Exchange</a>s
is being routed.</p>

<h3><a name="Debugger-Defaultimplementation"></a>Default implementation</h3>

<p>Camel provides a default implementation <tt>org.apache.camel.impl.DefaultDebugger</tt>
which you can set on the <tt>CamelContext</tt> using the <tt>setDebugger</tt>
method.<br/>
Likewise you can get hold of the <a href="/confluence/display/CAMEL/Debugger" title="Debugger">Debugger</a>
using the <tt>getDebugger</tt> method on <tt>CamelContext</tt>.</p>

<p>The <tt>org.apache.camel.spi.Debugger</tt> has methods to attach and
remove breakpoints. And to suspend/resume all breakpoints etc.<br/>
You can also attach a condition to the breakpoint so it only reacts if the condition matches.</p>

<h3><a name="Debugger-EasilydebuggingCamelroutesfrom%7B%7Bcameltest%7D%7D"></a>Easily
debugging Camel routes from <tt>camel-test</tt></h3>

<p>If you are developing unit tests using the <tt>camel-test</tt> component,
then the <a href="/confluence/display/CAMEL/Debugger" title="Debugger">Debugger</a>
comes out of the box.</p>

<h4><a name="Debugger-Example"></a>Example </h4>

<p>In this unit test</p>
<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="code-java">
<span class="code-keyword">public</span> class DebugTest <span class="code-keyword">extends</span>
CamelTestSupport
</pre>
</div></div>

<p>We want to debug the following route<br/>
TODO: e2</p>

<p>Which can easily done by overriding the <tt>debugBefore</tt> method as
shown<br/>
TODO: e1</p>

<p>Then from your Java editor just add a breakpoint inside the <tt>debugBefore</tt>
method. Then fire up the unit test and wait for the Java editor to hit the breakpoint. Then
you can inspect the <a href="/confluence/display/CAMEL/Exchange" title="Exchange">Exchange</a>
during debugging while it advances during routing. The <tt>ProcessorDefinition</tt>
and the <tt>id</tt> and <tt>shortName</tt> parameters is all information
which tells you where in the route the breakpoint was hit.</p>


<h3><a name="Debugger-SeeAlso"></a>See Also</h3>
<ul class="alternate" type="square">
	<li><a href="/confluence/display/CAMEL/Tracer" title="Tracer">Tracer</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/Debugger">View Online</a>
        |
        <a href="https://cwiki.apache.org/confluence/pages/diffpagesbyversion.action?pageId=86210&revisedVersion=14&originalVersion=13">View
Changes</a>
                |
        <a href="https://cwiki.apache.org/confluence/display/CAMEL/Debugger?showComments=true&amp;showCommentArea=true#addcomment">Add
Comment</a>
            </div>
</div>
</div>
</div>
</div>
</body>
</html>

Mime
View raw message