camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From conflue...@apache.org
Subject [CONF] Apache Camel > Return Address
Date Sun, 24 Apr 2011 00:51: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/Return+Address">Return
Address</a></h2>
    <h4>Page <b>edited</b> by             <a href="https://cwiki.apache.org/confluence/display/~boday">Ben
O&#39;Day</a>
    </h4>
        <div id="versionComment">
        <b>Comment:</b>
        added example Java/Spring DSL (for CAMEL-3557)<br />
    </div>
        <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" >For example when using [JMS] with
InOut the component will by default return to the address given in {{JMSReplyTo}}. <br>
<br></td></tr>
            <tr><td class="diff-added-lines" style="background-color: #dfd;">*Requestor
Code* <br>{code} <br>getMockEndpoint(&quot;mock:bar&quot;).expectedBodiesReceived(&quot;Bye
World&quot;); <br>template.sendBodyAndHeader(&quot;direct:start&quot;, &quot;World&quot;,
&quot;JMSReplyTo&quot;, &quot;queue:bar&quot;); <br>{code} <br>
<br>*Route Using the [Fluent Builders]* <br>{code} <br>from(&quot;direct:start&quot;).to(&quot;activemq:queue:foo?preserveMessageQos=true&quot;);
<br>from(&quot;activemq:queue:foo&quot;).transform(body().prepend(&quot;Bye
&quot;)); <br>from(&quot;activemq:queue:bar?disableReplyTo=true&quot;).to(&quot;mock:bar&quot;);
<br>{code} <br> <br>*Route Using the [Spring XML Extensions]* <br>
<br>{code} <br>&lt;route&gt; <br>  &lt;from uri=&quot;direct:start&quot;/&gt;
<br>  &lt;to uri=&quot;activemq:queue:foo?preserveMessageQos=true&quot;/&gt;
<br>&lt;/route&gt; <br> <br>&lt;route&gt; <br>  &lt;from
uri=&quot;activemq:queue:foo&quot;/&gt; <br>  &lt;transform&gt;
<br>      &lt;simple&gt;Bye ${in.body}&lt;/simple&gt; <br>  &lt;/transform&gt;
<br>&lt;/route&gt; <br> <br>&lt;route&gt; <br>  &lt;from
uri=&quot;activemq:queue:bar?disableReplyTo=true&quot;/&gt; <br>  &lt;to
uri=&quot;mock:bar&quot;/&gt; <br>&lt;/route&gt; <br>{code}
<br> <br>For a complete example of this pattern, see this [junit test case|http://svn.apache.org/viewvc/camel/trunk/components/camel-jms/src/test/java/org/apache/camel/component/jms/JmsInOnlyWithReplyToAsHeaderTest.java?view=markup]
<br> <br></td></tr>
            <tr><td class="diff-unchanged" >{include:Using This Pattern} <br></td></tr>
    
            </table>
    </div>                            <h4>Full Content</h4>
                    <div class="notificationGreySide">
        <h2><a name="ReturnAddress-ReturnAddress"></a>Return Address</h2>

<p>Camel supports the <a href="http://www.enterpriseintegrationpatterns.com/ReturnAddress.html"
class="external-link" rel="nofollow">Return Address</a> from the <a href="/confluence/display/CAMEL/Enterprise+Integration+Patterns"
title="Enterprise Integration Patterns">EIP patterns</a> by using the <tt>JMSReplyTo</tt>
header.</p>

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

<p>For example when using <a href="/confluence/display/CAMEL/JMS" title="JMS">JMS</a>
with InOut the component will by default return to the address given in <tt>JMSReplyTo</tt>.</p>

<p><b>Requestor Code</b></p>
<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="code-java">
getMockEndpoint(<span class="code-quote">"mock:bar"</span>).expectedBodiesReceived(<span
class="code-quote">"Bye World"</span>);
template.sendBodyAndHeader(<span class="code-quote">"direct:start"</span>, <span
class="code-quote">"World"</span>, <span class="code-quote">"JMSReplyTo"</span>,
<span class="code-quote">"queue:bar"</span>);
</pre>
</div></div>

<p><b>Route 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:start"</span>).to(<span class="code-quote">"activemq:queue:foo?preserveMessageQos=<span
class="code-keyword">true</span>"</span>);
from(<span class="code-quote">"activemq:queue:foo"</span>).transform(body().prepend(<span
class="code-quote">"Bye "</span>));
from(<span class="code-quote">"activemq:queue:bar?disableReplyTo=<span class="code-keyword">true</span>"</span>).to(<span
class="code-quote">"mock:bar"</span>);
</pre>
</div></div>

<p><b>Route 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;route&gt;
  &lt;from uri=<span class="code-quote">"direct:start"</span>/&gt;
  &lt;to uri=<span class="code-quote">"activemq:queue:foo?preserveMessageQos=<span
class="code-keyword">true</span>"</span>/&gt;
&lt;/route&gt;

&lt;route&gt;
  &lt;from uri=<span class="code-quote">"activemq:queue:foo"</span>/&gt;
  &lt;transform&gt;
      &lt;simple&gt;Bye ${in.body}&lt;/simple&gt;
  &lt;/transform&gt;
&lt;/route&gt;

&lt;route&gt;
  &lt;from uri=<span class="code-quote">"activemq:queue:bar?disableReplyTo=<span
class="code-keyword">true</span>"</span>/&gt;
  &lt;to uri=<span class="code-quote">"mock:bar"</span>/&gt;
&lt;/route&gt;
</pre>
</div></div>

<p>For a complete example of this pattern, see this <a href="http://svn.apache.org/viewvc/camel/trunk/components/camel-jms/src/test/java/org/apache/camel/component/jms/JmsInOnlyWithReplyToAsHeaderTest.java?view=markup"
class="external-link" rel="nofollow">junit test case</a></p>

<h4><a name="ReturnAddress-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="https://cwiki.apache.org/confluence/users/viewnotifications.action"
class="grey">Change Notification Preferences</a>
        </div>
        <a href="https://cwiki.apache.org/confluence/display/CAMEL/Return+Address">View
Online</a>
        |
        <a href="https://cwiki.apache.org/confluence/pages/diffpagesbyversion.action?pageId=5144864&revisedVersion=3&originalVersion=2">View
Changes</a>
                |
        <a href="https://cwiki.apache.org/confluence/display/CAMEL/Return+Address?showComments=true&amp;showCommentArea=true#addcomment">Add
Comment</a>
            </div>
</div>
</div>
</div>
</div>
</body>
</html>

Mime
View raw message