camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From conflue...@apache.org
Subject [CONF] Apache Camel > Hazelcast Component
Date Tue, 12 Feb 2013 09:52: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/Hazelcast+Component">Hazelcast Component</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" >The SEDA consumer provides no operations. You only retrieve data from the specified queue. <br> <br></td></tr>
            <tr><td class="diff-added-lines" style="background-color: #dfd;">|| Name || default value || Description || <br>| {{pollInterval}} | {{1000}} | How frequent to poll from the SEDA queue | <br>| {{concurrentConsumers}} | {{1}} | To use concurrent consumers polling from the SEDA queue. | <br>| {{transferExchange}} | {{false}} | *Camel 2.8.0:* if set to true the whole Exchange will be transfered. If header or body contains  not serializable objects, they will be skipped. | <br>| {{transacted}} | {{false}} | *Camel 2.11:* if set to true then the consumer runs in transaction mode, where the messages in the seda queue will only be removed if the transaction commits, which happens when the processing is complete. | <br> <br> <br></td></tr>
            <tr><td class="diff-unchanged" >Java DSL : <br>{code} <br></td></tr>
            <tr><td class="diff-snipped" >...<br></td></tr>
    
            </table>
    </div>                            <h4>Full Content</h4>
                    <div class="notificationGreySide">
        <h2><a name="HazelcastComponent-HazelcastComponent"></a>Hazelcast Component</h2>

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

<p>The <b>hazelcast:</b> component allows you to work with the <a href="http://www.hazelcast.com" class="external-link" rel="nofollow">Hazelcast</a> distributed data grid / cache. Hazelcast is a in memory data grid, entirely written in Java (single jar). It offers a great palette of different data stores like map, multi map (same key, n values), queue, list and atomic number. The main reason to use Hazelcast is its simple cluster support. If you have enabled multicast on your network you can run a cluster with hundred nodes with no extra configuration. Hazelcast can simply configured to add additional features like n copies between nodes (default is 1), cache persistence, network configuration (if needed), near cache, enviction and so on. For more information consult the Hazelcast documentation on <a href="http://www.hazelcast.com/documentation.jsp" class="external-link" rel="nofollow">http://www.hazelcast.com/documentation.jsp</a>.</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-hazelcast<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="HazelcastComponent-URIformat"></a>URI format</h3>

<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="code-java">
hazelcast:[ map | multimap | queue | seda | set | atomicvalue | instance]:cachename[?options]
</pre>
</div></div>

<div class='panelMacro'><table class='warningMacro'><colgroup><col width='24'><col></colgroup><tr><td valign='top'><img src="/confluence/images/icons/emoticons/forbidden.gif" width="16" height="16" align="absmiddle" alt="" border="0"></td><td>You have to use the second prefix to define which type of data store you want to use.</td></tr></table></div>

<h3><a name="HazelcastComponent-Sections"></a>Sections</h3>

<ol>
	<li>Usage of <a href="#HazelcastComponent-map">map</a></li>
	<li>Usage of <a href="#HazelcastComponent-multimap">multimap</a></li>
	<li>Usage of <a href="#HazelcastComponent-queue">queue</a></li>
	<li>Usage of <a href="#HazelcastComponent-list">list</a></li>
	<li>Usage of <a href="#HazelcastComponent-seda">seda</a></li>
	<li>Usage of <a href="#HazelcastComponent-atomicnumber">atomic number</a></li>
	<li>Usage of <a href="#HazelcastComponent-cluster">cluster</a> support (instance)</li>
</ol>


<p><a name="HazelcastComponent-map"></a></p>

<h3><a name="HazelcastComponent-UsageofMap"></a>Usage of Map</h3>

<h4><a name="HazelcastComponent-mapcacheproducerto%28%22hazelcast%3Amap%3Afoo%22%29"></a>map cache producer - to("hazelcast:map:foo")</h4>

<p>If you want to store a value in a map you can use the map cache producer. The map cache producer provides 5 operations (put, get, update, delete, query). For the first 4 you have to provide the operation inside the "hazelcast.operation.type" header variable. In Java DSL you can use the constants from <tt>org.apache.camel.component.hazelcast.HazelcastConstants</tt>.</p>

<p>Header Variables for the request message:</p>
<div class='table-wrap'>
<table class='confluenceTable'><tbody>
<tr>
<th class='confluenceTh'> Name </th>
<th class='confluenceTh'> Type </th>
<th class='confluenceTh'> Description </th>
</tr>
<tr>
<td class='confluenceTd'> <tt>hazelcast.operation.type</tt> </td>
<td class='confluenceTd'> <tt>String</tt> </td>
<td class='confluenceTd'> valid values are: put, delete, get, update, query </td>
</tr>
<tr>
<td class='confluenceTd'> <tt>hazelcast.objectId</tt> </td>
<td class='confluenceTd'> <tt>String</tt> </td>
<td class='confluenceTd'> the object id to store / find your object inside the cache (not needed for the query operation) </td>
</tr>
</tbody></table>
</div>


<div class='panelMacro'><table class='warningMacro'><colgroup><col width='24'><col></colgroup><tr><td valign='top'><img src="/confluence/images/icons/emoticons/forbidden.gif" width="16" height="16" align="absmiddle" alt="" border="0"></td><td>Header variables have changed in Camel 2.8</td></tr></table></div>
<div class='table-wrap'>
<table class='confluenceTable'><tbody>
<tr>
<th class='confluenceTh'> Name </th>
<th class='confluenceTh'> Type </th>
<th class='confluenceTh'> Description </th>
</tr>
<tr>
<td class='confluenceTd'> <tt>CamelHazelcastOperationType</tt> </td>
<td class='confluenceTd'> <tt>String</tt> </td>
<td class='confluenceTd'> valid values are: put, delete, get, update, query <b><a href="/confluence/pages/createpage.action?spaceKey=CAMEL&amp;title=Version+2.8&amp;linkCreation=true&amp;fromPageId=25202845" class="createlink">Version 2.8</a></b> </td>
</tr>
<tr>
<td class='confluenceTd'> <tt>CamelHazelcastObjectId</tt> </td>
<td class='confluenceTd'> <tt>String</tt> </td>
<td class='confluenceTd'> the object id to store / find your object inside the cache (not needed for the query operation) <b><a href="/confluence/pages/createpage.action?spaceKey=CAMEL&amp;title=Version+2.8&amp;linkCreation=true&amp;fromPageId=25202845" class="createlink">Version 2.8</a></b> </td>
</tr>
</tbody></table>
</div>


<p>You can call the samples with:</p>
<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="code-java">
template.sendBodyAndHeader(<span class="code-quote">"direct:[put|get|update|delete|query]"</span>, <span class="code-quote">"my-foo"</span>, HazelcastConstants.OBJECT_ID, <span class="code-quote">"4711"</span>);
</pre>
</div></div>

<h5><a name="HazelcastComponent-Sampleforput%3A"></a>Sample for <b>put</b>:</h5>

<p>Java DSL:</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>)
.setHeader(HazelcastConstants.OPERATION, constant(HazelcastConstants.PUT_OPERATION))
.toF(<span class="code-quote">"hazelcast:%sfoo"</span>, HazelcastConstants.MAP_PREFIX);
</pre>
</div></div>

<p>Spring DSL:</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:put"</span> /&gt;
        &lt;!-- If using version 2.8 and above set headerName to <span class="code-quote">"CamelHazelcastOperationType"</span> --&gt;
	&lt;setHeader headerName=<span class="code-quote">"hazelcast.operation.type"</span>&gt;
		&lt;constant&gt;put&lt;/constant&gt;
	&lt;/setHeader&gt;
	&lt;to uri=<span class="code-quote">"hazelcast:map:foo"</span> /&gt;
&lt;/route&gt;
</pre>
</div></div>

<h5><a name="HazelcastComponent-Sampleforget%3A"></a>Sample for <b>get</b>:</h5>

<p>Java DSL:</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(HazelcastConstants.OPERATION, constant(HazelcastConstants.GET_OPERATION))
.toF(<span class="code-quote">"hazelcast:%sfoo"</span>, HazelcastConstants.MAP_PREFIX)
.to(<span class="code-quote">"seda:out"</span>);
</pre>
</div></div>

<p>Spring DSL:</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:get"</span> /&gt;
        &lt;!-- If using version 2.8 and above set headerName to <span class="code-quote">"CamelHazelcastOperationType"</span> --&gt;
	&lt;setHeader headerName=<span class="code-quote">"hazelcast.operation.type"</span>&gt;
		&lt;constant&gt;get&lt;/constant&gt;
	&lt;/setHeader&gt;
	&lt;to uri=<span class="code-quote">"hazelcast:map:foo"</span> /&gt;
	&lt;to uri=<span class="code-quote">"seda:out"</span> /&gt;
&lt;/route&gt;
</pre>
</div></div>

<h5><a name="HazelcastComponent-Sampleforupdate%3A"></a>Sample for <b>update</b>:</h5>

<p>Java DSL:</p>
<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="code-java">
from(<span class="code-quote">"direct:update"</span>)
.setHeader(HazelcastConstants.OPERATION, constant(HazelcastConstants.UPDATE_OPERATION))
.toF(<span class="code-quote">"hazelcast:%sfoo"</span>, HazelcastConstants.MAP_PREFIX);
</pre>
</div></div>

<p>Spring DSL:</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:update"</span> /&gt;
        &lt;!-- If using version 2.8 and above set headerName to <span class="code-quote">"CamelHazelcastOperationType"</span> --&gt;
	&lt;setHeader headerName=<span class="code-quote">"hazelcast.operation.type"</span>&gt;
		&lt;constant&gt;update&lt;/constant&gt;
	&lt;/setHeader&gt;
	&lt;to uri=<span class="code-quote">"hazelcast:map:foo"</span> /&gt;
&lt;/route&gt;
</pre>
</div></div>

<h5><a name="HazelcastComponent-Samplefordelete%3A"></a>Sample for <b>delete</b>:</h5>

<p>Java DSL:</p>
<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="code-java">
from(<span class="code-quote">"direct:delete"</span>)
.setHeader(HazelcastConstants.OPERATION, constant(HazelcastConstants.DELETE_OPERATION))
.toF(<span class="code-quote">"hazelcast:%sfoo"</span>, HazelcastConstants.MAP_PREFIX);
</pre>
</div></div>

<p>Spring DSL:</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:delete"</span> /&gt;
        &lt;!-- If using version 2.8 and above set headerName to <span class="code-quote">"CamelHazelcastOperationType"</span> --&gt;
	&lt;setHeader headerName=<span class="code-quote">"hazelcast.operation.type"</span>&gt;
		&lt;constant&gt;delete&lt;/constant&gt;
	&lt;/setHeader&gt;
	&lt;to uri=<span class="code-quote">"hazelcast:map:foo"</span> /&gt;
&lt;/route&gt;
</pre>
</div></div>

<h5><a name="HazelcastComponent-Sampleforquery"></a>Sample for <b>query</b></h5>

<p>Java DSL:</p>
<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="code-java">
from(<span class="code-quote">"direct:query"</span>)
.setHeader(HazelcastConstants.OPERATION, constant(HazelcastConstants.QUERY_OPERATION))
.toF(<span class="code-quote">"hazelcast:%sfoo"</span>, HazelcastConstants.MAP_PREFIX)
.to(<span class="code-quote">"seda:out"</span>);
</pre>
</div></div>

<p>Spring DSL:</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:query"</span> /&gt;
        &lt;!-- If using version 2.8 and above set headerName to <span class="code-quote">"CamelHazelcastOperationType"</span> --&gt;
	&lt;setHeader headerName=<span class="code-quote">"hazelcast.operation.type"</span>&gt;
		&lt;constant&gt;query&lt;/constant&gt;
	&lt;/setHeader&gt;
	&lt;to uri=<span class="code-quote">"hazelcast:map:foo"</span> /&gt;
	&lt;to uri=<span class="code-quote">"seda:out"</span> /&gt;
&lt;/route&gt;
</pre>
</div></div>

<p>For the query operation Hazelcast offers a SQL like syntax to query your distributed map.</p>
<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="code-java">
<span class="code-object">String</span> q1 = <span class="code-quote">"bar &gt; 1000"</span>;
template.sendBodyAndHeader(<span class="code-quote">"direct:query"</span>, <span class="code-keyword">null</span>, HazelcastConstants.QUERY, q1);
</pre>
</div></div>


<h3><a name="HazelcastComponent-mapcacheconsumerfrom%28%22hazelcast%3Amap%3Afoo%22%29"></a>map cache consumer - from("hazelcast:map:foo")</h3>

<p>Hazelcast provides event listeners on their data grid. If you want to be notified if a cache will be manipulated, you can use the map consumer. There're 4 events: <b>put</b>, <b>update</b>, <b>delete</b> and <b>envict</b>. The event type will be stored in the "<b>hazelcast.listener.action</b>" header variable. The map consumer provides some additional information inside these variables:</p>

<p>Header Variables inside the response message:</p>
<div class='table-wrap'>
<table class='confluenceTable'><tbody>
<tr>
<th class='confluenceTh'> Name </th>
<th class='confluenceTh'> Type </th>
<th class='confluenceTh'> Description </th>
</tr>
<tr>
<td class='confluenceTd'> <tt>hazelcast.listener.time</tt> </td>
<td class='confluenceTd'> <tt>Long</tt> </td>
<td class='confluenceTd'> time of the event in millis </td>
</tr>
<tr>
<td class='confluenceTd'> <tt>hazelcast.listener.type</tt> </td>
<td class='confluenceTd'> <tt>String</tt> </td>
<td class='confluenceTd'> the map consumer sets here "cachelistener" </td>
</tr>
<tr>
<td class='confluenceTd'> <tt>hazelcast.listener.action</tt> </td>
<td class='confluenceTd'> <tt>String</tt> </td>
<td class='confluenceTd'> type of event - here <b>added</b>, <b>updated</b>, <b>envicted</b> and <b>removed</b> </td>
</tr>
<tr>
<td class='confluenceTd'> <tt>hazelcast.objectId</tt> </td>
<td class='confluenceTd'> <tt>String</tt> </td>
<td class='confluenceTd'> the oid of the object </td>
</tr>
<tr>
<td class='confluenceTd'> <tt>hazelcast.cache.name</tt> </td>
<td class='confluenceTd'> <tt>String</tt> </td>
<td class='confluenceTd'> the name of the cache - e.g. "foo" </td>
</tr>
<tr>
<td class='confluenceTd'> <tt>hazelcast.cache.type</tt> </td>
<td class='confluenceTd'> <tt>String</tt> </td>
<td class='confluenceTd'> the type of the cache - here map </td>
</tr>
</tbody></table>
</div>


<div class='panelMacro'><table class='warningMacro'><colgroup><col width='24'><col></colgroup><tr><td valign='top'><img src="/confluence/images/icons/emoticons/forbidden.gif" width="16" height="16" align="absmiddle" alt="" border="0"></td><td>Header variables have changed in Camel 2.8</td></tr></table></div>
<div class='table-wrap'>
<table class='confluenceTable'><tbody>
<tr>
<th class='confluenceTh'> Name </th>
<th class='confluenceTh'> Type </th>
<th class='confluenceTh'> Description </th>
</tr>
<tr>
<td class='confluenceTd'> <tt>CamelHazelcastListenerTime</tt> </td>
<td class='confluenceTd'> <tt>Long</tt> </td>
<td class='confluenceTd'> time of the event in millis <b><a href="/confluence/pages/createpage.action?spaceKey=CAMEL&amp;title=Version+2.8&amp;linkCreation=true&amp;fromPageId=25202845" class="createlink">Version 2.8</a></b> </td>
</tr>
<tr>
<td class='confluenceTd'> <tt>CamelHazelcastListenerType</tt> </td>
<td class='confluenceTd'> <tt>String</tt> </td>
<td class='confluenceTd'> the map consumer sets here "cachelistener" <b><a href="/confluence/pages/createpage.action?spaceKey=CAMEL&amp;title=Version+2.8&amp;linkCreation=true&amp;fromPageId=25202845" class="createlink">Version 2.8</a></b> </td>
</tr>
<tr>
<td class='confluenceTd'> <tt>CamelHazelcastListenerAction</tt> </td>
<td class='confluenceTd'> <tt>String</tt> </td>
<td class='confluenceTd'> type of event - here <b>added</b>, <b>updated</b>, <b>envicted</b> and <b>removed</b>. <b><a href="/confluence/pages/createpage.action?spaceKey=CAMEL&amp;title=Version+2.8&amp;linkCreation=true&amp;fromPageId=25202845" class="createlink">Version 2.8</a></b> </td>
</tr>
<tr>
<td class='confluenceTd'> <tt>CamelHazelcastObjectId</tt> </td>
<td class='confluenceTd'> <tt>String</tt> </td>
<td class='confluenceTd'> the oid of the object <b><a href="/confluence/pages/createpage.action?spaceKey=CAMEL&amp;title=Version+2.8&amp;linkCreation=true&amp;fromPageId=25202845" class="createlink">Version 2.8</a></b></td>
</tr>
<tr>
<td class='confluenceTd'> <tt>CamelHazelcastCacheName</tt> </td>
<td class='confluenceTd'> <tt>String</tt> </td>
<td class='confluenceTd'> the name of the cache - e.g. "foo" <b><a href="/confluence/pages/createpage.action?spaceKey=CAMEL&amp;title=Version+2.8&amp;linkCreation=true&amp;fromPageId=25202845" class="createlink">Version 2.8</a></b></td>
</tr>
<tr>
<td class='confluenceTd'> <tt>CamelHazelcastCacheType</tt> </td>
<td class='confluenceTd'> <tt>String</tt> </td>
<td class='confluenceTd'> the type of the cache - here map <b><a href="/confluence/pages/createpage.action?spaceKey=CAMEL&amp;title=Version+2.8&amp;linkCreation=true&amp;fromPageId=25202845" class="createlink">Version 2.8</a></b></td>
</tr>
</tbody></table>
</div>


<p>The object value will be stored within <b>put</b> and <b>update</b> actions inside the message body.</p>

<p>Here's a sample:</p>
<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="code-java">
fromF(<span class="code-quote">"hazelcast:%sfoo"</span>, HazelcastConstants.MAP_PREFIX)
.log(<span class="code-quote">"object..."</span>)
.choice()
    .when(header(HazelcastConstants.LISTENER_ACTION).isEqualTo(HazelcastConstants.ADDED))
         .log(<span class="code-quote">"...added"</span>)
         .to(<span class="code-quote">"mock:added"</span>)
    .when(header(HazelcastConstants.LISTENER_ACTION).isEqualTo(HazelcastConstants.ENVICTED))
         .log(<span class="code-quote">"...envicted"</span>)
         .to(<span class="code-quote">"mock:envicted"</span>)
    .when(header(HazelcastConstants.LISTENER_ACTION).isEqualTo(HazelcastConstants.UPDATED))
         .log(<span class="code-quote">"...updated"</span>)
         .to(<span class="code-quote">"mock:updated"</span>)
    .when(header(HazelcastConstants.LISTENER_ACTION).isEqualTo(HazelcastConstants.REMOVED))
         .log(<span class="code-quote">"...removed"</span>)
         .to(<span class="code-quote">"mock:removed"</span>)
    .otherwise()
         .log(<span class="code-quote">"fail!"</span>);
</pre>
</div></div>

<p><a name="HazelcastComponent-multimap"></a></p>

<h3><a name="HazelcastComponent-UsageofMultiMap"></a>Usage of Multi Map</h3>

<h4><a name="HazelcastComponent-multimapcacheproducerto%28%22hazelcast%3Amultimap%3Afoo%22%29"></a>multimap cache producer - to("hazelcast:multimap:foo")</h4>

<p>A multimap is a cache where you can store n values to one key. The multimap producer provides 4 operations (put, get, removevalue, delete).</p>

<p>Header Variables for the request message:</p>
<div class='table-wrap'>
<table class='confluenceTable'><tbody>
<tr>
<th class='confluenceTh'> Name </th>
<th class='confluenceTh'> Type </th>
<th class='confluenceTh'> Description </th>
</tr>
<tr>
<td class='confluenceTd'> <tt>hazelcast.operation.type</tt> </td>
<td class='confluenceTd'> <tt>String</tt> </td>
<td class='confluenceTd'> valid values are: put, get, removevalue, delete </td>
</tr>
<tr>
<td class='confluenceTd'> <tt>hazelcast.objectId</tt> </td>
<td class='confluenceTd'> <tt>String</tt> </td>
<td class='confluenceTd'> the object id to store / find your object inside the cache </td>
</tr>
</tbody></table>
</div>


<div class='panelMacro'><table class='warningMacro'><colgroup><col width='24'><col></colgroup><tr><td valign='top'><img src="/confluence/images/icons/emoticons/forbidden.gif" width="16" height="16" align="absmiddle" alt="" border="0"></td><td>Header variables have changed in Camel 2.8</td></tr></table></div>

<h2><a name="HazelcastComponent-"></a></h2>

<div class='table-wrap'>
<table class='confluenceTable'><tbody>
<tr>
<th class='confluenceTh'> Name </th>
<th class='confluenceTh'> Type </th>
<th class='confluenceTh'> Description </th>
</tr>
<tr>
<td class='confluenceTd'> <tt>CamelHazelcastOperationType</tt> </td>
<td class='confluenceTd'> <tt>String</tt> </td>
<td class='confluenceTd'> valid values are: put, delete, get, update, query <b>Available as of Camel 2.8</b> </td>
</tr>
<tr>
<td class='confluenceTd'> <tt>CamelHazelcastObjectId</tt> </td>
<td class='confluenceTd'> <tt>String</tt> </td>
<td class='confluenceTd'> the object id to store / find your object inside the cache (not needed for the query operation) <b><a href="/confluence/pages/createpage.action?spaceKey=CAMEL&amp;title=Version+2.8&amp;linkCreation=true&amp;fromPageId=25202845" class="createlink">Version 2.8</a></b> </td>
</tr>
</tbody></table>
</div>


<p>You can call the samples with:</p>
<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="code-java">
template.sendBodyAndHeader(<span class="code-quote">"direct:[put|get|update|delete|query]"</span>, <span class="code-quote">"my-foo"</span>, HazelcastConstants.OBJECT_ID, <span class="code-quote">"4711"</span>);
</pre>
</div></div>

<h5><a name="HazelcastComponent-Sampleforput%3A"></a>Sample for <b>put</b>:</h5>

<p>Java DSL:</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>)
.setHeader(HazelcastConstants.OPERATION, constant(HazelcastConstants.PUT_OPERATION))
.toF(<span class="code-quote">"hazelcast:%sfoo"</span>, HazelcastConstants.MAP_PREFIX);
</pre>
</div></div>

<p>Spring DSL:</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:put"</span> /&gt;
        &lt;!-- If using version 2.8 and above set headerName to <span class="code-quote">"CamelHazelcastOperationType"</span> --&gt;
	&lt;setHeader headerName=<span class="code-quote">"hazelcast.operation.type"</span>&gt;
		&lt;constant&gt;put&lt;/constant&gt;
	&lt;/setHeader&gt;
	&lt;to uri=<span class="code-quote">"hazelcast:map:foo"</span> /&gt;
&lt;/route&gt;
</pre>
</div></div>

<h5><a name="HazelcastComponent-Sampleforget%3A"></a>Sample for <b>get</b>:</h5>

<p>Java DSL:</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(HazelcastConstants.OPERATION, constant(HazelcastConstants.GET_OPERATION))
.toF(<span class="code-quote">"hazelcast:%sfoo"</span>, HazelcastConstants.MAP_PREFIX)
.to(<span class="code-quote">"seda:out"</span>);
</pre>
</div></div>

<p>Spring DSL:</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:get"</span> /&gt;
        &lt;!-- If using version 2.8 and above set headerName to <span class="code-quote">"CamelHazelcastOperationType"</span> --&gt;
	&lt;setHeader headerName=<span class="code-quote">"hazelcast.operation.type"</span>&gt;
		&lt;constant&gt;get&lt;/constant&gt;
	&lt;/setHeader&gt;
	&lt;to uri=<span class="code-quote">"hazelcast:map:foo"</span> /&gt;
	&lt;to uri=<span class="code-quote">"seda:out"</span> /&gt;
&lt;/route&gt;
</pre>
</div></div>

<h5><a name="HazelcastComponent-Sampleforupdate%3A"></a>Sample for <b>update</b>:</h5>

<p>Java DSL:</p>
<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="code-java">
from(<span class="code-quote">"direct:update"</span>)
.setHeader(HazelcastConstants.OPERATION, constant(HazelcastConstants.UPDATE_OPERATION))
.toF(<span class="code-quote">"hazelcast:%sfoo"</span>, HazelcastConstants.MAP_PREFIX);
</pre>
</div></div>

<p>Spring DSL:</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:update"</span> /&gt;
        &lt;!-- If using version 2.8 and above set headerName to <span class="code-quote">"CamelHazelcastOperationType"</span> --&gt;
	&lt;setHeader headerName=<span class="code-quote">"hazelcast.operation.type"</span>&gt;
		&lt;constant&gt;update&lt;/constant&gt;
	&lt;/setHeader&gt;
	&lt;to uri=<span class="code-quote">"hazelcast:map:foo"</span> /&gt;
&lt;/route&gt;
</pre>
</div></div>

<h5><a name="HazelcastComponent-Samplefordelete%3A"></a>Sample for <b>delete</b>:</h5>

<p>Java DSL:</p>
<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="code-java">
from(<span class="code-quote">"direct:delete"</span>)
.setHeader(HazelcastConstants.OPERATION, constant(HazelcastConstants.DELETE_OPERATION))
.toF(<span class="code-quote">"hazelcast:%sfoo"</span>, HazelcastConstants.MAP_PREFIX);
</pre>
</div></div>

<p>Spring DSL:</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:delete"</span> /&gt;
        &lt;!-- If using version 2.8 and above set headerName to <span class="code-quote">"CamelHazelcastOperationType"</span> --&gt;
	&lt;setHeader headerName=<span class="code-quote">"hazelcast.operation.type"</span>&gt;
		&lt;constant&gt;delete&lt;/constant&gt;
	&lt;/setHeader&gt;
	&lt;to uri=<span class="code-quote">"hazelcast:map:foo"</span> /&gt;
&lt;/route&gt;
</pre>
</div></div>

<h5><a name="HazelcastComponent-Sampleforquery"></a>Sample for <b>query</b></h5>

<p>Java DSL:</p>
<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="code-java">
from(<span class="code-quote">"direct:query"</span>)
.setHeader(HazelcastConstants.OPERATION, constant(HazelcastConstants.QUERY_OPERATION))
.toF(<span class="code-quote">"hazelcast:%sfoo"</span>, HazelcastConstants.MAP_PREFIX)
.to(<span class="code-quote">"seda:out"</span>);
</pre>
</div></div>

<p>Spring DSL:</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:query"</span> /&gt;
        &lt;!-- If using version 2.8 and above set headerName to <span class="code-quote">"CamelHazelcastOperationType"</span> --&gt;
	&lt;setHeader headerName=<span class="code-quote">"hazelcast.operation.type"</span>&gt;
		&lt;constant&gt;query&lt;/constant&gt;
	&lt;/setHeader&gt;
	&lt;to uri=<span class="code-quote">"hazelcast:map:foo"</span> /&gt;
	&lt;to uri=<span class="code-quote">"seda:out"</span> /&gt;
&lt;/route&gt;
</pre>
</div></div>

<p>For the query operation Hazelcast offers a SQL like syntax to query your distributed map.</p>
<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="code-java">
<span class="code-object">String</span> q1 = <span class="code-quote">"bar &gt; 1000"</span>;
template.sendBodyAndHeader(<span class="code-quote">"direct:query"</span>, <span class="code-keyword">null</span>, HazelcastConstants.QUERY, q1);
</pre>
</div></div>


<h3><a name="HazelcastComponent-mapcacheconsumerfrom%28%22hazelcast%3Amap%3Afoo%22%29"></a>map cache consumer - from("hazelcast:map:foo")</h3>

<p>Hazelcast provides event listeners on their data grid. If you want to be notified if a cache will be manipulated, you can use the map consumer. There're 4 events: <b>put</b>, <b>update</b>, <b>delete</b> and <b>envict</b>. The event type will be stored in the "<b>hazelcast.listener.action</b>" header variable. The map consumer provides some additional information inside these variables:</p>

<p>Header Variables inside the response message:</p>
<div class='table-wrap'>
<table class='confluenceTable'><tbody>
<tr>
<th class='confluenceTh'> Name </th>
<th class='confluenceTh'> Type </th>
<th class='confluenceTh'> Description </th>
</tr>
<tr>
<td class='confluenceTd'> <tt>hazelcast.listener.time</tt> </td>
<td class='confluenceTd'> <tt>Long</tt> </td>
<td class='confluenceTd'> time of the event in millis </td>
</tr>
<tr>
<td class='confluenceTd'> <tt>hazelcast.listener.type</tt> </td>
<td class='confluenceTd'> <tt>String</tt> </td>
<td class='confluenceTd'> the map consumer sets here "cachelistener" </td>
</tr>
<tr>
<td class='confluenceTd'> <tt>hazelcast.listener.action</tt> </td>
<td class='confluenceTd'> <tt>String</tt> </td>
<td class='confluenceTd'> type of event - here <b>added</b>, <b>updated</b>, <b>envicted</b> and <b>removed</b> </td>
</tr>
<tr>
<td class='confluenceTd'> <tt>hazelcast.objectId</tt> </td>
<td class='confluenceTd'> <tt>String</tt> </td>
<td class='confluenceTd'> the oid of the object </td>
</tr>
<tr>
<td class='confluenceTd'> <tt>hazelcast.cache.name</tt> </td>
<td class='confluenceTd'> <tt>String</tt> </td>
<td class='confluenceTd'> the name of the cache - e.g. "foo" </td>
</tr>
<tr>
<td class='confluenceTd'> <tt>hazelcast.cache.type</tt> </td>
<td class='confluenceTd'> <tt>String</tt> </td>
<td class='confluenceTd'> the type of the cache - here map </td>
</tr>
</tbody></table>
</div>


<div class='panelMacro'><table class='warningMacro'><colgroup><col width='24'><col></colgroup><tr><td valign='top'><img src="/confluence/images/icons/emoticons/forbidden.gif" width="16" height="16" align="absmiddle" alt="" border="0"></td><td>Header variables have changed in Camel 2.8</td></tr></table></div>
<div class='table-wrap'>
<table class='confluenceTable'><tbody>
<tr>
<th class='confluenceTh'> Name </th>
<th class='confluenceTh'> Type </th>
<th class='confluenceTh'> Description </th>
</tr>
<tr>
<td class='confluenceTd'> <tt>CamelHazelcastListenerTime</tt> </td>
<td class='confluenceTd'> <tt>Long</tt> </td>
<td class='confluenceTd'> time of the event in millis <b><a href="/confluence/pages/createpage.action?spaceKey=CAMEL&amp;title=Version+2.8&amp;linkCreation=true&amp;fromPageId=25202845" class="createlink">Version 2.8</a></b> </td>
</tr>
<tr>
<td class='confluenceTd'> <tt>CamelHazelcastListenerType</tt> </td>
<td class='confluenceTd'> <tt>String</tt> </td>
<td class='confluenceTd'> the map consumer sets here "cachelistener" <b><a href="/confluence/pages/createpage.action?spaceKey=CAMEL&amp;title=Version+2.8&amp;linkCreation=true&amp;fromPageId=25202845" class="createlink">Version 2.8</a></b> </td>
</tr>
<tr>
<td class='confluenceTd'> <tt>CamelHazelcastListenerAction</tt> </td>
<td class='confluenceTd'> <tt>String</tt> </td>
<td class='confluenceTd'> type of event - here <b>added</b>, <b>updated</b>, <b>envicted</b> and <b>removed</b>. <b><a href="/confluence/pages/createpage.action?spaceKey=CAMEL&amp;title=Version+2.8&amp;linkCreation=true&amp;fromPageId=25202845" class="createlink">Version 2.8</a></b> </td>
</tr>
<tr>
<td class='confluenceTd'> <tt>CamelHazelcastObjectId</tt> </td>
<td class='confluenceTd'> <tt>String</tt> </td>
<td class='confluenceTd'> the oid of the object <b><a href="/confluence/pages/createpage.action?spaceKey=CAMEL&amp;title=Version+2.8&amp;linkCreation=true&amp;fromPageId=25202845" class="createlink">Version 2.8</a></b> </td>
</tr>
<tr>
<td class='confluenceTd'> <tt>CamelHazelcastCacheName</tt> </td>
<td class='confluenceTd'> <tt>String</tt> </td>
<td class='confluenceTd'> the name of the cache - e.g. "foo" <b><a href="/confluence/pages/createpage.action?spaceKey=CAMEL&amp;title=Version+2.8&amp;linkCreation=true&amp;fromPageId=25202845" class="createlink">Version 2.8</a></b> </td>
</tr>
<tr>
<td class='confluenceTd'> <tt>CamelHazelcastCacheType</tt> </td>
<td class='confluenceTd'> <tt>String</tt> </td>
<td class='confluenceTd'> the type of the cache - here map <b><a href="/confluence/pages/createpage.action?spaceKey=CAMEL&amp;title=Version+2.8&amp;linkCreation=true&amp;fromPageId=25202845" class="createlink">Version 2.8</a></b> </td>
</tr>
</tbody></table>
</div>


<p>The object value will be stored within <b>put</b> and <b>update</b> actions inside the message body.</p>

<p>Here's a sample:</p>
<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="code-java">
fromF(<span class="code-quote">"hazelcast:%sfoo"</span>, HazelcastConstants.MAP_PREFIX)
.log(<span class="code-quote">"object..."</span>)
.choice()
    .when(header(HazelcastConstants.LISTENER_ACTION).isEqualTo(HazelcastConstants.ADDED))
         .log(<span class="code-quote">"...added"</span>)
         .to(<span class="code-quote">"mock:added"</span>)
    .when(header(HazelcastConstants.LISTENER_ACTION).isEqualTo(HazelcastConstants.ENVICTED))
         .log(<span class="code-quote">"...envicted"</span>)
         .to(<span class="code-quote">"mock:envicted"</span>)
    .when(header(HazelcastConstants.LISTENER_ACTION).isEqualTo(HazelcastConstants.UPDATED))
         .log(<span class="code-quote">"...updated"</span>)
         .to(<span class="code-quote">"mock:updated"</span>)
    .when(header(HazelcastConstants.LISTENER_ACTION).isEqualTo(HazelcastConstants.REMOVED))
         .log(<span class="code-quote">"...removed"</span>)
         .to(<span class="code-quote">"mock:removed"</span>)
    .otherwise()
         .log(<span class="code-quote">"fail!"</span>);
</pre>
</div></div>

<p><a name="HazelcastComponent-multimap"></a></p>

<h3><a name="HazelcastComponent-UsageofMultiMap"></a>Usage of Multi Map</h3>

<h4><a name="HazelcastComponent-multimapcacheproducerto%28%22hazelcast%3Amultimap%3Afoo%22%29"></a>multimap cache producer - to("hazelcast:multimap:foo")</h4>

<p>A multimap is a cache where you can store n values to one key. The multimap producer provides 4 operations (put, get, removevalue, delete).</p>

<p>Header Variables for the request message:</p>
<div class='table-wrap'>
<table class='confluenceTable'><tbody>
<tr>
<th class='confluenceTh'> Name </th>
<th class='confluenceTh'> Type </th>
<th class='confluenceTh'> Description </th>
</tr>
<tr>
<td class='confluenceTd'> <tt>hazelcast.operation.type</tt> </td>
<td class='confluenceTd'> <tt>String</tt> </td>
<td class='confluenceTd'> valid values are: put, get, removevalue, delete </td>
</tr>
<tr>
<td class='confluenceTd'> <tt>hazelcast.objectId</tt> </td>
<td class='confluenceTd'> <tt>String</tt> </td>
<td class='confluenceTd'> the object id to store / find your object inside the cache </td>
</tr>
</tbody></table>
</div>


<div class='panelMacro'><table class='warningMacro'><colgroup><col width='24'><col></colgroup><tr><td valign='top'><img src="/confluence/images/icons/emoticons/forbidden.gif" width="16" height="16" align="absmiddle" alt="" border="0"></td><td>Header variables have changed in Camel 2.8</td></tr></table></div>
<div class='table-wrap'>
<table class='confluenceTable'><tbody>
<tr>
<th class='confluenceTh'> Name </th>
<th class='confluenceTh'> Type </th>
<th class='confluenceTh'> Description </th>
</tr>
<tr>
<td class='confluenceTd'> <tt>CamelHazelcastOperationType</tt> </td>
<td class='confluenceTd'> <tt>String</tt> </td>
<td class='confluenceTd'> valid values are: put, get, removevalue, delete <b><a href="/confluence/pages/createpage.action?spaceKey=CAMEL&amp;title=Version+2.8&amp;linkCreation=true&amp;fromPageId=25202845" class="createlink">Version 2.8</a></b> </td>
</tr>
<tr>
<td class='confluenceTd'> <tt>CamelHazelcastObjectId</tt> </td>
<td class='confluenceTd'> <tt>String</tt> </td>
<td class='confluenceTd'> the object id to store / find your object inside the cache <b><a href="/confluence/pages/createpage.action?spaceKey=CAMEL&amp;title=Version+2.8&amp;linkCreation=true&amp;fromPageId=25202845" class="createlink">Version 2.8</a></b> </td>
</tr>
</tbody></table>
</div>


<h5><a name="HazelcastComponent-Sampleforput%3A"></a>Sample for <b>put</b>:</h5>

<p>Java DSL:</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>)
.setHeader(HazelcastConstants.OPERATION, constant(HazelcastConstants.PUT_OPERATION))
.to(<span class="code-object">String</span>.format(<span class="code-quote">"hazelcast:%sbar"</span>, HazelcastConstants.MULTIMAP_PREFIX));
</pre>
</div></div>

<p>Spring DSL:</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:put"</span> /&gt;
	&lt;log message=<span class="code-quote">"put.."</span>/&gt;
        &lt;!-- If using version 2.8 and above set headerName to <span class="code-quote">"CamelHazelcastOperationType"</span> --&gt;
	&lt;setHeader headerName=<span class="code-quote">"hazelcast.operation.type"</span>&gt;
		&lt;constant&gt;put&lt;/constant&gt;
	&lt;/setHeader&gt;
	&lt;to uri=<span class="code-quote">"hazelcast:multimap:foo"</span> /&gt;
&lt;/route&gt;
</pre>
</div></div>

<h5><a name="HazelcastComponent-Sampleforremovevalue%3A"></a>Sample for <b>removevalue</b>:</h5>

<p>Java DSL:</p>
<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="code-java">
from(<span class="code-quote">"direct:removevalue"</span>)
.setHeader(HazelcastConstants.OPERATION, constant(HazelcastConstants.REMOVEVALUE_OPERATION))
.toF(<span class="code-quote">"hazelcast:%sbar"</span>, HazelcastConstants.MULTIMAP_PREFIX);
</pre>
</div></div>

<p>Spring DSL:</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:removevalue"</span> /&gt;
	&lt;log message=<span class="code-quote">"removevalue..."</span>/&gt;
        &lt;!-- If using version 2.8 and above set headerName to <span class="code-quote">"CamelHazelcastOperationType"</span> --&gt;
	&lt;setHeader headerName=<span class="code-quote">"hazelcast.operation.type"</span>&gt;
		&lt;constant&gt;removevalue&lt;/constant&gt;
	&lt;/setHeader&gt;
	&lt;to uri=<span class="code-quote">"hazelcast:multimap:foo"</span> /&gt;
&lt;/route&gt;
</pre>
</div></div>

<p>To remove a value you have to provide the value you want to remove inside the message body. If you have a multimap object {<tt>key: "4711" values: { "my-foo", "my-bar"</tt>}} you have to put "my-foo" inside the message body to remove the "my-foo" value.</p>

<h5><a name="HazelcastComponent-Sampleforget%3A"></a>Sample for <b>get</b>:</h5>

<p>Java DSL:</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(HazelcastConstants.OPERATION, constant(HazelcastConstants.GET_OPERATION))
.toF(<span class="code-quote">"hazelcast:%sbar"</span>, HazelcastConstants.MULTIMAP_PREFIX)
.to(<span class="code-quote">"seda:out"</span>);
</pre>
</div></div>

<p>Spring DSL:</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:get"</span> /&gt;
	&lt;log message=<span class="code-quote">"get.."</span>/&gt;
        &lt;!-- If using version 2.8 and above set headerName to <span class="code-quote">"CamelHazelcastOperationType"</span> --&gt;
	&lt;setHeader headerName=<span class="code-quote">"hazelcast.operation.type"</span>&gt;
		&lt;constant&gt;get&lt;/constant&gt;
	&lt;/setHeader&gt;
	&lt;to uri=<span class="code-quote">"hazelcast:multimap:foo"</span> /&gt;
	&lt;to uri=<span class="code-quote">"seda:out"</span> /&gt;
&lt;/route&gt;
</pre>
</div></div>

<h5><a name="HazelcastComponent-Samplefordelete%3A"></a>Sample for <b>delete</b>:</h5>

<p>Java DSL:</p>
<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="code-java">
from(<span class="code-quote">"direct:delete"</span>)
.setHeader(HazelcastConstants.OPERATION, constant(HazelcastConstants.DELETE_OPERATION))
.toF(<span class="code-quote">"hazelcast:%sbar"</span>, HazelcastConstants.MULTIMAP_PREFIX);
</pre>
</div></div>

<p>Spring DSL:</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:delete"</span> /&gt;
	&lt;log message=<span class="code-quote">"delete.."</span>/&gt;
        &lt;!-- If using version 2.8 and above set headerName to <span class="code-quote">"CamelHazelcastOperationType"</span> --&gt;
	&lt;setHeader headerName=<span class="code-quote">"hazelcast.operation.type"</span>&gt;
		&lt;constant&gt;delete&lt;/constant&gt;
	&lt;/setHeader&gt;
	&lt;to uri=<span class="code-quote">"hazelcast:multimap:foo"</span> /&gt;
&lt;/route&gt;
</pre>
</div></div>

<p>you can call them in your test class with:</p>

<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="code-java">
template.sendBodyAndHeader(<span class="code-quote">"direct:[put|get|removevalue|delete]"</span>, <span class="code-quote">"my-foo"</span>, HazelcastConstants.OBJECT_ID, <span class="code-quote">"4711"</span>);
</pre>
</div></div>

<h4><a name="HazelcastComponent-multimapcacheconsumerfrom%28%22hazelcast%3Amultimap%3Afoo%22%29"></a>multimap cache consumer - from("hazelcast:multimap:foo")</h4>

<p>For the multimap cache this component provides the same listeners / variables as for the map cache consumer (except the update and enviction listener). The only difference is the <b>multimap</b> prefix inside the URI. Here is a sample:</p>

<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="code-java">
fromF(<span class="code-quote">"hazelcast:%sbar"</span>, HazelcastConstants.MULTIMAP_PREFIX)
.log(<span class="code-quote">"object..."</span>)
.choice()
	.when(header(HazelcastConstants.LISTENER_ACTION).isEqualTo(HazelcastConstants.ADDED))
		.log(<span class="code-quote">"...added"</span>)
                .to(<span class="code-quote">"mock:added"</span>)
        <span class="code-comment">//.when(header(HazelcastConstants.LISTENER_ACTION).isEqualTo(HazelcastConstants.ENVICTED))
</span>        <span class="code-comment">//        .log(<span class="code-quote">"...envicted"</span>)
</span>        <span class="code-comment">//        .to(<span class="code-quote">"mock:envicted"</span>)
</span>        .when(header(HazelcastConstants.LISTENER_ACTION).isEqualTo(HazelcastConstants.REMOVED))
                .log(<span class="code-quote">"...removed"</span>)
                .to(<span class="code-quote">"mock:removed"</span>)
        .otherwise()
                .log(<span class="code-quote">"fail!"</span>);
</pre>
</div></div>

<p>Header Variables inside the response message:</p>
<div class='table-wrap'>
<table class='confluenceTable'><tbody>
<tr>
<th class='confluenceTh'> Name </th>
<th class='confluenceTh'> Type </th>
<th class='confluenceTh'> Description </th>
</tr>
<tr>
<td class='confluenceTd'> <tt>hazelcast.listener.time</tt> </td>
<td class='confluenceTd'> <tt>Long</tt> </td>
<td class='confluenceTd'> time of the event in millis </td>
</tr>
<tr>
<td class='confluenceTd'> <tt>hazelcast.listener.type</tt> </td>
<td class='confluenceTd'> <tt>String</tt> </td>
<td class='confluenceTd'> the map consumer sets here "cachelistener" </td>
</tr>
<tr>
<td class='confluenceTd'> <tt>hazelcast.listener.action</tt> </td>
<td class='confluenceTd'> <tt>String</tt> </td>
<td class='confluenceTd'> type of event - here <b>added</b> and <b>removed</b> (and soon <b>envicted</b>) </td>
</tr>
<tr>
<td class='confluenceTd'> <tt>hazelcast.objectId</tt> </td>
<td class='confluenceTd'> <tt>String</tt> </td>
<td class='confluenceTd'> the oid of the object </td>
</tr>
<tr>
<td class='confluenceTd'> <tt>hazelcast.cache.name</tt> </td>
<td class='confluenceTd'> <tt>String</tt> </td>
<td class='confluenceTd'> the name of the cache - e.g. "foo" </td>
</tr>
<tr>
<td class='confluenceTd'> <tt>hazelcast.cache.type</tt> </td>
<td class='confluenceTd'> <tt>String</tt> </td>
<td class='confluenceTd'> the type of the cache - here multimap </td>
</tr>
</tbody></table>
</div>


<p>Eviction will be added as feature, soon (this is a Hazelcast issue).</p>

<div class='panelMacro'><table class='warningMacro'><colgroup><col width='24'><col></colgroup><tr><td valign='top'><img src="/confluence/images/icons/emoticons/forbidden.gif" width="16" height="16" align="absmiddle" alt="" border="0"></td><td>Header variables have changed in Camel 2.8</td></tr></table></div>
<div class='table-wrap'>
<table class='confluenceTable'><tbody>
<tr>
<th class='confluenceTh'> Name </th>
<th class='confluenceTh'> Type </th>
<th class='confluenceTh'> Description </th>
</tr>
<tr>
<td class='confluenceTd'> <tt>CamelHazelcastListenerTime</tt> </td>
<td class='confluenceTd'> <tt>Long</tt> </td>
<td class='confluenceTd'> time of the event in millis <b><a href="/confluence/pages/createpage.action?spaceKey=CAMEL&amp;title=Version+2.8&amp;linkCreation=true&amp;fromPageId=25202845" class="createlink">Version 2.8</a></b> </td>
</tr>
<tr>
<td class='confluenceTd'> <tt>CamelHazelcastListenerType</tt> </td>
<td class='confluenceTd'> <tt>String</tt> </td>
<td class='confluenceTd'> the map consumer sets here "cachelistener" <b><a href="/confluence/pages/createpage.action?spaceKey=CAMEL&amp;title=Version+2.8&amp;linkCreation=true&amp;fromPageId=25202845" class="createlink">Version 2.8</a></b> </td>
</tr>
<tr>
<td class='confluenceTd'> <tt>CamelHazelcastListenerAction</tt> </td>
<td class='confluenceTd'> <tt>String</tt> </td>
<td class='confluenceTd'> type of event - here <b>added</b> and <b>removed</b> (and soon <b>envicted</b>) <b><a href="/confluence/pages/createpage.action?spaceKey=CAMEL&amp;title=Version+2.8&amp;linkCreation=true&amp;fromPageId=25202845" class="createlink">Version 2.8</a></b> </td>
</tr>
<tr>
<td class='confluenceTd'> <tt>CamelHazelcastObjectId</tt> </td>
<td class='confluenceTd'> <tt>String</tt> </td>
<td class='confluenceTd'> the oid of the object <b><a href="/confluence/pages/createpage.action?spaceKey=CAMEL&amp;title=Version+2.8&amp;linkCreation=true&amp;fromPageId=25202845" class="createlink">Version 2.8</a></b> </td>
</tr>
<tr>
<td class='confluenceTd'> <tt>CamelHazelcastCacheName</tt> </td>
<td class='confluenceTd'> <tt>String</tt> </td>
<td class='confluenceTd'> the name of the cache - e.g. "foo" <b><a href="/confluence/pages/createpage.action?spaceKey=CAMEL&amp;title=Version+2.8&amp;linkCreation=true&amp;fromPageId=25202845" class="createlink">Version 2.8</a></b> </td>
</tr>
<tr>
<td class='confluenceTd'> <tt>CamelHazelcastCacheType</tt> </td>
<td class='confluenceTd'> <tt>String</tt> </td>
<td class='confluenceTd'> the type of the cache - here multimap <b><a href="/confluence/pages/createpage.action?spaceKey=CAMEL&amp;title=Version+2.8&amp;linkCreation=true&amp;fromPageId=25202845" class="createlink">Version 2.8</a></b> </td>
</tr>
</tbody></table>
</div>


<p><a name="HazelcastComponent-queue"></a></p>

<h3><a name="HazelcastComponent-UsageofQueue"></a>Usage of Queue</h3>

<h4><a name="HazelcastComponent-Queueproducerto%28%E2%80%9Chazelcast%3Aqueue%3Afoo%E2%80%9D%29"></a>Queue producer &#8211; to(“hazelcast:queue:foo”)</h4>

<p>The queue producer provides 6 operations (add, put, poll, peek, offer, removevalue).</p>

<h5><a name="HazelcastComponent-Sampleforadd%3A"></a>Sample for <b>add</b>:</h5>

<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="code-java">
from(<span class="code-quote">"direct:add"</span>)
.setHeader(HazelcastConstants.OPERATION, constant(HazelcastConstants.ADD_OPERATION))
.toF(<span class="code-quote">"hazelcast:%sbar"</span>, HazelcastConstants.QUEUE_PREFIX);
</pre>
</div></div>

<h5><a name="HazelcastComponent-Sampleforput%3A"></a>Sample for <b>put</b>:</h5>

<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="code-java">
from(<span class="code-quote">"direct:put"</span>)
.setHeader(HazelcastConstants.OPERATION, constant(HazelcastConstants.PUT_OPERATION))
.toF(<span class="code-quote">"hazelcast:%sbar"</span>, HazelcastConstants.QUEUE_PREFIX);
</pre>
</div></div>

<h5><a name="HazelcastComponent-Sampleforpoll%3A"></a>Sample for <b>poll</b>:</h5>

<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="code-java">
from(<span class="code-quote">"direct:poll"</span>)
.setHeader(HazelcastConstants.OPERATION, constant(HazelcastConstants.POLL_OPERATION))
.toF(<span class="code-quote">"hazelcast:%sbar"</span>, HazelcastConstants.QUEUE_PREFIX);
</pre>
</div></div>

<h5><a name="HazelcastComponent-Sampleforpeek%3A"></a>Sample for <b>peek</b>:</h5>

<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="code-java">
from(<span class="code-quote">"direct:peek"</span>)
.setHeader(HazelcastConstants.OPERATION, constant(HazelcastConstants.PEEK_OPERATION))
.toF(<span class="code-quote">"hazelcast:%sbar"</span>, HazelcastConstants.QUEUE_PREFIX);
</pre>
</div></div>

<h5><a name="HazelcastComponent-Sampleforoffer%3A"></a>Sample for <b>offer</b>:</h5>

<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="code-java">
from(<span class="code-quote">"direct:offer"</span>)
.setHeader(HazelcastConstants.OPERATION, constant(HazelcastConstants.OFFER_OPERATION))
.toF(<span class="code-quote">"hazelcast:%sbar"</span>, HazelcastConstants.QUEUE_PREFIX);
</pre>
</div></div>

<h5><a name="HazelcastComponent-Sampleforremovevalue%3A"></a>Sample for <b>removevalue</b>:</h5>

<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="code-java">
from(<span class="code-quote">"direct:removevalue"</span>)
.setHeader(HazelcastConstants.OPERATION, constant(HazelcastConstants.REMOVEVALUE_OPERATION))
.toF(<span class="code-quote">"hazelcast:%sbar"</span>, HazelcastConstants.QUEUE_PREFIX);
</pre>
</div></div>

<h4><a name="HazelcastComponent-Queueconsumerfrom%28%E2%80%9Chazelcast%3Aqueue%3Afoo%E2%80%9D%29"></a>Queue consumer &#8211; from(“hazelcast:queue:foo”)</h4>

<p>The queue consumer provides 2 operations (add, remove).</p>

<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="code-java">
fromF(<span class="code-quote">"hazelcast:%smm"</span>, HazelcastConstants.QUEUE_PREFIX)
   .log(<span class="code-quote">"object..."</span>)
   .choice()
	.when(header(HazelcastConstants.LISTENER_ACTION).isEqualTo(HazelcastConstants.ADDED))
        	.log(<span class="code-quote">"...added"</span>)
		.to(<span class="code-quote">"mock:added"</span>)
	.when(header(HazelcastConstants.LISTENER_ACTION).isEqualTo(HazelcastConstants.REMOVED))
		.log(<span class="code-quote">"...removed"</span>)
		.to(<span class="code-quote">"mock:removed"</span>)
	.otherwise()
		.log(<span class="code-quote">"fail!"</span>);
</pre>
</div></div>


<p><a name="HazelcastComponent-list"></a></p>

<h3><a name="HazelcastComponent-UsageofList"></a>Usage of List</h3>

<h4><a name="HazelcastComponent-Listproducerto%28%E2%80%9Chazelcast%3Alist%3Afoo%E2%80%9D%29"></a>List producer &#8211; to(“hazelcast:list:foo”)</h4>

<p>The list producer provides 4 operations (add, set, get, removevalue).</p>

<h5><a name="HazelcastComponent-Sampleforadd%3A"></a>Sample for <b>add</b>:</h5>

<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="code-java">
from(<span class="code-quote">"direct:add"</span>)
.setHeader(HazelcastConstants.OPERATION, constant(HazelcastConstants.ADD_OPERATION))
.toF(<span class="code-quote">"hazelcast:%sbar"</span>, HazelcastConstants.LIST_PREFIX);
</pre>
</div></div>

<h5><a name="HazelcastComponent-Sampleforget%3A"></a>Sample for <b>get</b>:</h5>

<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(HazelcastConstants.OPERATION, constant(HazelcastConstants.GET_OPERATION))
.toF(<span class="code-quote">"hazelcast:%sbar"</span>, HazelcastConstants.LIST_PREFIX)
.to(<span class="code-quote">"seda:out"</span>);
</pre>
</div></div>

<h5><a name="HazelcastComponent-Sampleforsetvalue%3A"></a>Sample for <b>setvalue</b>:</h5>

<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="code-java">
from(<span class="code-quote">"direct:set"</span>)
.setHeader(HazelcastConstants.OPERATION, constant(HazelcastConstants.SETVALUE_OPERATION))
.toF(<span class="code-quote">"hazelcast:%sbar"</span>, HazelcastConstants.LIST_PREFIX);
</pre>
</div></div>

<h5><a name="HazelcastComponent-Sampleforremovevalue%3A"></a>Sample for <b>removevalue</b>:</h5>

<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="code-java">
from(<span class="code-quote">"direct:removevalue"</span>)
.setHeader(HazelcastConstants.OPERATION, constant(HazelcastConstants.REMOVEVALUE_OPERATION))
.toF(<span class="code-quote">"hazelcast:%sbar"</span>, HazelcastConstants.LIST_PREFIX);
</pre>
</div></div>

<div class='panelMacro'><table class='warningMacro'><colgroup><col width='24'><col></colgroup><tr><td valign='top'><img src="/confluence/images/icons/emoticons/forbidden.gif" width="16" height="16" align="absmiddle" alt="" border="0"></td><td>Please note that set,get and removevalue and not yet supported by hazelcast, will be added in the future..</td></tr></table></div>

<h4><a name="HazelcastComponent-Listconsumerfrom%28%E2%80%9Chazelcast%3Alist%3Afoo%E2%80%9D%29"></a>List consumer &#8211; from(“hazelcast:list:foo”)</h4>

<p>The list consumer provides 2 operations (add, remove).</p>

<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="code-java">
fromF(<span class="code-quote">"hazelcast:%smm"</span>, HazelcastConstants.LIST_PREFIX)
	.log(<span class="code-quote">"object..."</span>)
	.choice()
		.when(header(HazelcastConstants.LISTENER_ACTION).isEqualTo(HazelcastConstants.ADDED))
			.log(<span class="code-quote">"...added"</span>)
                        .to(<span class="code-quote">"mock:added"</span>)
		.when(header(HazelcastConstants.LISTENER_ACTION).isEqualTo(HazelcastConstants.REMOVED))
			.log(<span class="code-quote">"...removed"</span>)
                        .to(<span class="code-quote">"mock:removed"</span>)
                .otherwise()
                        .log(<span class="code-quote">"fail!"</span>);
</pre>
</div></div>


<p><a name="HazelcastComponent-seda"></a></p>

<h3><a name="HazelcastComponent-UsageofSEDA"></a>Usage of SEDA</h3>

<p>SEDA component differs from the rest components provided. It implements a work-queue in order to  support asynchronous SEDA architectures, similar to the core "SEDA" component.</p>

<h4><a name="HazelcastComponent-SEDAproducerto%28%E2%80%9Chazelcast%3Aseda%3Afoo%E2%80%9D%29"></a>SEDA producer &#8211; to(“hazelcast:seda:foo”)</h4>

<p>The SEDA producer provides no operations. You only send data to the specified queue.</p>

<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>transferExchange</tt> </td>
<td class='confluenceTd'> <tt>false</tt> </td>
<td class='confluenceTd'> <b>Camel 2.8.0:</b> if set to true the whole Exchange will be transfered. If header or body contains  not serializable objects, they will be skipped. </td>
</tr>
</tbody></table>
</div>


<p>Java DSL :</p>
<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="code-java">
from(<span class="code-quote">"direct:foo"</span>)
.to(<span class="code-quote">"hazelcast:seda:foo"</span>);
</pre>
</div></div>

<p>Spring DSL :</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">"hazelcast:seda:foo"</span> /&gt;
&lt;/route&gt;
</pre>
</div></div>

<h4><a name="HazelcastComponent-SEDAconsumerfrom%28%E2%80%9Chazelcast%3Aseda%3Afoo%E2%80%9D%29"></a>SEDA consumer &#8211; from(“hazelcast:seda:foo”)</h4>

<p>The SEDA consumer provides no operations. You only retrieve data from the specified queue.</p>

<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>pollInterval</tt> </td>
<td class='confluenceTd'> <tt>1000</tt> </td>
<td class='confluenceTd'> How frequent to poll from the SEDA queue </td>
</tr>
<tr>
<td class='confluenceTd'> <tt>concurrentConsumers</tt> </td>
<td class='confluenceTd'> <tt>1</tt> </td>
<td class='confluenceTd'> To use concurrent consumers polling from the SEDA queue. </td>
</tr>
<tr>
<td class='confluenceTd'> <tt>transferExchange</tt> </td>
<td class='confluenceTd'> <tt>false</tt> </td>
<td class='confluenceTd'> <b>Camel 2.8.0:</b> if set to true the whole Exchange will be transfered. If header or body contains  not serializable objects, they will be skipped. </td>
</tr>
<tr>
<td class='confluenceTd'> <tt>transacted</tt> </td>
<td class='confluenceTd'> <tt>false</tt> </td>
<td class='confluenceTd'> <b>Camel 2.11:</b> if set to true then the consumer runs in transaction mode, where the messages in the seda queue will only be removed if the transaction commits, which happens when the processing is complete. </td>
</tr>
</tbody></table>
</div>



<p>Java DSL :</p>
<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="code-java">
from(<span class="code-quote">"hazelcast:seda:foo"</span>)
.to(<span class="code-quote">"mock:result"</span>);
</pre>
</div></div>

<p>Spring DSL:</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">"hazelcast:seda:foo"</span> /&gt;
  &lt;to uri=<span class="code-quote">"mock:result"</span> /&gt;
&lt;/route&gt;
</pre>
</div></div>

<p><a name="HazelcastComponent-atomicnumber"></a></p>

<h3><a name="HazelcastComponent-UsageofAtomicNumber"></a>Usage of Atomic Number</h3>

<div class='panelMacro'><table class='warningMacro'><colgroup><col width='24'><col></colgroup><tr><td valign='top'><img src="/confluence/images/icons/emoticons/forbidden.gif" width="16" height="16" align="absmiddle" alt="" border="0"></td><td>There is no consumer for this endpoint&#33;</td></tr></table></div>


<h4><a name="HazelcastComponent-atomicnumberproducerto%28%22hazelcast%3Aatomicnumber%3Afoo%22%29"></a>atomic number producer - to("hazelcast:atomicnumber:foo")</h4>

<p>An atomic number is an object that simply provides a grid wide number (long). The operations for this producer are setvalue (set the number with a given value), get, increase (+1), decrease (-1) and destroy.</p>

<p>Header Variables for the request message:</p>
<div class='table-wrap'>
<table class='confluenceTable'><tbody>
<tr>
<th class='confluenceTh'> Name </th>
<th class='confluenceTh'> Type </th>
<th class='confluenceTh'> Description </th>
</tr>
<tr>
<td class='confluenceTd'> <tt>hazelcast.operation.type</tt> </td>
<td class='confluenceTd'> <tt>String</tt> </td>
<td class='confluenceTd'> valid values are: setvalue, get, increase, decrease, destroy </td>
</tr>
</tbody></table>
</div>


<div class='panelMacro'><table class='warningMacro'><colgroup><col width='24'><col></colgroup><tr><td valign='top'><img src="/confluence/images/icons/emoticons/forbidden.gif" width="16" height="16" align="absmiddle" alt="" border="0"></td><td>Header variables have changed in Camel 2.8</td></tr></table></div>
<div class='table-wrap'>
<table class='confluenceTable'><tbody>
<tr>
<th class='confluenceTh'> Name </th>
<th class='confluenceTh'> Type </th>
<th class='confluenceTh'> Description </th>
</tr>
<tr>
<td class='confluenceTd'> <tt>CamelHazelcastOperationType</tt> </td>
<td class='confluenceTd'> <tt>String</tt> </td>
<td class='confluenceTd'> valid values are: setvalue, get, increase, decrease, destroy <b>Available as of Camel version 2.8</b> </td>
</tr>
</tbody></table>
</div>


<h5><a name="HazelcastComponent-Sampleforset%3A"></a>Sample for <b>set</b>:</h5>

<p>Java DSL:</p>
<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="code-java">
from(<span class="code-quote">"direct:set"</span>)
.setHeader(HazelcastConstants.OPERATION, constant(HazelcastConstants.SETVALUE_OPERATION))
.toF(<span class="code-quote">"hazelcast:%sfoo"</span>, HazelcastConstants.ATOMICNUMBER_PREFIX);
</pre>
</div></div>

<p>Spring DSL:</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:set"</span> /&gt;
        &lt;!-- If using version 2.8 and above set headerName to <span class="code-quote">"CamelHazelcastOperationType"</span> --&gt;
	&lt;setHeader headerName=<span class="code-quote">"hazelcast.operation.type"</span>&gt;
		&lt;constant&gt;setvalue&lt;/constant&gt;
	&lt;/setHeader&gt;
	&lt;to uri=<span class="code-quote">"hazelcast:atomicvalue:foo"</span> /&gt;
&lt;/route&gt;
</pre>
</div></div>

<p>Provide the value to set inside the message body (here the value is 10): <tt>template.sendBody("direct:set", 10);</tt></p>

<h5><a name="HazelcastComponent-Sampleforget%3A"></a>Sample for <b>get</b>:</h5>

<p>Java DSL:</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(HazelcastConstants.OPERATION, constant(HazelcastConstants.GET_OPERATION))
.toF(<span class="code-quote">"hazelcast:%sfoo"</span>, HazelcastConstants.ATOMICNUMBER_PREFIX);
</pre>
</div></div>

<p>Spring DSL:</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:get"</span> /&gt;
        &lt;!-- If using version 2.8 and above set headerName to <span class="code-quote">"CamelHazelcastOperationType"</span> --&gt;
	&lt;setHeader headerName=<span class="code-quote">"hazelcast.operation.type"</span>&gt;
		&lt;constant&gt;get&lt;/constant&gt;
	&lt;/setHeader&gt;
	&lt;to uri=<span class="code-quote">"hazelcast:atomicvalue:foo"</span> /&gt;
&lt;/route&gt;
</pre>
</div></div>

<p>You can get the number with <tt>long body = template.requestBody("direct:get", null, Long.class);</tt>.</p>

<h5><a name="HazelcastComponent-Sampleforincrement%3A"></a>Sample for <b>increment</b>:</h5>

<p>Java DSL:</p>
<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="code-java">
from(<span class="code-quote">"direct:increment"</span>)
.setHeader(HazelcastConstants.OPERATION, constant(HazelcastConstants.INCREMENT_OPERATION))
.toF(<span class="code-quote">"hazelcast:%sfoo"</span>, HazelcastConstants.ATOMICNUMBER_PREFIX);
</pre>
</div></div>

<p>Spring DSL:</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:increment"</span> /&gt;
        &lt;!-- If using version 2.8 and above set headerName to <span class="code-quote">"CamelHazelcastOperationType"</span> --&gt;
	&lt;setHeader headerName=<span class="code-quote">"hazelcast.operation.type"</span>&gt;
		&lt;constant&gt;increment&lt;/constant&gt;
	&lt;/setHeader&gt;
	&lt;to uri=<span class="code-quote">"hazelcast:atomicvalue:foo"</span> /&gt;
&lt;/route&gt;
</pre>
</div></div>

<p>The actual value (after increment) will be provided inside the message body.</p>

<h5><a name="HazelcastComponent-Samplefordecrement%3A"></a>Sample for <b>decrement</b>:</h5>

<p>Java DSL:</p>
<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="code-java">
from(<span class="code-quote">"direct:decrement"</span>)
.setHeader(HazelcastConstants.OPERATION, constant(HazelcastConstants.DECREMENT_OPERATION))
.toF(<span class="code-quote">"hazelcast:%sfoo"</span>, HazelcastConstants.ATOMICNUMBER_PREFIX);
</pre>
</div></div>

<p>Spring DSL:</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:decrement"</span> /&gt;
        &lt;!-- If using version 2.8 and above set headerName to <span class="code-quote">"CamelHazelcastOperationType"</span> --&gt;
	&lt;setHeader headerName=<span class="code-quote">"hazelcast.operation.type"</span>&gt;
		&lt;constant&gt;decrement&lt;/constant&gt;
	&lt;/setHeader&gt;
	&lt;to uri=<span class="code-quote">"hazelcast:atomicvalue:foo"</span> /&gt;
&lt;/route&gt;
</pre>
</div></div>

<p>The actual value (after decrement) will be provided inside the message body.</p>

<h5><a name="HazelcastComponent-Samplefordestroy"></a>Sample for <b>destroy</b></h5>

<div class='panelMacro'><table class='warningMacro'><colgroup><col width='24'><col></colgroup><tr><td valign='top'><img src="/confluence/images/icons/emoticons/forbidden.gif" width="16" height="16" align="absmiddle" alt="" border="0"></td><td>There's a bug inside Hazelcast. So this feature may not work properly. Will be fixed in 1.9.3.</td></tr></table></div>
<p>Java DSL:</p>
<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="code-java">
from(<span class="code-quote">"direct:destroy"</span>)
.setHeader(HazelcastConstants.OPERATION, constant(HazelcastConstants.DESTROY_OPERATION))
.toF(<span class="code-quote">"hazelcast:%sfoo"</span>, HazelcastConstants.ATOMICNUMBER_PREFIX);
</pre>
</div></div>

<p>Spring DSL:</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:destroy"</span> /&gt;
        &lt;!-- If using version 2.8 and above set headerName to <span class="code-quote">"CamelHazelcastOperationType"</span> --&gt;
	&lt;setHeader headerName=<span class="code-quote">"hazelcast.operation.type"</span>&gt;
		&lt;constant&gt;destroy&lt;/constant&gt;
	&lt;/setHeader&gt;
	&lt;to uri=<span class="code-quote">"hazelcast:atomicvalue:foo"</span> /&gt;
&lt;/route&gt;
</pre>
</div></div>


<p><a name="HazelcastComponent-cluster"></a></p>

<h3><a name="HazelcastComponent-clustersupport"></a>cluster support</h3>

<div class='panelMacro'><table class='warningMacro'><colgroup><col width='24'><col></colgroup><tr><td valign='top'><img src="/confluence/images/icons/emoticons/forbidden.gif" width="16" height="16" align="absmiddle" alt="" border="0"></td><td>This endpoint provides no producer&#33;</td></tr></table></div>

<h3><a name="HazelcastComponent-instanceconsumerfrom%28%22hazelcast%3Ainstance%3Afoo%22%29"></a>instance consumer - from("hazelcast:instance:foo")</h3>

<p>Hazelcast makes sense in one single "server node", but it's extremly powerful in a clustered environment. The instance consumer fires if a new cache instance will join or leave the cluster.</p>

<p>Here's a sample:</p>

<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="code-java">
fromF(<span class="code-quote">"hazelcast:%sfoo"</span>, HazelcastConstants.INSTANCE_PREFIX)
.log(<span class="code-quote">"instance..."</span>)
.choice()
	.when(header(HazelcastConstants.LISTENER_ACTION).isEqualTo(HazelcastConstants.ADDED))
		.log(<span class="code-quote">"...added"</span>)
		.to(<span class="code-quote">"mock:added"</span>)
	.otherwise()
		.log(<span class="code-quote">"...removed"</span>)
		.to(<span class="code-quote">"mock:removed"</span>);
</pre>
</div></div>

<p>Each event provides the following information inside the message header:</p>

<p>Header Variables inside the response message:</p>
<div class='table-wrap'>
<table class='confluenceTable'><tbody>
<tr>
<th class='confluenceTh'> Name </th>
<th class='confluenceTh'> Type </th>
<th class='confluenceTh'> Description </th>
</tr>
<tr>
<td class='confluenceTd'> <tt>hazelcast.listener.time</tt> </td>
<td class='confluenceTd'> <tt>Long</tt> </td>
<td class='confluenceTd'> time of the event in millis </td>
</tr>
<tr>
<td class='confluenceTd'> <tt>hazelcast.listener.type</tt> </td>
<td class='confluenceTd'> <tt>String</tt> </td>
<td class='confluenceTd'> the map consumer sets here "instancelistener" </td>
</tr>
<tr>
<td class='confluenceTd'> <tt>hazelcast.listener.action</tt> </td>
<td class='confluenceTd'> <tt>String</tt> </td>
<td class='confluenceTd'> type of event - here <b>added</b> or <b>removed</b> </td>
</tr>
<tr>
<td class='confluenceTd'> <tt>hazelcast.instance.host</tt> </td>
<td class='confluenceTd'> <tt>String</tt> </td>
<td class='confluenceTd'> host name of the instance </td>
</tr>
<tr>
<td class='confluenceTd'> <tt>hazelcast.instance.port</tt> </td>
<td class='confluenceTd'> <tt>Integer</tt> </td>
<td class='confluenceTd'> port number of the instance </td>
</tr>
</tbody></table>
</div>


<div class='panelMacro'><table class='warningMacro'><colgroup><col width='24'><col></colgroup><tr><td valign='top'><img src="/confluence/images/icons/emoticons/forbidden.gif" width="16" height="16" align="absmiddle" alt="" border="0"></td><td>Header variables have changed in Camel 2.8</td></tr></table></div>
<div class='table-wrap'>
<table class='confluenceTable'><tbody>
<tr>
<th class='confluenceTh'> Name </th>
<th class='confluenceTh'> Type </th>
<th class='confluenceTh'> Description </th>
</tr>
<tr>
<td class='confluenceTd'> <tt>CamelHazelcastListenerTime</tt> </td>
<td class='confluenceTd'> <tt>Long</tt> </td>
<td class='confluenceTd'> time of the event in millis <b><a href="/confluence/pages/createpage.action?spaceKey=CAMEL&amp;title=Version+2.8&amp;linkCreation=true&amp;fromPageId=25202845" class="createlink">Version 2.8</a></b> </td>
</tr>
<tr>
<td class='confluenceTd'> <tt>CamelHazelcastListenerType</tt> </td>
<td class='confluenceTd'> <tt>String</tt> </td>
<td class='confluenceTd'> the map consumer sets here "instancelistener" <b><a href="/confluence/pages/createpage.action?spaceKey=CAMEL&amp;title=Version+2.8&amp;linkCreation=true&amp;fromPageId=25202845" class="createlink">Version 2.8</a></b> </td>
</tr>
<tr>
<td class='confluenceTd'> <tt>CamelHazelcastListenerActionn</tt> </td>
<td class='confluenceTd'> <tt>String</tt> </td>
<td class='confluenceTd'> type of event - here <b>added</b> or <b>removed</b>. <b><a href="/confluence/pages/createpage.action?spaceKey=CAMEL&amp;title=Version+2.8&amp;linkCreation=true&amp;fromPageId=25202845" class="createlink">Version 2.8</a></b> </td>
</tr>
<tr>
<td class='confluenceTd'> <tt>CamelHazelcastInstanceHost</tt> </td>
<td class='confluenceTd'> <tt>String</tt> </td>
<td class='confluenceTd'> host name of the instance <b><a href="/confluence/pages/createpage.action?spaceKey=CAMEL&amp;title=Version+2.8&amp;linkCreation=true&amp;fromPageId=25202845" class="createlink">Version 2.8</a></b> </td>
</tr>
<tr>
<td class='confluenceTd'> <tt>CamelHazelcastInstancePort</tt> </td>
<td class='confluenceTd'> <tt>Integer</tt> </td>
<td class='confluenceTd'> port number of the instance <b><a href="/confluence/pages/createpage.action?spaceKey=CAMEL&amp;title=Version+2.8&amp;linkCreation=true&amp;fromPageId=25202845" class="createlink">Version 2.8</a></b> </td>
</tr>
</tbody></table>
</div>

    </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/Hazelcast+Component">View Online</a>
        |
        <a href="https://cwiki.apache.org/confluence/pages/diffpagesbyversion.action?pageId=25202845&revisedVersion=10&originalVersion=9">View Changes</a>
                |
        <a href="https://cwiki.apache.org/confluence/display/CAMEL/Hazelcast+Component?showComments=true&amp;showCommentArea=true#addcomment">Add Comment</a>
            </div>
</div>
</div>
</div>
</div>
</body>
</html>

Mime
View raw message