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 Sat, 25 Jun 2011 14:05: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/~akarpe">Ashwin Karpe</a>
    </h4>
        <br/>
                         <h4>Changes (22)</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" >| {{hazelcast.objectId}} | {{String}} | the object id to store / find your object inside the cache (not needed for the query operation) | <br> <br></td></tr>
            <tr><td class="diff-added-lines" style="background-color: #dfd;">{warning} <br>Header variables have changed in Camel 2.8 <br>{warning} <br>|| Name || Type || Description || <br>| {{CamelHazelcastOperationType}} | {{String}} | valid values are: put, delete, get, update, query *Available as of Camel 2.8* | <br>| {{CamelHazelcastObjectId}} | {{String}} | the object id to store / find your object inside the cache (not needed for the query operation) *Available as of Camel 2.8* | <br> <br></td></tr>
            <tr><td class="diff-unchanged" >You can call the samples with: <br>{code} <br></td></tr>
            <tr><td class="diff-snipped" >...<br></td></tr>
            <tr><td class="diff-unchanged" >{code} <br> <br></td></tr>
            <tr><td class="diff-added-lines" style="background-color: #dfd;">*Starting Camel version 2.8* <br>{code} <br>&lt;route&gt; <br>	&lt;from uri=&quot;direct:put&quot; /&gt; <br>	&lt;setHeader headerName=&quot;CamelHazelcastOperationType&quot;&gt; <br>		&lt;constant&gt;put&lt;/constant&gt; <br>	&lt;/setHeader&gt; <br>	&lt;to uri=&quot;hazelcast:map:foo&quot; /&gt; <br>&lt;/route&gt; <br>{code} <br> <br></td></tr>
            <tr><td class="diff-unchanged" >h5. Sample for *get*: <br> <br></td></tr>
            <tr><td class="diff-snipped" >...<br></td></tr>
            <tr><td class="diff-unchanged" >{code} <br> <br></td></tr>
            <tr><td class="diff-added-lines" style="background-color: #dfd;">*Starting Camel version 2.8* <br>{code} <br>&lt;route&gt; <br>	&lt;from uri=&quot;direct:get&quot; /&gt; <br>	&lt;setHeader headerName=&quot;CamelHazelcastOperationType&quot;&gt; <br>		&lt;constant&gt;get&lt;/constant&gt; <br>	&lt;/setHeader&gt; <br>	&lt;to uri=&quot;hazelcast:map:foo&quot; /&gt; <br>	&lt;to uri=&quot;seda:out&quot; /&gt; <br>&lt;/route&gt; <br>{code} <br> <br></td></tr>
            <tr><td class="diff-unchanged" >h5. Sample for *update*: <br> <br></td></tr>
            <tr><td class="diff-snipped" >...<br></td></tr>
            <tr><td class="diff-unchanged" >{code} <br> <br></td></tr>
            <tr><td class="diff-added-lines" style="background-color: #dfd;">*Starting Camel version 2.8* <br>{code} <br>&lt;route&gt; <br>	&lt;from uri=&quot;direct:update&quot; /&gt; <br>	&lt;setHeader headerName=&quot;CamelHazelcastOperationType&quot;&gt; <br>		&lt;constant&gt;update&lt;/constant&gt; <br>	&lt;/setHeader&gt; <br>	&lt;to uri=&quot;hazelcast:map:foo&quot; /&gt; <br>&lt;/route&gt; <br>{code} <br> <br></td></tr>
            <tr><td class="diff-unchanged" >h5. Sample for *delete*: <br> <br></td></tr>
            <tr><td class="diff-snipped" >...<br></td></tr>
            <tr><td class="diff-unchanged" >{code} <br> <br></td></tr>
            <tr><td class="diff-added-lines" style="background-color: #dfd;">*Starting Camel version 2.8* <br>{code} <br>&lt;route&gt; <br>	&lt;from uri=&quot;direct:delete&quot; /&gt; <br>	&lt;setHeader headerName=&quot;CamelHazelcastOperationType&quot;&gt; <br>		&lt;constant&gt;delete&lt;/constant&gt; <br>	&lt;/setHeader&gt; <br>	&lt;to uri=&quot;hazelcast:map:foo&quot; /&gt; <br>&lt;/route&gt; <br>{code} <br> <br></td></tr>
            <tr><td class="diff-unchanged" >h5. Sample for *query* <br> <br></td></tr>
            <tr><td class="diff-snipped" >...<br></td></tr>
            <tr><td class="diff-unchanged" >{code} <br> <br></td></tr>
            <tr><td class="diff-added-lines" style="background-color: #dfd;">*Starting Camel version 2.8* <br>{code} <br>&lt;route&gt; <br>	&lt;from uri=&quot;direct:query&quot; /&gt; <br>	&lt;setHeader headerName=&quot;CamelHazelcastOperationType&quot;&gt; <br>		&lt;constant&gt;query&lt;/constant&gt; <br>	&lt;/setHeader&gt; <br>	&lt;to uri=&quot;hazelcast:map:foo&quot; /&gt; <br>	&lt;to uri=&quot;seda:out&quot; /&gt; <br>&lt;/route&gt; <br>{code} <br> <br></td></tr>
            <tr><td class="diff-unchanged" >For the query operation Hazelcast offers a SQL like syntax to query your distributed map. <br>{code} <br></td></tr>
            <tr><td class="diff-snipped" >...<br></td></tr>
            <tr><td class="diff-unchanged" >| {{hazelcast.cache.type}} | {{String}} | the type of the cache - here map | <br> <br></td></tr>
            <tr><td class="diff-added-lines" style="background-color: #dfd;">{warning} <br>Header variables have changed in Camel 2.8 <br>{warning} <br>|| Name || Type || Description || <br>| {{CamelHazelcastListenerTime}} | {{Long}} | time of the event in millis *Available as of Version 2.8* | <br>| {{CamelHazelcastListenerType}} | {{String}} | the map consumer sets here &quot;cachelistener&quot; *Available as of Version 2.8* | <br>| {{CamelHazelcastListenerAction}} | {{String}} | type of event - here *added*, *updated*, *envicted* and *removed*. *Available as of Version 2.8*| <br>| {{CamelHazelcastObjectId}} | {{String}} | the oid of the object | <br>| {{CamelHazelcastCacheName}} | {{String}} | the name of the cache - e.g. &quot;foo&quot; | <br>| {{CamelHazelcastCacheType}} | {{String}} | the type of the cache - here map | <br> <br></td></tr>
            <tr><td class="diff-unchanged" >The object value will be stored within *put* and *update* actions inside the message body. <br> <br></td></tr>
            <tr><td class="diff-snipped" >...<br></td></tr>
            <tr><td class="diff-unchanged" >| {{hazelcast.objectId}} | {{String}} | the object id to store / find your object inside the cache | <br> <br></td></tr>
            <tr><td class="diff-added-lines" style="background-color: #dfd;">{warning} <br>Header variables have changed in Camel 2.8 <br>{warning} <br>h2. Hazelcast Component <br> <br>*Available as of Camel 2.7* <br> <br>The *hazelcast:* component allows you to work with the [Hazelcast|http://www.hazelcast.com] 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 [http://www.hazelcast.com/documentation.jsp].    <br> <br>Maven users will need to add the following dependency to their {{pom.xml}} for this component: <br>{code:xml} <br>&lt;dependency&gt; <br>    &lt;groupId&gt;org.apache.camel&lt;/groupId&gt; <br>    &lt;artifactId&gt;camel-hazelcast&lt;/artifactId&gt; <br>    &lt;version&gt;x.x.x&lt;/version&gt; <br>    &lt;!-- use the same version as your Camel core version --&gt; <br>&lt;/dependency&gt; <br>{code} <br> <br>h3. URI format <br> <br>{code} <br>hazelcast:[ map | multimap | queue | seda | set | atomicvalue | instance]:cachename[?options] <br>{code} <br> <br>{warning} <br>You have to use the second prefix to define which type of data store you want to use.   <br>{warning} <br> <br>h3. Sections <br> <br># Usage of [#map] <br># Usage of [#multimap] <br># Usage of [#queue] <br># Usage of [#list] <br># Usage of [#seda] <br># Usage of [atomic number|#atomicnumber] <br># Usage of [#cluster] support (instance) <br> <br>{anchor:map} <br>h3. Usage of Map <br> <br>h4. map cache producer - to(&quot;hazelcast:map:foo&quot;) <br> <br>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 &quot;hazelcast.operation.type&quot; header variable. In Java DSL you can use the constants from {{org.apache.camel.component.hazelcast.HazelcastConstants}}. <br> <br>Header Variables for the request message: <br>|| Name || Type || Description || <br>| {{hazelcast.operation.type}} | {{String}} | valid values are: put, delete, get, update, query | <br>| {{hazelcast.objectId}} | {{String}} | the object id to store / find your object inside the cache (not needed for the query operation) | <br> <br>{warning} <br>Header variables have changed in Camel 2.8 <br>{warning} <br>|| Name || Type || Description || <br>| {{CamelHazelcastOperationType}} | {{String}} | valid values are: put, delete, get, update, query *Available as of Camel 2.8* | <br>| {{CamelHazelcastObjectId}} | {{String}} | the object id to store / find your object inside the cache (not needed for the query operation) *Available as of Camel 2.8* | <br> <br>You can call the samples with: <br>{code} <br>template.sendBodyAndHeader(&quot;direct:[put|get|update|delete|query]&quot;, &quot;my-foo&quot;, HazelcastConstants.OBJECT_ID, &quot;4711&quot;); <br>{code} <br> <br></td></tr>
            <tr><td class="diff-unchanged" >h5. Sample for *put*: <br> <br></td></tr>
            <tr><td class="diff-snipped" >...<br></td></tr>
            <tr><td class="diff-unchanged" >{code} <br>from(&quot;direct:put&quot;) <br></td></tr>
            <tr><td class="diff-added-lines" style="background-color: #dfd;">.setHeader(HazelcastConstants.OPERATION, constant(HazelcastConstants.PUT_OPERATION))	 <br>.toF(&quot;hazelcast:%sfoo&quot;, HazelcastConstants.MAP_PREFIX); <br>{code} <br> <br>Spring DSL: <br>{code} <br>&lt;route&gt; <br>	&lt;from uri=&quot;direct:put&quot; /&gt; <br>        &lt;!-- If using version 2.8 and above set headerName to &quot;CamelHazelcastOperationType&quot; --&gt; <br>	&lt;setHeader headerName=&quot;hazelcast.operation.type&quot;&gt; <br>		&lt;constant&gt;put&lt;/constant&gt; <br>	&lt;/setHeader&gt; <br>	&lt;to uri=&quot;hazelcast:map:foo&quot; /&gt; <br>&lt;/route&gt; <br>{code} <br> <br>h5. Sample for *get*: <br> <br>Java DSL: <br>{code} <br>from(&quot;direct:get&quot;) <br>.setHeader(HazelcastConstants.OPERATION, constant(HazelcastConstants.GET_OPERATION))	 <br>.toF(&quot;hazelcast:%sfoo&quot;, HazelcastConstants.MAP_PREFIX) <br>.to(&quot;seda:out&quot;); <br>{code} <br> <br>Spring DSL: <br>{code} <br>&lt;route&gt; <br>	&lt;from uri=&quot;direct:get&quot; /&gt; <br>        &lt;!-- If using version 2.8 and above set headerName to &quot;CamelHazelcastOperationType&quot; --&gt; <br>	&lt;setHeader headerName=&quot;hazelcast.operation.type&quot;&gt; <br>		&lt;constant&gt;get&lt;/constant&gt; <br>	&lt;/setHeader&gt; <br>	&lt;to uri=&quot;hazelcast:map:foo&quot; /&gt; <br>	&lt;to uri=&quot;seda:out&quot; /&gt; <br>&lt;/route&gt; <br>{code} <br> <br>h5. Sample for *update*: <br> <br>Java DSL: <br>{code} <br>from(&quot;direct:update&quot;) <br>.setHeader(HazelcastConstants.OPERATION, constant(HazelcastConstants.UPDATE_OPERATION)) <br>.toF(&quot;hazelcast:%sfoo&quot;, HazelcastConstants.MAP_PREFIX); <br>{code} <br> <br>Spring DSL: <br>{code} <br>&lt;route&gt; <br>	&lt;from uri=&quot;direct:update&quot; /&gt; <br>        &lt;!-- If using version 2.8 and above set headerName to &quot;CamelHazelcastOperationType&quot; --&gt; <br>	&lt;setHeader headerName=&quot;hazelcast.operation.type&quot;&gt; <br>		&lt;constant&gt;update&lt;/constant&gt; <br>	&lt;/setHeader&gt; <br>	&lt;to uri=&quot;hazelcast:map:foo&quot; /&gt; <br>&lt;/route&gt; <br>{code} <br> <br>h5. Sample for *delete*: <br> <br>Java DSL: <br>{code} <br>from(&quot;direct:delete&quot;) <br>.setHeader(HazelcastConstants.OPERATION, constant(HazelcastConstants.DELETE_OPERATION)) <br>.toF(&quot;hazelcast:%sfoo&quot;, HazelcastConstants.MAP_PREFIX); <br>{code} <br> <br>Spring DSL: <br>{code} <br>&lt;route&gt; <br>	&lt;from uri=&quot;direct:delete&quot; /&gt; <br>        &lt;!-- If using version 2.8 and above set headerName to &quot;CamelHazelcastOperationType&quot; --&gt; <br>	&lt;setHeader headerName=&quot;hazelcast.operation.type&quot;&gt; <br>		&lt;constant&gt;delete&lt;/constant&gt; <br>	&lt;/setHeader&gt; <br>	&lt;to uri=&quot;hazelcast:map:foo&quot; /&gt; <br>&lt;/route&gt; <br>{code} <br> <br>h5. Sample for *query* <br> <br>Java DSL: <br>{code} <br>from(&quot;direct:query&quot;) <br>.setHeader(HazelcastConstants.OPERATION, constant(HazelcastConstants.QUERY_OPERATION)) <br>.toF(&quot;hazelcast:%sfoo&quot;, HazelcastConstants.MAP_PREFIX) <br>.to(&quot;seda:out&quot;); <br>{code} <br> <br>Spring DSL: <br>{code} <br>&lt;route&gt; <br>	&lt;from uri=&quot;direct:query&quot; /&gt; <br>        &lt;!-- If using version 2.8 and above set headerName to &quot;CamelHazelcastOperationType&quot; --&gt; <br>	&lt;setHeader headerName=&quot;hazelcast.operation.type&quot;&gt; <br>		&lt;constant&gt;query&lt;/constant&gt; <br>	&lt;/setHeader&gt; <br>	&lt;to uri=&quot;hazelcast:map:foo&quot; /&gt; <br>	&lt;to uri=&quot;seda:out&quot; /&gt; <br>&lt;/route&gt; <br>{code} <br> <br>For the query operation Hazelcast offers a SQL like syntax to query your distributed map. <br>{code} <br>String q1 = &quot;bar &gt; 1000&quot;; <br>template.sendBodyAndHeader(&quot;direct:query&quot;, null, HazelcastConstants.QUERY, q1); <br>{code} <br> <br> <br>h3. map cache consumer - from(&quot;hazelcast:map:foo&quot;) <br> <br>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&#39;re 4 events: *put*, *update*, *delete* and *envict*. The event type will be stored in the &quot;*hazelcast.listener.action*&quot; header variable. The map consumer provides some additional information inside these variables: <br> <br>Header Variables inside the response message: <br>|| Name || Type || Description || <br>| {{hazelcast.listener.time}} | {{Long}} | time of the event in millis| <br>| {{hazelcast.listener.type}} | {{String}} | the map consumer sets here &quot;cachelistener&quot; | <br>| {{hazelcast.listener.action}} | {{String}} | type of event - here *added*, *updated*, *envicted* and *removed* | <br>| {{hazelcast.objectId}} | {{String}} | the oid of the object | <br>| {{hazelcast.cache.name}} | {{String}} | the name of the cache - e.g. &quot;foo&quot; | <br>| {{hazelcast.cache.type}} | {{String}} | the type of the cache - here map | <br> <br>{warning} <br>Header variables have changed in Camel 2.8 <br>{warning} <br>|| Name || Type || Description || <br>| {{CamelHazelcastListenerTime}} | {{Long}} | time of the event in millis *Available as of Version 2.8* | <br>| {{CamelHazelcastListenerType}} | {{String}} | the map consumer sets here &quot;cachelistener&quot; *Available as of Version 2.8* | <br>| {{CamelHazelcastListenerAction}} | {{String}} | type of event - here *added*, *updated*, *envicted* and *removed*. *Available as of Version 2.8* | <br>| {{CamelHazelcastObjectId}} | {{String}} | the oid of the object *Available as of Version 2.8* | <br>| {{CamelHazelcastCacheName}} | {{String}} | the name of the cache - e.g. &quot;foo&quot; *Available as of Version 2.8* | <br>| {{CamelHazelcastCacheType}} | {{String}} | the type of the cache - here map *Available as of Version 2.8* | <br> <br>The object value will be stored within *put* and *update* actions inside the message body. <br> <br>Here&#39;s a sample: <br>{code} <br>fromF(&quot;hazelcast:%sfoo&quot;, HazelcastConstants.MAP_PREFIX) <br>.log(&quot;object...&quot;) <br>.choice() <br>    .when(header(HazelcastConstants.LISTENER_ACTION).isEqualTo(HazelcastConstants.ADDED)) <br>         .log(&quot;...added&quot;) <br>         .to(&quot;mock:added&quot;) <br>    .when(header(HazelcastConstants.LISTENER_ACTION).isEqualTo(HazelcastConstants.ENVICTED)) <br>         .log(&quot;...envicted&quot;) <br>         .to(&quot;mock:envicted&quot;) <br>    .when(header(HazelcastConstants.LISTENER_ACTION).isEqualTo(HazelcastConstants.UPDATED)) <br>         .log(&quot;...updated&quot;) <br>         .to(&quot;mock:updated&quot;) <br>    .when(header(HazelcastConstants.LISTENER_ACTION).isEqualTo(HazelcastConstants.REMOVED)) <br>         .log(&quot;...removed&quot;) <br>         .to(&quot;mock:removed&quot;) <br>    .otherwise() <br>         .log(&quot;fail!&quot;); <br>{code} <br> <br>{anchor:multimap} <br>h3. Usage of Multi Map <br> <br>h4. multimap cache producer - to(&quot;hazelcast:multimap:foo&quot;) <br> <br>A multimap is a cache where you can store n values to one key. The multimap producer provides 4 operations (put, get, removevalue, delete).  <br> <br>Header Variables for the request message: <br>|| Name || Type || Description || <br>| {{hazelcast.operation.type}} | {{String}} | valid values are: put, get, removevalue, delete | <br>| {{hazelcast.objectId}} | {{String}} | the object id to store / find your object inside the cache | <br> <br>{warning} <br>Header variables have changed in Camel 2.8 <br>{warning} <br>|| Name || Type || Description || <br>| {{CamelHazelcastOperationType}} | {{String}} | valid values are: put, get, removevalue, delete *Available as of Version 2.8* | <br>| {{CamelHazelcastObjectId}} | {{String}} | the object id to store / find your object inside the cache *Available as of Version 2.8* | <br> <br>h5. Sample for *put*: <br> <br>Java DSL: <br>{code} <br>from(&quot;direct:put&quot;) <br></td></tr>
            <tr><td class="diff-unchanged" >.setHeader(HazelcastConstants.OPERATION, constant(HazelcastConstants.PUT_OPERATION)) <br>.to(String.format(&quot;hazelcast:%sbar&quot;, HazelcastConstants.MULTIMAP_PREFIX)); <br></td></tr>
            <tr><td class="diff-snipped" >...<br></td></tr>
            <tr><td class="diff-unchanged" >	&lt;from uri=&quot;direct:put&quot; /&gt; <br>	&lt;log message=&quot;put..&quot;/&gt; <br></td></tr>
            <tr><td class="diff-added-lines" style="background-color: #dfd;">        &lt;!-- If using version 2.8 and above set headerName to &quot;CamelHazelcastOperationType&quot; --&gt; <br></td></tr>
            <tr><td class="diff-unchanged" >	&lt;setHeader headerName=&quot;hazelcast.operation.type&quot;&gt; <br>		&lt;constant&gt;put&lt;/constant&gt; <br></td></tr>
            <tr><td class="diff-snipped" >...<br></td></tr>
            <tr><td class="diff-unchanged" >	&lt;from uri=&quot;direct:removevalue&quot; /&gt; <br>	&lt;log message=&quot;removevalue...&quot;/&gt; <br></td></tr>
            <tr><td class="diff-added-lines" style="background-color: #dfd;">        &lt;!-- If using version 2.8 and above set headerName to &quot;CamelHazelcastOperationType&quot; --&gt; <br></td></tr>
            <tr><td class="diff-unchanged" >	&lt;setHeader headerName=&quot;hazelcast.operation.type&quot;&gt; <br>		&lt;constant&gt;removevalue&lt;/constant&gt; <br></td></tr>
            <tr><td class="diff-snipped" >...<br></td></tr>
            <tr><td class="diff-unchanged" >	&lt;from uri=&quot;direct:get&quot; /&gt; <br>	&lt;log message=&quot;get..&quot;/&gt; <br></td></tr>
            <tr><td class="diff-added-lines" style="background-color: #dfd;">        &lt;!-- If using version 2.8 and above set headerName to &quot;CamelHazelcastOperationType&quot; --&gt; <br></td></tr>
            <tr><td class="diff-unchanged" >	&lt;setHeader headerName=&quot;hazelcast.operation.type&quot;&gt; <br>		&lt;constant&gt;get&lt;/constant&gt; <br></td></tr>
            <tr><td class="diff-snipped" >...<br></td></tr>
            <tr><td class="diff-unchanged" >	&lt;from uri=&quot;direct:delete&quot; /&gt; <br>	&lt;log message=&quot;delete..&quot;/&gt; <br></td></tr>
            <tr><td class="diff-added-lines" style="background-color: #dfd;">        &lt;!-- If using version 2.8 and above set headerName to &quot;CamelHazelcastOperationType&quot; --&gt; <br></td></tr>
            <tr><td class="diff-unchanged" >	&lt;setHeader headerName=&quot;hazelcast.operation.type&quot;&gt; <br>		&lt;constant&gt;delete&lt;/constant&gt; <br></td></tr>
            <tr><td class="diff-snipped" >...<br></td></tr>
            <tr><td class="diff-unchanged" >| {{hazelcast.cache.type}} | {{String}} | the type of the cache - here multimap | <br> <br></td></tr>
            <tr><td class="diff-changed-lines" ><span class="diff-changed-words">E<span class="diff-deleted-chars"style="color:#999;background-color:#fdd;text-decoration:line-through;">n</span>viction</span> will be added as feature, soon (this is a Hazelcast issue). <br></td></tr>
            <tr><td class="diff-unchanged" > <br></td></tr>
            <tr><td class="diff-added-lines" style="background-color: #dfd;">{warning} <br>Header variables have changed in Camel 2.8 <br>{warning} <br>|| Name || Type || Description || <br>| {{CamelHazelcastListenerTime}} | {{Long}} | time of the event in millis *Available as of Version 2.8* | <br>| {{CamelHazelcastListenerType}} | {{String}} | the map consumer sets here &quot;cachelistener&quot; *Available as of Version 2.8* | <br>| {{CamelHazelcastListenerAction}} | {{String}} | type of event - here *added* and *removed* (and soon *envicted*) *Available as of Version 2.8* | <br>| {{CamelHazelcastObjectId}} | {{String}} | the oid of the object *Available as of Version 2.8* | <br>| {{CamelHazelcastCacheName}} | {{String}} | the name of the cache - e.g. &quot;foo&quot; *Available as of Version 2.8* | <br>| {{CamelHazelcastCacheType}} | {{String}} | the type of the cache - here multimap *Available as of Version 2.8* | <br></td></tr>
            <tr><td class="diff-unchanged" > <br>{anchor:queue} <br></td></tr>
            <tr><td class="diff-snipped" >...<br></td></tr>
            <tr><td class="diff-unchanged" >| {{hazelcast.operation.type}} | {{String}} | valid values are: setvalue, get, increase, decrease, destroy | <br> <br></td></tr>
            <tr><td class="diff-added-lines" style="background-color: #dfd;">{warning} <br>Header variables have changed in Camel 2.8 <br>{warning} <br>|| Name || Type || Description || <br>| {{hazelcast.operation.type}} | {{String}} | valid values are: setvalue, get, increase, decrease, destroy *Available as of Camel version 2.8* | <br></td></tr>
            <tr><td class="diff-unchanged" >h5. Sample for *set*: <br> <br></td></tr>
            <tr><td class="diff-snipped" >...<br></td></tr>
            <tr><td class="diff-unchanged" >&lt;route&gt; <br>	&lt;from uri=&quot;direct:set&quot; /&gt; <br></td></tr>
            <tr><td class="diff-added-lines" style="background-color: #dfd;">        &lt;!-- If using version 2.8 and above set headerName to &quot;CamelHazelcastOperationType&quot; --&gt; <br></td></tr>
            <tr><td class="diff-unchanged" >	&lt;setHeader headerName=&quot;hazelcast.operation.type&quot;&gt; <br>		&lt;constant&gt;setvalue&lt;/constant&gt; <br></td></tr>
            <tr><td class="diff-snipped" >...<br></td></tr>
            <tr><td class="diff-unchanged" >&lt;route&gt; <br>	&lt;from uri=&quot;direct:get&quot; /&gt; <br></td></tr>
            <tr><td class="diff-added-lines" style="background-color: #dfd;">        &lt;!-- If using version 2.8 and above set headerName to &quot;CamelHazelcastOperationType&quot; --&gt; <br></td></tr>
            <tr><td class="diff-unchanged" >	&lt;setHeader headerName=&quot;hazelcast.operation.type&quot;&gt; <br>		&lt;constant&gt;get&lt;/constant&gt; <br></td></tr>
            <tr><td class="diff-snipped" >...<br></td></tr>
            <tr><td class="diff-unchanged" >&lt;route&gt; <br>	&lt;from uri=&quot;direct:increment&quot; /&gt; <br></td></tr>
            <tr><td class="diff-added-lines" style="background-color: #dfd;">        &lt;!-- If using version 2.8 and above set headerName to &quot;CamelHazelcastOperationType&quot; --&gt; <br></td></tr>
            <tr><td class="diff-unchanged" >	&lt;setHeader headerName=&quot;hazelcast.operation.type&quot;&gt; <br>		&lt;constant&gt;increment&lt;/constant&gt; <br></td></tr>
            <tr><td class="diff-snipped" >...<br></td></tr>
            <tr><td class="diff-unchanged" >&lt;route&gt; <br>	&lt;from uri=&quot;direct:decrement&quot; /&gt; <br></td></tr>
            <tr><td class="diff-added-lines" style="background-color: #dfd;">        &lt;!-- If using version 2.8 and above set headerName to &quot;CamelHazelcastOperationType&quot; --&gt; <br></td></tr>
            <tr><td class="diff-unchanged" >	&lt;setHeader headerName=&quot;hazelcast.operation.type&quot;&gt; <br>		&lt;constant&gt;decrement&lt;/constant&gt; <br></td></tr>
            <tr><td class="diff-snipped" >...<br></td></tr>
            <tr><td class="diff-unchanged" >&lt;route&gt; <br>	&lt;from uri=&quot;direct:destroy&quot; /&gt; <br></td></tr>
            <tr><td class="diff-added-lines" style="background-color: #dfd;">        &lt;!-- If using version 2.8 and above set headerName to &quot;CamelHazelcastOperationType&quot; --&gt; <br></td></tr>
            <tr><td class="diff-unchanged" >	&lt;setHeader headerName=&quot;hazelcast.operation.type&quot;&gt; <br>		&lt;constant&gt;destroy&lt;/constant&gt; <br></td></tr>
            <tr><td class="diff-snipped" >...<br></td></tr>
            <tr><td class="diff-unchanged" >| {{hazelcast.instance.host}} | {{String}} | host name of the instance | <br>| {{hazelcast.instance.port}} | {{Integer}} | port number of the instance | <br></td></tr>
            <tr><td class="diff-added-lines" style="background-color: #dfd;"> <br>{warning} <br>Header variables have changed in Camel 2.8 <br>{warning} <br>|| Name || Type || Description || <br>| {{CamelHazelcastListenerTime}} | {{Long}} | time of the event in millis *Available as of Version 2.8* | <br>| {{CamelHazelcastListenerType}} | {{String}} | the map consumer sets here &quot;instancelistener&quot; *Available as of Version 2.8* | <br>| {{CamelHazelcastListenerActionn}} | {{String}} | type of event - here *added* or *removed*. *Available as of Version 2.8* | <br>| {{CamelHazelcastInstanceHost}} | {{String}} | host name of the instance *Available as of Version 2.8* | <br>| {{CamelHazelcastInstancePort}} | {{Integer}} | port number of the instance *Available as of Version 2.8* | <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>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>Available as of Camel 2.8</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;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>

<p><b>Starting Camel version 2.8</b></p>
<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="code-java">
&lt;route&gt;
	&lt;from uri=<span class="code-quote">"direct:put"</span> /&gt;
	&lt;setHeader headerName=<span class="code-quote">"CamelHazelcastOperationType"</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;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>

<p><b>Starting Camel version 2.8</b></p>
<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="code-java">
&lt;route&gt;
	&lt;from uri=<span class="code-quote">"direct:get"</span> /&gt;
	&lt;setHeader headerName=<span class="code-quote">"CamelHazelcastOperationType"</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;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>

<p><b>Starting Camel version 2.8</b></p>
<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="code-java">
&lt;route&gt;
	&lt;from uri=<span class="code-quote">"direct:update"</span> /&gt;
	&lt;setHeader headerName=<span class="code-quote">"CamelHazelcastOperationType"</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;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>

<p><b>Starting Camel version 2.8</b></p>
<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="code-java">
&lt;route&gt;
	&lt;from uri=<span class="code-quote">"direct:delete"</span> /&gt;
	&lt;setHeader headerName=<span class="code-quote">"CamelHazelcastOperationType"</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;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><b>Starting Camel version 2.8</b></p>
<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="code-java">
&lt;route&gt;
	&lt;from uri=<span class="code-quote">"direct:query"</span> /&gt;
	&lt;setHeader headerName=<span class="code-quote">"CamelHazelcastOperationType"</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>Available as of Version 2.8</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>Available as of Version 2.8</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>Available as of Version 2.8</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 </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" </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 </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-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>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>Available as of Camel 2.8</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>Available as of Version 2.8</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>Available as of Version 2.8</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>Available as of Version 2.8</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>Available as of Version 2.8</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>Available as of Version 2.8</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>Available as of Version 2.8</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>Available as of Version 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 <b>Available as of Version 2.8</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>Available as of Version 2.8</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>Available as of Version 2.8</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>Available as of Version 2.8</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>Available as of Version 2.8</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>Available as of Version 2.8</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>Available as of Version 2.8</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-Queueproducer%E2%80%93to%28%E2%80%9Chazelcast%3Aqueue%3Afoo%E2%80%9D%29"></a>Queue producer – 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-Queueconsumer%E2%80%93from%28%E2%80%9Chazelcast%3Aqueue%3Afoo%E2%80%9D%29"></a>Queue consumer – 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-Listproducer%E2%80%93to%28%E2%80%9Chazelcast%3Alist%3Afoo%E2%80%9D%29"></a>List producer – 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-Listconsumer%E2%80%93from%28%E2%80%9Chazelcast%3Alist%3Afoo%E2%80%9D%29"></a>List consumer – 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-SEDAproducer%E2%80%93to%28%E2%80%9Chazelcast%3Aseda%3Afoo%E2%80%9D%29"></a>SEDA producer – 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-SEDAconsumer%E2%80%93from%28%E2%80%9Chazelcast%3Aseda%3Afoo%E2%80%9D%29"></a>SEDA consumer – from(“hazelcast:seda:foo”)</h4>

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

<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!</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>hazelcast.operation.type</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!</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>Available as of Version 2.8</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>Available as of Version 2.8</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>Available as of Version 2.8</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>Available as of Version 2.8</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>Available as of Version 2.8</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=7&originalVersion=6">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