camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
Subject [CONF] Apache Camel > DataSet
Date Fri, 07 Sep 2012 16:42:00 GMT
    <base href="">
            <link rel="stylesheet" href="/confluence/s/2042/9/1/_/styles/combined.css?spaceKey=CAMEL&amp;forWysiwyg=true"
<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="">DataSet</a></h2>
    <h4>Page <b>edited</b> by             <a href="">Christian
        <div id="versionComment">
        Removed the deprecated Camel 1.x documentations<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" >{include:Testing Summary Include}
<br> <br></td></tr>
            <tr><td class="diff-changed-lines" >The DataSet component <span
since 1.3.0)</span> provides a mechanism to easily perform load &amp; soak testing
of your system. It works by allowing you to create [DataSet instances|]
both as a source of messages and as a way to assert that the data set is received. <br></td></tr>
            <tr><td class="diff-unchanged" > <br>Camel will use the [throughput
logger|Log] when sending dataset&#39;s.  <br></td></tr>
            <tr><td class="diff-snipped" >...<br></td></tr>
    </div>                            <h4>Full Content</h4>
                    <div class="notificationGreySide">
        <h2><a name="DataSet-DataSetComponent"></a>DataSet Component</h2>

<p><a href="/confluence/display/CAMEL/Testing" title="Testing">Testing</a>
of distributed and asynchronous processing is notoriously difficult. The <a href="/confluence/display/CAMEL/Mock"
title="Mock">Mock</a>, <a href="/confluence/display/CAMEL/Test" title="Test">Test</a>
and <a href="/confluence/display/CAMEL/DataSet" title="DataSet">DataSet</a> endpoints
work great with the <a href="/confluence/display/CAMEL/Testing" title="Testing">Camel
Testing Framework</a> to simplify your unit and integration testing using <a href="/confluence/display/CAMEL/Enterprise+Integration+Patterns"
title="Enterprise Integration Patterns">Enterprise Integration Patterns</a> and Camel's
large range of <a href="/confluence/display/CAMEL/Components" title="Components">Components</a>
together with the powerful <a href="/confluence/display/CAMEL/Bean+Integration" title="Bean
Integration">Bean Integration</a>.</p>

<p>The DataSet component provides a mechanism to easily perform load &amp; soak
testing of your system. It works by allowing you to create <a href=""
class="external-link" rel="nofollow">DataSet instances</a> both as a source of messages
and as a way to assert that the data set is received.</p>

<p>Camel will use the <a href="/confluence/display/CAMEL/Log" title="Log">throughput
logger</a> when sending dataset's. </p>

<h3><a name="DataSet-URIformat"></a>URI format</h3>

<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="code-java">

<p>Where <b>name</b> is used to find the <a href=""
class="external-link" rel="nofollow">DataSet instance</a> in the <a href="/confluence/display/CAMEL/Registry"

<p>Camel ships with a support implementation of <tt>org.apache.camel.component.dataset.DataSet</tt>,
the <tt>org.apache.camel.component.dataset.DataSetSupport</tt> class, that can
be used as a base for implementing your own DataSet. Camel also ships with a default implementation,
the <tt>org.apache.camel.component.dataset.SimpleDataSet</tt> that can be used
for testing.</p>

<h3><a name="DataSet-Options"></a>Options</h3>
<div class="confluenceTableSmall"><div class='table-wrap'>
<table class='confluenceTable'><tbody>
<th class='confluenceTh'> Option </th>
<th class='confluenceTh'> Default </th>
<th class='confluenceTh'> Description </th>
<td class='confluenceTd'> <tt>produceDelay</tt> </td>
<td class='confluenceTd'> 3 </td>
<td class='confluenceTd'> Allows a delay in ms to be specified, which causes producers
to pause in order to simulate slow producers. Uses a minimum of 3 ms delay unless you set
this option to -1 to force no delay at all. </td>
<td class='confluenceTd'> <tt>consumeDelay</tt> </td>
<td class='confluenceTd'> 0 </td>
<td class='confluenceTd'> Allows a delay in ms to be specified, which causes consumers
to pause in order to simulate slow consumers. </td>
<td class='confluenceTd'> <tt>preloadSize</tt> </td>
<td class='confluenceTd'> 0 </td>
<td class='confluenceTd'> Sets how many messages should be preloaded (sent) before the
route completes its initialization. </td>
<td class='confluenceTd'> <tt>initialDelay</tt> </td>
<td class='confluenceTd'> 1000 </td>
<td class='confluenceTd'> <b>Camel 2.1:</b> Time period in millis to wait
before starting sending messages. </td>
<td class='confluenceTd'> <tt>minRate</tt> </td>
<td class='confluenceTd'> 0 </td>
<td class='confluenceTd'> Wait until the DataSet contains at least this number of messages

<p>You can append query options to the URI in the following format, <tt>?option=value&amp;option=value&amp;...</tt></p>

<h3><a name="DataSet-ConfiguringDataSet"></a>Configuring DataSet</h3>
<p>Camel will lookup in the <a href="/confluence/display/CAMEL/Registry" title="Registry">Registry</a>
for a bean implementing the DataSet interface. So you can register your own DataSet as:</p>
<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="code-xml">
   <span class="code-tag">&lt;bean id=<span class="code-quote">"myDataSet"</span>
class=<span class="code-quote">"com.mycompany.MyDataSet"</span>&gt;</span>
      <span class="code-tag">&lt;property name=<span class="code-quote">"size"</span>
value=<span class="code-quote">"100"</span>/&gt;</span>
   <span class="code-tag">&lt;/bean&gt;</span>

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

<p>For example, to test that a set of messages are sent to a queue and then consumed
from the queue without losing any messages:</p>

<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="code-java">
<span class="code-comment">// send the dataset to a queue
</span>from(<span class="code-quote">"dataset:foo"</span>).to(<span class="code-quote">"activemq:SomeQueue"</span>);

<span class="code-comment">// now lets test that the messages are consumed correctly
</span>from(<span class="code-quote">"activemq:SomeQueue"</span>).to(<span

<p>The above would look in the <a href="/confluence/display/CAMEL/Registry" title="Registry">Registry</a>
to find the <b>foo</b> DataSet instance which is used to create the messages.</p>

<p>Then you create a DataSet implementation, such as using the <tt>SimpleDataSet</tt>
as described below, configuring things like how big the data set is and what the messages
look like etc.</p>

<h3><a name="DataSet-PropertiesonSimpleDataSet"></a>Properties on SimpleDataSet</h3>
<div class="confluenceTableSmall"><div class='table-wrap'>
<table class='confluenceTable'><tbody>
<th class='confluenceTh'>Property</th>
<th class='confluenceTh'>Type</th>
<th class='confluenceTh'>Description</th>
<td class='confluenceTd'><tt>defaultBody</tt> </td>
<td class='confluenceTd'> <tt>Object</tt> </td>
<td class='confluenceTd'> Specifies the default message body. For SimpleDataSet it is
a constant payload; though if you want to create custom payloads per message, create your
own derivation of <tt>DataSetSupport</tt>. </td>
<td class='confluenceTd'><tt>reportGroup</tt> </td>
<td class='confluenceTd'> <tt>long</tt> </td>
<td class='confluenceTd'> Specifies the number of messages to be received before reporting
progress. Useful for showing progress of a large load test.</td>
<td class='confluenceTd'><tt>size</tt> </td>
<td class='confluenceTd'> <tt>long</tt> </td>
<td class='confluenceTd'>Specifies how many messages to send/consume.</td>

<h3><a name="DataSet-SeeAlso"></a>See Also</h3>
	<li><a href="/confluence/display/CAMEL/Configuring+Camel" title="Configuring Camel">Configuring
	<li><a href="/confluence/display/CAMEL/Component" title="Component">Component</a></li>
	<li><a href="/confluence/display/CAMEL/Endpoint" title="Endpoint">Endpoint</a></li>
	<li><a href="/confluence/display/CAMEL/Getting+Started" title="Getting Started">Getting

	<li><a href="/confluence/display/CAMEL/Spring+Testing" title="Spring Testing">Spring

        <div id="commentsSection" class="wiki-content pageSection">
        <div style="float: right;">
            <a href=""
class="grey">Change Notification Preferences</a>
        <a href="">View Online</a>
        <a href="">View
        <a href=";showCommentArea=true#addcomment">Add

View raw message