camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From conflue...@apache.org
Subject [CONF] Apache Camel > Routing Slip
Date Thu, 13 May 2010 07:21:00 GMT
<html>
<head>
    <base href="http://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="http://cwiki.apache.org/confluence/display/CAMEL/Routing+Slip">Routing
Slip</a></h2>
    <h4>Page <b>edited</b> by             <a href="http://cwiki.apache.org/confluence/display/~davsclaus">Claus
Ibsen</a>
    </h4>
        <br/>
                         <h4>Changes (1)</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" >{code} <br> <br></td></tr>
            <tr><td class="diff-added-lines" style="background-color: #dfd;">h3.
Ignore invalid endpoints <br>*Available as of Camel 2.3* <br> <br>The [Routing
Slip] now supports {{ignoreInvalidEndpoints}} which the [Recipient List] also supports. You
can use it to skip endpoints which is invalid. <br> <br>{code} <br>    from(&quot;direct:a&quot;).routingSlip(header(&quot;myHeader&quot;)).ignoreInvalidEndpoints();
<br>{code} <br> <br>And in Spring XML its an attribute on the recipient
list tag. <br> <br>{code} <br>   &lt;route&gt; <br>      
&lt;from uri=&quot;direct:a&quot;/&gt; <br>       &lt;routingSlip
ignoreInvalidEndpoints=&quot;true&quot;&gt; <br>           &lt;header&gt;myHeader&lt;/header&gt;
<br>       &lt;/routingSlip&gt; <br>   &lt;/route&gt; <br>{code}
<br> <br>Then lets say the {{myHeader}} contains the following two endpoints {{direct:foo,xxx:bar}}.
The first endpoint is valid and works. However the 2nd is invalid and will just be ignored.
Camel logs at INFO level about, so you can see why the endpoint was invalid. <br> <br>
<br></td></tr>
            <tr><td class="diff-unchanged" >h4. Further Examples <br> <br></td></tr>
            <tr><td class="diff-snipped" >...<br></td></tr>
        </table>
</div>                            <h4>Full Content</h4>
                    <div class="notificationGreySide">
        <h3><a name="RoutingSlip-RoutingSlip"></a>Routing Slip</h3>

<p>The <a href="http://www.enterpriseintegrationpatterns.com/RoutingTable.html" class="external-link"
rel="nofollow">Routing Slip</a> from the <a href="/confluence/display/CAMEL/Enterprise+Integration+Patterns"
title="Enterprise Integration Patterns">EIP patterns</a> allows you to route a message
consecutively through a series of processing steps where the sequence of steps is not known
at design time and can vary for each message.</p>

<p><span class="image-wrap" style=""><img src="http://www.enterpriseintegrationpatterns.com/img/RoutingTableSimple.gif"
style="border: 0px solid black" /></span></p>

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

<p>The following route will take any messages sent to the <a href="http://activemq.apache.org"
class="external-link" rel="nofollow">Apache ActiveMQ</a> queue <b>SomeQueue</b>
and pass them into the <a href="http://www.enterpriseintegrationpatterns.com/RoutingTable.html"
class="external-link" rel="nofollow">Routing Slip</a> pattern.</p>

<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="code-java">
from(<span class="code-quote">"activemq:SomeQueue"</span>).routingSlip(<span
class="code-quote">"headerName"</span>);
</pre>
</div></div>

<p>Messages will be checked for the existance of the "headerName" header. The value
of this header should be a comma-delimited list of endpoint <a href="/confluence/display/CAMEL/URIs"
title="URIs">URIs</a> you wish the message to be routed to. The <a href="/confluence/display/CAMEL/Message"
title="Message">Message</a> will be routed in a <a href="/confluence/display/CAMEL/Pipes+and+Filters"
title="Pipes and Filters">pipeline</a> fashion (i.e. one after the other).</p>

<p><b>Note:</b> In Camel 1.x the default header name <tt>routingSlipHeader</tt>
has been @deprecated and is removed in Camel 2.0. We feel that the DSL needed to express,
the header it uses to locate the destinations, directly in the DSL to not confuse readers.
So the header name must be provided. </p>

<h4><a name="RoutingSlip-Configurationoptions"></a>Configuration options</h4>

<p>Here we set the header name and the URI delimiter to something different.</p>

<p><b>Using the <a href="/confluence/display/CAMEL/Fluent+Builders" title="Fluent
Builders">Fluent Builders</a></b></p>
<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="code-java">from(<span class="code-quote">"direct:c"</span>).routingSlip(<span
class="code-quote">"aRoutingSlipHeader"</span>, <span class="code-quote">"#"</span>);
</pre>
</div></div>

<p><b>Using the <a href="/confluence/display/CAMEL/Spring+XML+Extensions" title="Spring
XML Extensions">Spring XML Extensions</a></b></p>
<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="code-java">
&lt;camelContext id=<span class="code-quote">"buildRoutingSlip"</span> xmlns=<span
class="code-quote">"http:<span class="code-comment">//activemq.apache.org/camel/schema/spring"</span>&gt;
</span>  &lt;route&gt;
    &lt;from uri=<span class="code-quote">"direct:c"</span>/&gt;
    &lt;routingSlip headerName=<span class="code-quote">"aRoutingSlipHeader"</span>
uriDelimiter=<span class="code-quote">"#"</span>/&gt;
  &lt;/route&gt;
&lt;/camelContext&gt;
</pre>
</div></div>

<h3><a name="RoutingSlip-Ignoreinvalidendpoints"></a>Ignore invalid endpoints</h3>
<p><b>Available as of Camel 2.3</b></p>

<p>The <a href="/confluence/display/CAMEL/Routing+Slip" title="Routing Slip">Routing
Slip</a> now supports <tt>ignoreInvalidEndpoints</tt> which the <a href="/confluence/display/CAMEL/Recipient+List"
title="Recipient List">Recipient List</a> also supports. You can use it to skip endpoints
which is invalid.</p>

<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="code-java">
    from(<span class="code-quote">"direct:a"</span>).routingSlip(header(<span
class="code-quote">"myHeader"</span>)).ignoreInvalidEndpoints();
</pre>
</div></div>

<p>And in Spring XML its an attribute on the recipient list tag.</p>

<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="code-java">
   &lt;route&gt;
       &lt;from uri=<span class="code-quote">"direct:a"</span>/&gt;
       &lt;routingSlip ignoreInvalidEndpoints=<span class="code-quote">"<span
class="code-keyword">true</span>"</span>&gt;
           &lt;header&gt;myHeader&lt;/header&gt;
       &lt;/routingSlip&gt;
   &lt;/route&gt;
</pre>
</div></div>

<p>Then lets say the <tt>myHeader</tt> contains the following two endpoints
<tt>direct:foo,xxx:bar</tt>. The first endpoint is valid and works. However the
2nd is invalid and will just be ignored. Camel logs at INFO level about, so you can see why
the endpoint was invalid.</p>


<h4><a name="RoutingSlip-FurtherExamples"></a>Further Examples</h4>

<p>For further examples of this pattern in use you could look at the <a href="http://svn.apache.org/viewvc/camel/trunk/camel-core/src/test/java/org/apache/camel/processor/routingslip"
class="external-link" rel="nofollow">routing slip test cases</a>.</p>

<h4><a name="RoutingSlip-Availability"></a>Availability</h4>

<p>This pattern is available as of Camel version 1.3.</p>

<h4><a name="RoutingSlip-UsingThisPattern"></a>Using This Pattern</h4>

<p>If you would like to use this EIP Pattern then please read the <a href="/confluence/display/CAMEL/Getting+Started"
title="Getting Started">Getting Started</a>, you may also find the <a href="/confluence/display/CAMEL/Architecture"
title="Architecture">Architecture</a> useful particularly the description of <a
href="/confluence/display/CAMEL/Endpoint" title="Endpoint">Endpoint</a> and <a
href="/confluence/display/CAMEL/URIs" title="URIs">URIs</a>. Then you could try out
some of the <a href="/confluence/display/CAMEL/Examples" title="Examples">Examples</a>
first before trying this pattern out.</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/CAMEL/Routing+Slip">View
Online</a>
        |
        <a href="http://cwiki.apache.org/confluence/pages/diffpagesbyversion.action?pageId=81112&revisedVersion=9&originalVersion=8">View
Changes</a>
                |
        <a href="http://cwiki.apache.org/confluence/display/CAMEL/Routing+Slip?showComments=true&amp;showCommentArea=true#addcomment">Add
Comment</a>
            </div>
</div>
</div>
</div>
</div>
</body>
</html>

Mime
View raw message