camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From conflue...@apache.org
Subject [CONF] Apache Camel > Delay Interceptor
Date Wed, 29 Jul 2009 12:12: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/Delay+Interceptor">Delay
Interceptor</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="DelayInterceptor-DelayInterceptor"></a>Delay Interceptor</h2>

<p><b>Available in Camel 1.5</b></p>

<p>The Delay interceptor is an route interceptor that is used for slowing processing
of messages down. This allows you to enable this interceptor and set a fixed amount of delay
between each step a message passes in the route path, to show how things is happening nice
and slowly, so you are not bombarded with a zillion lines of logging output.</p>

<p>The delay interceptor can be configured as follows:</p>
<ul class="alternate" type="square">
	<li>using Java system property <tt>camel.delay=value</tt> where value is
the fixed delay in millis.</li>
	<li>setting the delay attribute in the spring camelContext tag.</li>
	<li>adding the delay interceptor to the CamelContext in Java code.</li>
</ul>


<h3><a name="DelayInterceptor-ConfiguringusingSpring"></a>Configuring using
Spring</h3>
<p>Just set the delay attribute of the camelContext tag as shown below:</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="xml:nocontrols:nogutter" rows="10" readonly="readonly">&lt;camelContext
id="camel" delayer="500" xmlns="http://activemq.apache.org/camel/schema/spring"&gt;
        &lt;route&gt;
            &lt;from uri="direct: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>


<h3><a name="DelayInterceptor-ConfiguringusingJava"></a>Configuring using
Java</h3>
<p>You can add the delayer interceptor in the RouteBulder as shown below:</p>
<div class="code">
<textarea name="newcodemacro" class="java:nocontrols:nogutter" rows="10" readonly="readonly">public
void configure() throws Exception {
        // add the delay interceptor to delay each step 200 millis
        getContext().addInterceptStrategy(new Delayer(200));

       ... // regular routes here
    }</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>In <b>Camel 2.0</b> its a bit easier as you can just do</p>
<div class="code">
<textarea name="newcodemacro" class="java:nocontrols:nogutter" rows="10" readonly="readonly">getContext().setDelayer(200);</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="DelayInterceptor-Granularity"></a>Granularity</h3>
<p>In <b>Camel 2.0</b> you can configure it on both camel context and per
route as you like. Per route will override the camel context setting.<br/>
For example the route below is only the first route that has a delayer with 200 millis.</p>

<div class="code">
<textarea name="newcodemacro" class="java:nocontrols:nogutter" rows="10" readonly="readonly">&lt;camelContext
...&gt;

   &lt;route delayer="200"&gt;
     ...
   &lt;/route&gt;

   &lt;route&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>


<h3><a name="DelayInterceptor-SeeAlso"></a>See Also</h3>
<ul>
	<li><a href="/confluence/display/CAMEL/Tracer" title="Tracer">Tracer</a></li>
	<li><a href="/confluence/display/CAMEL/Debugger" title="Debugger">Debugger</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/Delay+Interceptor">View
Online</a>
       |
       <a href="http://cwiki.apache.org/confluence/pages/diffpagesbyversion.action?pageId=97587&revisedVersion=4&originalVersion=3">View
Change</a>
              |
       <a href="http://cwiki.apache.org/confluence/display/CAMEL/Delay+Interceptor?showComments=true&amp;showCommentArea=true#addcomment">Add
Comment</a>
            </div>
</div>
</div>
</div>
</div>
</body>
</html>

Mime
View raw message