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 Wed, 15 Jul 2009 08:31: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/Debugger">Debugger</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="Debugger-Debugger"></a>Debugger </h2>

<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>

<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>@deprecated</b><br
/><p>The debugger is @deprecated and is removed in Camel 2.0.</p>

<p>The <a href="/confluence/display/CAMEL/Tracer" title="Tracer">Tracer</a>
is sufficient in many cases, and if you want to do some debugging yourself then you can use
<a href="/confluence/display/CAMEL/Intercept" title="Intercept">Intercept</a>.<br/>
Or try out Eclipse based tooling that supports visual and integrated debugger in Eclipse,
being able to debug Camel routing - <a href="http://fusesource.com/products/fuse-integration-designer/"
rel="nofollow">FUSE Integration Designer</a></p></td></tr></table></div>

<p>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.</p>

<p>You can grab the debugger via the <tt>Debugger.getDebugger(context)</tt>
method or via the <tt>Main.getDebugger()</tt> method - which returns null if it
is not enabled.</p>

<p>You can enable or disable the debugger's logging dynamically, by calling the debugger's
setEnable method.</p>

<h3><a name="Debugger-EnablingfromMain"></a>Enabling from Main</h3>
<p>To enable debugging from the main run</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">java
org.apache.camel.spring.Main -x</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 </p>
<div class="code">
<textarea name="newcodemacro" class="java:nocontrols:nogutter" rows="10" readonly="readonly">java
org.apache.camel.spring.Main -debug</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>and the debugger will be active.</p>

<h3><a name="Debugger-Programmaticallyusingthedebugger"></a>Programmatically
using the debugger</h3>

<p>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 <a href="http://svn.apache.org/repos/asf/camel/branches/camel-1.x/components/camel-spring/src/test/java/org/apache/camel/spring/debug/DebugTest.java"
rel="nofollow">the following test case</a>...</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">//
lets run the camel route in debug mode
main = new Main();
main.enableDebug();
main.setApplicationContextUri("org/apache/camel/spring/debug/applicationContext.xml");
main.start();

// now lets test we have a debugger available
debugger = main.getDebugger();</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 Debugger can also be added to the routes as an interceptor as the following unit
test below demonstrates:</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">public
void testSendingSomeMessages() throws Exception {
    template.sendBodyAndHeader("direct:start", "Hello London", "to", "James");
    template.sendBodyAndHeader("direct:start", "This is Copenhagen calling", "from", "Claus");
}

protected RouteBuilder createRouteBuilder() throws Exception {
    return new RouteBuilder() {
        public void configure() throws Exception {
            // add debugger as an interceptor. The debugger is an enhanced tracer that also
            // logs the exchanges at runtime. It is also a framework where we programatically
            // can access the internal states of Camel etc.
            getContext().addInterceptStrategy(new Debugger());

            from("direct:start").
                    process(new Processor() {
                        public void process(Exchange exchange) throws Exception {
                            // do nothing
                        }

                        @Override
                        public String toString() {
                            return "MyProcessor";
                        }
                    }).
                    to("mock:a").
                    to("mock:b");
        }
    };
}</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="Debugger-AbouttheDebugger"></a>About the Debugger</h3>

<p>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</p>

<ul>
	<li>the Breakpoint object</li>
	<li>the list of Exchanges sent to this node</li>
	<li>the Predicate used to determine if messages are logged to the list</li>
</ul>


<h3><a name="Debugger-AccessingtheRouteDefinitions"></a>Accessing the Route
Definitions</h3>

<p>You can easily access all of the available route definitions from the Main instance
via the <b>getRouteDefinitions()</b> method.</p>

<div class="code">
<textarea name="newcodemacro" class="java:nocontrols:nogutter" rows="10" readonly="readonly">List&lt;RouteType&gt;
routes = main.getRouteDefinitions();</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>you can then navigate the route and see its inputs and outputs etc</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>
	<li><a href="/confluence/display/CAMEL/Delay+Interceptor" title="Delay Interceptor">Delay
Interceptor</a></li>
</ul>

     </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/Debugger">View Online</a>
       |
       <a href="http://cwiki.apache.org/confluence/pages/diffpagesbyversion.action?pageId=86210&revisedVersion=13&originalVersion=12">View
Change</a>
              |
       <a href="http://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