camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From conflue...@apache.org
Subject [CONF] Apache Camel > Templating
Date Fri, 22 Jul 2011 08:42: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/Templating">Templating</a></h2>
    <h4>Page <b>edited</b> by             <a href="https://cwiki.apache.org/confluence/display/~jstrachan">James
Strachan</a>
    </h4>
        <br/>
                         <h4>Changes (2)</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" >A great way to do this is using some
kind of Template system to generate responses to requests generating a dynamic message using
a mostly-static body. <br> <br></td></tr>
            <tr><td class="diff-changed-lines" >There are a number of templating
components <span class="diff-added-words"style="background-color: #dfd;">included in
the Camel distribution</span> you could use <br></td></tr>
            <tr><td class="diff-unchanged" > <br>* [FreeMarker] <br></td></tr>
            <tr><td class="diff-snipped" >...<br></td></tr>
            <tr><td class="diff-unchanged" >* [XSLT] <br> <br></td></tr>
            <tr><td class="diff-added-lines" style="background-color: #dfd;">or
the following external Camel components <br> <br>* [Scalate|http://scalate.fusesource.org/camel.html]
<br> <br></td></tr>
            <tr><td class="diff-unchanged" >h3. Example <br> <br></td></tr>
            <tr><td class="diff-snipped" >...<br></td></tr>
    
            </table>
    </div>                            <h4>Full Content</h4>
                    <div class="notificationGreySide">
        <h2><a name="Templating-Templating"></a>Templating</h2>

<p>When you are testing distributed systems its a very common requirement to have to
stub out certain external systems with some stub so that you can test other parts of the system
until a specific system is available or written etc.</p>

<p>A great way to do this is using some kind of Template system to generate responses
to requests generating a dynamic message using a mostly-static body.</p>

<p>There are a number of templating components included in the Camel distribution you
could use</p>

<ul>
	<li><a href="/confluence/display/CAMEL/FreeMarker" title="FreeMarker">FreeMarker</a></li>
	<li><a href="/confluence/display/CAMEL/StringTemplate" title="StringTemplate">StringTemplate</a></li>
	<li><a href="/confluence/display/CAMEL/Velocity" title="Velocity">Velocity</a></li>
	<li><a href="/confluence/display/CAMEL/XQuery" title="XQuery">XQuery</a></li>
	<li><a href="/confluence/display/CAMEL/XSLT" title="XSLT">XSLT</a></li>
</ul>


<p>or the following external Camel components</p>

<ul>
	<li><a href="http://scalate.fusesource.org/camel.html" class="external-link" rel="nofollow">Scalate</a></li>
</ul>


<h3><a name="Templating-Example"></a>Example</h3>

<p>Here's a simple example showing how we can respond to InOut requests on the <b>My.Queue</b>
queue on <a href="/confluence/display/CAMEL/ActiveMQ" title="ActiveMQ">ActiveMQ</a>
with a template generated response. The reply would be sent back to the JMSReplyTo Destination.</p>

<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="code-java">
from(<span class="code-quote">"activemq:My.Queue"</span>).
  to(<span class="code-quote">"velocity:com/acme/MyResponse.vm"</span>);
</pre>
</div></div>

<p>If you want to use InOnly and consume the message and send it to another destination
you could use</p>

<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="code-java">
from(<span class="code-quote">"activemq:My.Queue"</span>).
  to(<span class="code-quote">"velocity:com/acme/MyResponse.vm"</span>).
  to(<span class="code-quote">"activemq:Another.Queue"</span>);
</pre>
</div></div>

<h3><a name="Templating-SeeAlso"></a>See Also</h3>

<ul>
	<li><a href="/confluence/display/CAMEL/Mock" title="Mock">Mock</a> for
details of mock endpoint testing (as opposed to template based stubs).</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/Templating">View
Online</a>
        |
        <a href="https://cwiki.apache.org/confluence/pages/diffpagesbyversion.action?pageId=67659&revisedVersion=9&originalVersion=8">View
Changes</a>
                |
        <a href="https://cwiki.apache.org/confluence/display/CAMEL/Templating?showComments=true&amp;showCommentArea=true#addcomment">Add
Comment</a>
            </div>
</div>
</div>
</div>
</div>
</body>
</html>

Mime
View raw message