camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From conflue...@apache.org
Subject [CONF] Apache Camel > Krati
Date Fri, 17 May 2013 07:15: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/Krati">Krati</a></h2>
    <h4>Page <b>edited</b> by             <a href="https://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" >| {{segmentFactory}} | ChannelSegmentFactory
| The segment factory to use. Allowed instance classes: ChannelSegmentFactory,MemorySegmentFactory,
MappedSegmentFactory &amp; WriteBufferSegmentFactory. | <br>| {{hashFunction}} |
FnvHashFunction | The hash function to use. Allowed instance classes: FnvHashFunction,Fnv1Hash32,FnvHash64,Fnv1aHash32,Fnv1aHash64,
JenkisHashFunction, MurmurHashFunctiom | <br></td></tr>
            <tr><td class="diff-added-lines" style="background-color: #dfd;">|
{{maxMessagesPerPoll}} | | *Camel 2.10.5/2.11.1:* The maximum number of messages which can
be received in one poll. This can be used to avoid reading in too much data and taking up
too much memory. | <br></td></tr>
            <tr><td class="diff-unchanged" >{div} <br>You can have as many
of these options as you like. <br></td></tr>
            <tr><td class="diff-snipped" >...<br></td></tr>
    
            </table>
    </div>                            <h4>Full Content</h4>
                    <div class="notificationGreySide">
        <h2><a name="Krati-KratiComponent"></a>Krati Component</h2>

<p><b>Available as of Camel 2.9</b></p>

<p>This component allows the use krati datastores and datasets inside Camel. Krati is
a simple persistent data store with very low latency and high throughput. It is designed for
easy integration with read-write-intensive applications with little effort in tuning configuration,
performance and JVM garbage collection.</p>

<p>Camel provides a producer and consumer for krati datastore_(key/value engine)_. It
also provides an idempotent repository for filtering out duplicate messages.</p>

<p>Maven users will need to add the following dependency to their <tt>pom.xml</tt>
for this component:</p>
<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="code-xml">
<span class="code-tag">&lt;dependency&gt;</span>
    <span class="code-tag">&lt;groupId&gt;</span>org.apache.camel<span
class="code-tag">&lt;/groupId&gt;</span>
    <span class="code-tag">&lt;artifactId&gt;</span>camel-krati<span
class="code-tag">&lt;/artifactId&gt;</span>
    <span class="code-tag">&lt;version&gt;</span>x.x.x<span class="code-tag">&lt;/version&gt;</span>
    <span class="code-tag"><span class="code-comment">&lt;!-- use the same
version as your Camel core version --&gt;</span></span>
<span class="code-tag">&lt;/dependency&gt;</span>
</pre>
</div></div>

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

<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="code-java">
krati:[the path of the datastore][?options]
</pre>
</div></div>

<p>The <b>path of the datastore</b> is the relative path of the folder that
krati will use for its datastore.</p>

<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="Krati-KratiURIOptions"></a>Krati URI Options</h3>

<div class="confluenceTableSmall"><div class='table-wrap'>
<table class='confluenceTable'><tbody>
<tr>
<th class='confluenceTh'> Name </th>
<th class='confluenceTh'> Default Value </th>
<th class='confluenceTh'> Description </th>
</tr>
<tr>
<td class='confluenceTd'> <tt>operation</tt> </td>
<td class='confluenceTd'> CamelKratiPut </td>
<td class='confluenceTd'> <b>Producer Only</b>. Specifies the type of operation
that will be performed to the datastore. Allowed values are CamelKratiPut, CamelKratiGet,
CamelKratiDelete &amp; CamelKratiDeleteAll. </td>
</tr>
<tr>
<td class='confluenceTd'> <tt>initialCapacity</tt> </td>
<td class='confluenceTd'> 100 </td>
<td class='confluenceTd'> The inital capcity of the store. </td>
</tr>
<tr>
<td class='confluenceTd'> <tt>keySerializer</tt> </td>
<td class='confluenceTd'> KratiDefaultSerializer </td>
<td class='confluenceTd'> The serializer serializer that will be used to serialize the
key. </td>
</tr>
<tr>
<td class='confluenceTd'> <tt>valueSerializer</tt> </td>
<td class='confluenceTd'> KratiDefaultSerializer </td>
<td class='confluenceTd'> The serializer serializer that will be used to serialize the
value. </td>
</tr>
<tr>
<td class='confluenceTd'> <tt>segmentFactory</tt> </td>
<td class='confluenceTd'> ChannelSegmentFactory </td>
<td class='confluenceTd'> The segment factory to use. Allowed instance classes: ChannelSegmentFactory,MemorySegmentFactory,
MappedSegmentFactory &amp; WriteBufferSegmentFactory. </td>
</tr>
<tr>
<td class='confluenceTd'> <tt>hashFunction</tt> </td>
<td class='confluenceTd'> FnvHashFunction </td>
<td class='confluenceTd'> The hash function to use. Allowed instance classes: FnvHashFunction,Fnv1Hash32,FnvHash64,Fnv1aHash32,Fnv1aHash64,
JenkisHashFunction, MurmurHashFunctiom </td>
</tr>
<tr>
<td class='confluenceTd'> <tt>maxMessagesPerPoll</tt> </td>
<td class='confluenceTd'>&nbsp;</td>
<td class='confluenceTd'> <b>Camel 2.10.5/2.11.1:</b> The maximum number
of messages which can be received in one poll. This can be used to avoid reading in too much
data and taking up too much memory. </td>
</tr>
</tbody></table>
</div>
</div>
<p>You can have as many of these options as you like.</p>
<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="code-java">
krati:/tmp/krati?operation=CamelKratiGet&amp;initialCapacity=10000&amp;keySerializer=#myCustomSerializer
</pre>
</div></div>

<p>For producer endpoint you can override all of the above URI options by passing the
appropriate headers to the message.</p>

<h4><a name="Krati-MessageHeadersfordatastore"></a>Message Headers for datastore</h4>
<div class="confluenceTableSmall"><div class='table-wrap'>
<table class='confluenceTable'><tbody>
<tr>
<th class='confluenceTh'> Header </th>
<th class='confluenceTh'> Description </th>
</tr>
<tr>
<td class='confluenceTd'> <tt>CamelKratiOperation</tt> </td>
<td class='confluenceTd'> The operation to be performed on the datastore. The valid
options are
<ul class="alternate" type="square">
	<li>CamelKratiAdd</li>
	<li>CamelKratiGet</li>
	<li>CamelKratiDelete</li>
	<li>CamelKratiDeleteAll</li>
</ul>
</td>
</tr>
<tr>
<td class='confluenceTd'> <tt>CamelKratiKey</tt> </td>
<td class='confluenceTd'> The key. </td>
</tr>
<tr>
<td class='confluenceTd'> <tt>CamelKratiValue</tt> </td>
<td class='confluenceTd'> The value. </td>
</tr>
</tbody></table>
</div>
</div>

<h3><a name="Krati-UsageSamples"></a>Usage Samples</h3>

<h4><a name="Krati-Example1%3APuttingtothedatastore."></a>Example 1: Putting
to the datastore.</h4>

<p>This example will show you how you can store any message inside a datastore.</p>
<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="code-java">
from(<span class="code-quote">"direct:put"</span>).to(<span class="code-quote">"krati:target/test/producertest"</span>);
</pre>
</div></div>

<p>In the above example you can override any of the URI parameters with headers on the
message.<br/>
Here is how the above example would look like using xml to define our route.</p>

<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="code-xml">
        <span class="code-tag">&lt;route&gt;</span>
            <span class="code-tag">&lt;from uri=<span class="code-quote">"direct:put"</span>/&gt;</span>
            <span class="code-tag">&lt;to uri=<span class="code-quote">"krati:target/test/producerspringtest"</span>/&gt;</span>
        <span class="code-tag">&lt;/route&gt;</span>
</pre>
</div></div>

<h4><a name="Krati-Example2%3AGetting%2FReadingfromadatastore"></a>Example
2: Getting/Reading from a datastore</h4>

<p>This example will show you how you can read the contnet of a datastore.</p>
<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="code-java">
from(<span class="code-quote">"direct:get"</span>)
    .setHeader(KratiConstants.KRATI_OPERATION, constant(KratiConstants.KRATI_OPERATION_GET))
    .to(<span class="code-quote">"krati:target/test/producertest"</span>);
</pre>
</div></div>

<p>In the above example you can override any of the URI parameters with headers on the
message.<br/>
Here is how the above example would look like using xml to define our route.</p>

<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="code-xml">
<span class="code-tag">&lt;route&gt;</span>
     <span class="code-tag">&lt;from uri=<span class="code-quote">"direct:get"</span>/&gt;</span>
     <span class="code-tag">&lt;to uri=<span class="code-quote">"krati:target/test/producerspringtest?operation=CamelKratiGet"</span>/&gt;</span>
<span class="code-tag">&lt;/route&gt;</span>
</pre>
</div></div>


<h4><a name="Krati-Example3%3AConsumingfromadatastore"></a>Example 3: Consuming
from a datastore</h4>

<p>This example will consume all items that are under the specified datastore.</p>
<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="code-java">
    from(<span class="code-quote">"krati:target/test/consumertest"</span>)
        .to(<span class="code-quote">"direct:next"</span>);
</pre>
</div></div>

<p>You can achieve the same goal by using xml, as you can see below.</p>

<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="code-xml">
<span class="code-tag">&lt;route&gt;</span>
    <span class="code-tag">&lt;from uri=<span class="code-quote">"krati:target/test/consumerspringtest"</span>/&gt;</span>
    <span class="code-tag">&lt;to uri=<span class="code-quote">"mock:results"</span>/&gt;</span>
<span class="code-tag">&lt;/route&gt;</span>
</pre>
</div></div>

<h3><a name="Krati-IdempotentRepository"></a>Idempotent Repository</h3>

<p>As already mentioned this component also offers and idemptonet repository which can
be used for filtering out duplicate messages.</p>

<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="code-java">
from(<span class="code-quote">"direct:<span class="code-comment">//in"</span>).idempotentConsumer(header(<span
class="code-quote">"messageId"</span>), <span class="code-keyword">new</span>
KratiIdempotentRepositroy(<span class="code-quote">"/tmp/idempotent"</span>).to(<span
class="code-quote">"log://out"</span>);</span>
</pre>
</div></div>


<h4><a name="Krati-Seealso"></a>See also</h4>

<p><a href="http://sna-projects.com/krati/" class="external-link" rel="nofollow">Krati
Websitre</a></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/Krati">View Online</a>
        |
        <a href="https://cwiki.apache.org/confluence/pages/diffpagesbyversion.action?pageId=27829500&revisedVersion=2&originalVersion=1">View
Changes</a>
                |
        <a href="https://cwiki.apache.org/confluence/display/CAMEL/Krati?showComments=true&amp;showCommentArea=true#addcomment">Add
Comment</a>
            </div>
</div>
</div>
</div>
</div>
</body>
</html>

Mime
View raw message