Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
hazelcast:[ map | multimap | queue | topic | seda | set | atomicvalue | instance | list | ringbuffer]:cachename[?options]
Info

Topic support is available as of Camel 2.15. 

Info

RingBuffer support is available as of Camel 2.16. 

Options

NameRequiredDescription
hazelcastInstanceNoCamel 2.14: The hazelcast instance reference which can be used for hazelcast endpoint. If you don't specify the instance reference, camel use the default hazelcast instance from the camel-hazelcast instance.
hazelcastInstanceNameNoCamel 2.16: The hazelcast instance reference name which can be used for hazelcast endpoint. If you don't specify the instance reference, camel use the default hazelcast instance from the camel-hazelcast instance.
operation-1To specify a default operation to use, if no operation header has been provided. deprecated use defaultOperation instead.
defaultOperation-1Camel 2.15: To specify a default operation to use, if no operation header has been provided.

...

  1. Usage of #map
  2. Usage of #multimap
  3. Usage of #queue
  4. Usage of #topic
  5. Usage of #list
  6. Usage of #seda
  7. Usage of atomic number
  8. Usage of #cluster support (instance)
  9. Usage of #replicatedmap 
  10. Usage of #ringbuffer 

Anchor
map
map

Usage of Map

map cache producer - to("hazelcast:map:foo")

...

Name

Type

Description

hazelcast.operation.type

String

valid values are: put, delete, get, update, queryFrom Camel 2.16: getAll, clear

hazelcast.objectId

String

the object id to store / find your object inside the cache (not needed for the query operation)

...

Name

Type

Description

CamelHazelcastOperationType

String

valid values are: put, delete, get, update, query Version 2.8

From Camel 2.16: getAll, putIfAbsent, clear.

CamelHazelcastObjectId

String

the object id to store / find your object inside the cache (not needed for the query operation) Version 2.8

...

Name

Type

Description

hazelcast.operation.type

String

valid values are: put, get, removevalue, delete

From Camel 2.16: clear

hazelcast.objectId

String

the object id to store / find your object inside the cache

...

Name

Type

Description

CamelHazelcastOperationType

String

valid values are: put, delete, get, update, query removevalue, delete Version 2.8

From Available as of Camel 2.816: clear.

CamelHazelcastObjectId

String

the object id to store / find your object inside the cache (not needed for the query operation) Version 2.8

Sample for put:

Java DSLYou can call the samples with:

Code Block
template.sendBodyAndHeaderfrom("direct:[put|get|update|delete|query]", "my-foo", HazelcastConstants.OBJECT_ID, "4711");
Sample for put:

Java DSL:

Code Block
from("direct:put")
.put")
.setHeader(HazelcastConstants.OPERATION, constant(HazelcastConstants.PUT_OPERATION))
.to(String.toFformat("hazelcast:%sfoo%sbar", HazelcastConstants.MAPMULTIMAP_PREFIX));

Spring DSL:

Code Block
<route>
	<from uri="direct:put" />
	<log message="put.."/>
        <!-- If using version 2.8 and above set headerName to "CamelHazelcastOperationType" -->
	<setHeader headerName="hazelcast.operation.type">
		<constant>put</constant>
	</setHeader>
	<to uri="hazelcast:mapmultimap:foo" />
</route>
Sample for

...

removevalue:

Java DSL:

Code Block
from("direct:getremovevalue")
.setHeader(HazelcastConstants.OPERATION, constant(HazelcastConstants.GETREMOVEVALUE_OPERATION))
.toF("hazelcast:%sfoo%sbar", HazelcastConstants.MAPMULTIMAP_PREFIX)
.to("seda:out");

Spring DSL:

Code Block
<route>
	<from uri="direct:getremovevalue" />
    	<log message="removevalue..."/>
        <!-- If using version 2.8 and above set headerName to "CamelHazelcastOperationType" -->
	<setHeader headerName="hazelcast.operation.type">
		<constant>get<<constant>removevalue</constant>
	</setHeader>
	<to uri="hazelcast:mapmultimap:foo" />
	<to uri="seda:out" />
</route>

...

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

Sample for get:

Java DSL:

Code Block
from("direct:updateget")
.setHeader(HazelcastConstants.OPERATION, constant(HazelcastConstants.UPDATEGET_OPERATION))
.toF("hazelcast:%sfoo%sbar", HazelcastConstants.MAPMULTIMAP_PREFIX)
.to("seda:out");

Spring DSL:

Code Block
<route>
	<from uri="direct:updateget" />
	<log message="get.."/>
        <!-- If using version 2.8 and above set headerName to "CamelHazelcastOperationType" -->
	<setHeader headerName="hazelcast.operation.type">
		<constant>update<<constant>get</constant>
	</setHeader>
	<to uri="hazelcast:mapmultimap:foo" />
	<to uri="seda:out" />
</route>
Sample for delete:

...

Code Block
from("direct:delete")
.setHeader(HazelcastConstants.OPERATION, constant(HazelcastConstants.DELETE_OPERATION))
.toF("hazelcast:%sfoo%sbar", HazelcastConstants.MAPMULTIMAP_PREFIX);

Spring DSL:

Code Block
<route>
	<from uri="direct:delete" />
	<log message="delete.."/>
        <!-- If using version 2.8 and above set headerName to "CamelHazelcastOperationType" -->
	<setHeader headerName="hazelcast.operation.type">
		<constant>delete</constant>
	</setHeader>
	<to uri="hazelcast:mapmultimap:foo" />
</route>
Sample for query

Java DSLyou can call them in your test class with:

Code Block
fromtemplate.sendBodyAndHeader("direct:query")
.setHeader(HazelcastConstants.OPERATION, constant(HazelcastConstants.QUERY_OPERATION))
.toF("hazelcast:%sfoo[put|get|removevalue|delete]", "my-foo", HazelcastConstants.OBJECT_ID, "4711");

multimap cache consumer - from("hazelcast:multimap:foo")

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 multimap prefix inside the URI. Here is a sample:

Code Block
fromF("hazelcast:%sbar", HazelcastConstants.MAPMULTIMAP_PREFIX)
.tolog("seda:outobject...");

Spring DSL:

Code Block
<route>
	<from uri="direct:query" />

.choice()
	.when(header(HazelcastConstants.LISTENER_ACTION).isEqualTo(HazelcastConstants.ADDED))
		.log("...added")
            <!-- If using version 2.8 and above set headerName to "CamelHazelcastOperationType" -->
	<setHeader headerName="hazelcast.operation.type">
		<constant>query</constant>
	</setHeader>
	<to uri="hazelcast:map:foo" />
	<to uri="seda:out" />
</route>

For the query operation Hazelcast offers a SQL like syntax to query your distributed map.

Code Block
String q1 = "bar > 1000";
template.sendBodyAndHeader("direct:query", null, HazelcastConstants.QUERY, q1);

map cache consumer - from("hazelcast:map:foo")

...

.to("mock:added")
        //.when(header(HazelcastConstants.LISTENER_ACTION).isEqualTo(HazelcastConstants.ENVICTED))
        //        .log("...envicted")
        //        .to("mock:envicted")
        .when(header(HazelcastConstants.LISTENER_ACTION).isEqualTo(HazelcastConstants.REMOVED))
                .log("...removed")
                .to("mock:removed")
        .otherwise()
                .log("fail!");

Header Variables inside the response message:

Name

Type

Description

hazelcast.listener.time

Long

time of the event in millis

hazelcast.listener.type

String

the map consumer sets here "cachelistener"

hazelcast.listener.action

String

type of event - here added, updated, envicted and removed (and soon envicted)

hazelcast.objectId

String

the oid of the object

hazelcast.cache.name

String

the name of the cache - e.g. "foo"

hazelcast.cache.type

String

the type of the cache - here mapmultimap

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

Warning

Header variables have changed in Camel 2.8

Name

Type

Description

CamelHazelcastListenerTime

Long

time of the event in millis Version 2.8

CamelHazelcastListenerType

String

the map consumer sets here "cachelistener" Version 2.8

CamelHazelcastListenerAction

String

type of event - here added, updated, envicted and removed. (and soon envicted) Version 2.8

CamelHazelcastObjectId

String

the oid of the object Version 2.8

CamelHazelcastCacheName

String

the name of the cache - e.g. "foo" Version 2.8

CamelHazelcastCacheType

String

the type of the cache - here map multimap Version 2.8

The object value will be stored within put and update actions inside the message body.

...

Anchor
queue
queue

Usage of Queue

Queue producer – to(“hazelcast:queue:foo”)

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

Sample for add:
Code Block
fromFfrom("hazelcastdirect:%sfoo"add")
.setHeader(HazelcastConstants.OPERATION, constant(HazelcastConstants.MAPADD_PREFIXOPERATION))
.logtoF("object...")
.choice()
    .when(header(HazelcastConstants.LISTENER_ACTION).isEqualTo(HazelcastConstants.ADDED))
         .log("...added")
         .to("mock:added")
    .when(header(HazelcastConstants.LISTENER_ACTION).isEqualTo(HazelcastConstants.ENVICTED))
         .log("...envicted")
         .to("mock:envicted")
    .when(header(HazelcastConstants.LISTENER_ACTION).isEqualTo(HazelcastConstants.UPDATED))
         .log("...updated")
         .to("mock:updated")
    .when(header(HazelcastConstants.LISTENER_ACTION).isEqualTo(HazelcastConstants.REMOVED))
         .log("...removed")
         .to("mock:removed")
    .otherwise()
         .log("fail!");

...

hazelcast:%sbar", HazelcastConstants.QUEUE_PREFIX);
Sample for put:
Code Block
from("direct:put")
.setHeader(HazelcastConstants.OPERATION, constant(HazelcastConstants.PUT_OPERATION))
.toF("hazelcast:%sbar", HazelcastConstants.QUEUE_PREFIX);
Sample for poll:
Code Block
from("direct:poll")
.setHeader(HazelcastConstants.OPERATION, constant(HazelcastConstants.POLL_OPERATION))
.toF("hazelcast:%sbar", HazelcastConstants.QUEUE_PREFIX);
Sample for peek:
Code Block
from("direct:peek")
.setHeader(HazelcastConstants.OPERATION, constant(HazelcastConstants.PEEK_OPERATION))
.toF("hazelcast:%sbar", HazelcastConstants.QUEUE_PREFIX);
Sample for offer:
Code Block
from("direct:offer")
.setHeader(HazelcastConstants.OPERATION, constant(HazelcastConstants.OFFER_OPERATION))
.toF("hazelcast:%sbar", HazelcastConstants.QUEUE_PREFIX);
Sample for removevalue:
Code Block
from("direct:removevalue")
.setHeader(HazelcastConstants.OPERATION, constant(HazelcastConstants.REMOVEVALUE_OPERATION))
.toF("hazelcast:%sbar", HazelcastConstants.QUEUE_PREFIX);

Queue consumer – from(“hazelcast:queue:foo”)

The queue consumer provides 2 operations (add, remove).

Code Block
fromF("hazelcast:%smm", HazelcastConstants.QUEUE_PREFIX)
   .log("object...")
   .choice()
	.when(header(HazelcastConstants.LISTENER_ACTION).isEqualTo(HazelcastConstants.ADDED))
        	.log("...added")
		.to("mock:added")
	.when(header(HazelcastConstants.LISTENER_ACTION).isEqualTo(HazelcastConstants.REMOVED))
		.log("...removed")
		.to("mock:removed")
	.otherwise()
		.log("fail!");

Anchor
topic
topic

Usage of Topic

Topic producer – to(“hazelcast:topic:foo”)

The topic producer provides only one operation (publish).

Sample for publish:
Code Block
from("direct:add

...

Usage of Multi Map

multimap cache producer - to("hazelcast:multimap:foo")

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

Header Variables for the request message:

Name

Type

Description

hazelcast.operation.type

String

valid values are: put, get, removevalue, delete

hazelcast.objectId

String

the object id to store / find your object inside the cache

Warning

Header variables have changed in Camel 2.8

Name

Type

Description

CamelHazelcastOperationType

String

valid values are: put, get, removevalue, delete Version 2.8

CamelHazelcastObjectId

String

the object id to store / find your object inside the cache Version 2.8

Sample for put:

Java DSL:

Code Block
from("direct:put")
.setHeader(HazelcastConstants.OPERATION, constant(HazelcastConstants.PUT_OPERATION))
.to(String.format("hazelcast:%sbar", HazelcastConstants.MULTIMAP_PREFIX));

Spring DSL:

Code Block
<route>
	<from uri="direct:put" />
	<log message="put.."/>
        <!-- If using version 2.8 and above set headerName to "CamelHazelcastOperationType" -->
	<setHeader headerName="hazelcast.operation.type">
		<constant>put</constant>
	</setHeader>
	<to uri="hazelcast:multimap:foo" />
</route>
Sample for removevalue:

Java DSL:

Code Block
from("direct:removevalue")
.setHeader(HazelcastConstants.OPERATION, constant(HazelcastConstants.REMOVEVALUEPUBLISH_OPERATION))
.toF("hazelcast:%sbar", HazelcastConstants.MULTIMAPPUBLISH_PREFIXOPERATION);

Spring DSL:

Code Block
<route>
	<from uri="direct:removevalue" />
	<log message="removevalue..."/>
        <!-- If using version 2.8 and above set headerName to "CamelHazelcastOperationType" -->
	<setHeader headerName="hazelcast.operation.type">
		<constant>removevalue</constant>
	</setHeader>
	<to uri="hazelcast:multimap:foo" />
</route>

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

Sample for get:

Java DSL:

Topic consumer – from(“hazelcast:topic:foo”)

The topic consumer provides only one operation (received). This component is supposed to support multiple consumption as it's expected when it comes to topics so you are free to have as much consumers as you need on the same hazelcast topic.

Code Block
fromF("hazelcast:%sfoo", HazelcastConstants.TOPIC_PREFIX)
  .choice()
    .when(header(HazelcastConstants.LISTENER_ACTION).isEqualTo(HazelcastConstants.RECEIVED))
      .log("...message received")
    .otherwise()
      .log("...this should never have happened")

 

Anchor
list
list

Usage of List

List producer – to(“hazelcast:list:foo”)

The list producer provides 4 operations (add, addAll, set, get, removevalue, removeAll, clear).

Sample for add:
Code Block
from("direct:getadd")
.setHeader(HazelcastConstants.OPERATION, constant(HazelcastConstants.GETADD_OPERATION))
.toF("hazelcast:%sbar", HazelcastConstants.MULTIMAPLIST_PREFIX)
.to("seda:out");

...

Sample for get:
Code Block
<route>
	<from uri="direct:get" />
	<log message="get.."/>
        <!-- If using version 2.8 and above set headerName to "CamelHazelcastOperationType" -->
	<setHeader headerName="hazelcast.operation.type">
		<constant>get</constant>
	</setHeader>
	<to uri="hazelcast:multimap:foo" />
	<to uri="seda:out" />
</route>
Sample for delete:

Java DSL:

from("direct:get")
.setHeader(HazelcastConstants.OPERATION, constant(HazelcastConstants.GET_OPERATION))
.toF("hazelcast:%sbar", HazelcastConstants.LIST_PREFIX)
.to("seda:out");
Sample for setvalue:
Code Block
from("direct:set")
.setHeader(HazelcastConstants.OPERATION, constant(HazelcastConstants.SETVALUE_OPERATION))
.toF("hazelcast:%sbar", HazelcastConstants.LIST_PREFIX);
Sample for removevalue:
Code Block
from("direct:deleteremovevalue")
.setHeader(HazelcastConstants.OPERATION, constant(HazelcastConstants.DELETEREMOVEVALUE_OPERATION))
.toF("hazelcast:%sbar", HazelcastConstants.MULTIMAPLIST_PREFIX);

Spring DSL:

Note that CamelHazelcastObjectIndex header is used for indexing purpose.

The list consumer provides 2 operations (add, remove).List consumer – from(“hazelcast:list:foo”)

Code Block
fromF("hazelcast:%smm", HazelcastConstants.LIST_PREFIX)
	.log("object...")
	.choice()
		.when(header(HazelcastConstants.LISTENER_ACTION).isEqualTo(HazelcastConstants.ADDED))
			.log("...added")
Code Block
<route>
	<from uri="direct:delete" />
	<log message="delete.."/>
        <!-- If using version 2.8 and above set headerName to "CamelHazelcastOperationType" -->
	<setHeader headerName="hazelcast.operation.type">
		<constant>delete</constant>
	</setHeader>
	<to uri="hazelcast:multimap:foo" />
</route>

you can call them in your test class with:

Code Block
template.sendBodyAndHeader("direct:[put|get|removevalue|delete]", "my-foo", HazelcastConstants.OBJECT_ID, "4711");

multimap cache consumer - from("hazelcast:multimap:foo")

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 multimap prefix inside the URI. Here is a sample:

Code Block
fromF("hazelcast:%sbar", HazelcastConstants.MULTIMAP_PREFIX)
.log("object...")
.choice()
	.when(header(HazelcastConstants.LISTENER_ACTION).isEqualTo(HazelcastConstants.ADDED))
		.log("...added")
                .to("mock:added")
        //.when(header(HazelcastConstants.LISTENER_ACTION).isEqualTo(HazelcastConstants.ENVICTED))
        //        .log("...envicted")
        //        .to("mock:envicted")
        .when(header(HazelcastConstants.LISTENER_ACTION).isEqualTo(HazelcastConstants.REMOVED))
                .log("...removed")
                .to("mock:removed")
        .otherwise()
                .log("fail!");

Header Variables inside the response message:

Name

Type

Description

hazelcast.listener.time

Long

time of the event in millis

hazelcast.listener.type

String

the map consumer sets here "cachelistener"

hazelcast.listener.action

String

type of event - here added and removed (and soon envicted)

hazelcast.objectId

String

the oid of the object

hazelcast.cache.name

String

the name of the cache - e.g. "foo"

hazelcast.cache.type

String

the type of the cache - here multimap

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

Warning

Header variables have changed in Camel 2.8

Name

Type

Description

CamelHazelcastListenerTime

Long

time of the event in millis Version 2.8

CamelHazelcastListenerType

String

the map consumer sets here "cachelistener" Version 2.8

CamelHazelcastListenerAction

String

type of event - here added and removed (and soon envicted) Version 2.8

CamelHazelcastObjectId

String

the oid of the object Version 2.8

CamelHazelcastCacheName

String

the name of the cache - e.g. "foo" Version 2.8

CamelHazelcastCacheType

String

the type of the cache - here multimap Version 2.8

...

             .to("mock:added")
		.when(header(HazelcastConstants.LISTENER_ACTION).isEqualTo(HazelcastConstants.REMOVED))
			.log("...removed")
                        .to("mock:removed")
                .otherwise()
                        .log("fail!");

Anchor
seda
seda

Usage of SEDA

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.

SEDA producer – to(“hazelcast:seda:foo”)

The SEDA producer provides no operations. You only send data to the specified queue.

Name

default value

Description

transferExchange

false

Camel 2.8.0: if set to true the whole Exchange will be transfered. If header or body contains not serializable objects, they will be skipped.

Java DSL :

Code Block
from("direct:foo")
.to("hazelcast:seda:foo");

Spring DSL :

Code Block
<route>
   <from uri="direct:start" />
   <to uri="hazelcast:seda:foo" />
</route>

SEDA consumer – from(“hazelcast:seda:foo”)

The SEDA consumer provides no operations. You only retrieve data from the specified queue.

Name

default value

Description

pollInterval

1000

The timeout used when consuming from the SEDA queue. When a timeout occurs, the consumer can check whether it is allowed to continue running. Setting a lower value allows the consumer to react more quickly upon shutdown. (deprecated from Camel 2.15 onwards, use pollTimeout instead).

...

Usage of Queue

Queue producer – to(“hazelcast:queue:foo”)

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

Sample for add:
Code Block
from("direct:add")
.setHeader(HazelcastConstants.OPERATION, constant(HazelcastConstants.ADD_OPERATION))
.toF("hazelcast:%sbar", HazelcastConstants.QUEUE_PREFIX);
Sample for put:
Code Block
from("direct:put")
.setHeader(HazelcastConstants.OPERATION, constant(HazelcastConstants.PUT_OPERATION))
.toF("hazelcast:%sbar", HazelcastConstants.QUEUE_PREFIX);
Sample for poll:
Code Block
from("direct:poll")
.setHeader(HazelcastConstants.OPERATION, constant(HazelcastConstants.POLL_OPERATION))
.toF("hazelcast:%sbar", HazelcastConstants.QUEUE_PREFIX);
Sample for peek:
Code Block
from("direct:peek")
.setHeader(HazelcastConstants.OPERATION, constant(HazelcastConstants.PEEK_OPERATION))
.toF("hazelcast:%sbar", HazelcastConstants.QUEUE_PREFIX);
Sample for offer:
Code Block
from("direct:offer")
.setHeader(HazelcastConstants.OPERATION, constant(HazelcastConstants.OFFER_OPERATION))
.toF("hazelcast:%sbar", HazelcastConstants.QUEUE_PREFIX);
Sample for removevalue:
Code Block
from("direct:removevalue")
.setHeader(HazelcastConstants.OPERATION, constant(HazelcastConstants.REMOVEVALUE_OPERATION))
.toF("hazelcast:%sbar", HazelcastConstants.QUEUE_PREFIX);

Queue consumer – from(“hazelcast:queue:foo”)

The queue consumer provides 2 operations (add, remove).

Code Block
fromF("hazelcast:%smm", HazelcastConstants.QUEUE_PREFIX)
   .log("object...")
   .choice()
	.when(header(HazelcastConstants.LISTENER_ACTION).isEqualTo(HazelcastConstants.ADDED))
        	.log("...added")
		.to("mock:added")
	.when(header(HazelcastConstants.LISTENER_ACTION).isEqualTo(HazelcastConstants.REMOVED))
		.log("...removed")
		.to("mock:removed")
	.otherwise()
		.log("fail!");

...

Usage of Topic

Topic producer – to(“hazelcast:topic:foo”)

The topic producer provides only one operation (publish).

Sample for publish:
Code Block
from("direct:add")
.setHeader(HazelcastConstants.OPERATION, constant(HazelcastConstants.PUBLISH_OPERATION))
.toF("hazelcast:%sbar", HazelcastConstants.PUBLISH_OPERATION);

Topic consumer – from(“hazelcast:topic:foo”)

The topic consumer provides only one operation (received). This component is supposed to support multiple consumption as it's expected when it comes to topics so you are free to have as much consumers as you need on the same hazelcast topic.

Code Block
fromF("hazelcast:%sfoo", HazelcastConstants.TOPIC_PREFIX)
  .choice()
    .when(header(HazelcastConstants.LISTENER_ACTION).isEqualTo(HazelcastConstants.RECEIVED))
      .log("...message received")
    .otherwise()
      .log("...this should never have happened")

 

...

Usage of List

List producer – to(“hazelcast:list:foo”)

The list producer provides 4 operations (add, set, get, removevalue).

Sample for add:
Code Block
from("direct:add")
.setHeader(HazelcastConstants.OPERATION, constant(HazelcastConstants.ADD_OPERATION))
.toF("hazelcast:%sbar", HazelcastConstants.LIST_PREFIX);
Sample for get:
Code Block
from("direct:get")
.setHeader(HazelcastConstants.OPERATION, constant(HazelcastConstants.GET_OPERATION))
.toF("hazelcast:%sbar", HazelcastConstants.LIST_PREFIX)
.to("seda:out");
Sample for setvalue:
Code Block
from("direct:set")
.setHeader(HazelcastConstants.OPERATION, constant(HazelcastConstants.SETVALUE_OPERATION))
.toF("hazelcast:%sbar", HazelcastConstants.LIST_PREFIX);
Sample for removevalue:
Code Block
from("direct:removevalue")
.setHeader(HazelcastConstants.OPERATION, constant(HazelcastConstants.REMOVEVALUE_OPERATION))
.toF("hazelcast:%sbar", HazelcastConstants.LIST_PREFIX);
Warning

Please note that set,get and removevalue and not yet supported by hazelcast, will be added in the future..

List consumer – from(“hazelcast:list:foo”)

The list consumer provides 2 operations (add, remove).

Code Block
fromF("hazelcast:%smm", HazelcastConstants.LIST_PREFIX)
	.log("object...")
	.choice()
		.when(header(HazelcastConstants.LISTENER_ACTION).isEqualTo(HazelcastConstants.ADDED))
			.log("...added")
                        .to("mock:added")
		.when(header(HazelcastConstants.LISTENER_ACTION).isEqualTo(HazelcastConstants.REMOVED))
			.log("...removed")
                        .to("mock:removed")
                .otherwise()
                        .log("fail!");

...

Usage of SEDA

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.

SEDA producer – to(“hazelcast:seda:foo”)

The SEDA producer provides no operations. You only send data to the specified queue.

Name

default value

Description

transferExchange

false

Camel 2.8.0: if set to true the whole Exchange will be transfered. If header or body contains not serializable objects, they will be skipped.

Java DSL :

Code Block
from("direct:foo")
.to("hazelcast:seda:foo");

Spring DSL :

Code Block
<route>
   <from uri="direct:start" />
   <to uri="hazelcast:seda:foo" />
</route>

SEDA consumer – from(“hazelcast:seda:foo”)

The SEDA consumer provides no operations. You only retrieve data from the specified queue.

Name

default value

Description

pollInterval

1000

The timeout used when consuming from the SEDA queue. When a timeout occurs, the consumer can check whether it is allowed to continue running. Setting a lower value allows the consumer to react more quickly upon shutdown. (deprecated from Camel 2.15 onwards, use pollTimeout instead).

pollTimeout1000Camel 2.15: The timeout used when consuming from the SEDA queue. When a timeout occurs, the consumer can check whether it is allowed to continue running. Setting a lower value allows the consumer to react more quickly upon shutdown.

concurrentConsumers

1

To use concurrent consumers polling from the SEDA queue.

transferExchange

false

Camel 2.8.0: if set to true the whole Exchange will be transfered. If header or body contains not serializable objects, they will be skipped.

transacted

false

Camel 2.10.4: if set to true then the consumer runs in transaction mode, where the messages in the seda queue will only be removed if the transaction commits, which happens when the processing is complete.

...

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

Sample for get:

Java DSL:

Code Block
from("direct:get")
.setHeader(HazelcastConstants.OPERATION, constant(HazelcastConstants.GET_OPERATION))
.toF("hazelcast:%sfoo", HazelcastConstants.ATOMICNUMBER_PREFIX);

...

Name

Type

Description

CamelHazelcastOperationType

String

valid values are: put, get, removevalue, delete Version 2.8

CamelHazelcastObjectId

String

the object id to store / find your object inside the cache Version 2.8

Sample for put:

Java DSL:

Code Block
from("direct:put")
.setHeader(HazelcastConstants.OPERATION, constant(HazelcastConstants.PUT_OPERATION))
.to(String.format("hazelcast:%sbar", HazelcastConstants.REPLICATEDMAP_PREFIX));

...

Code Block
<route>
	<from uri="direct:put" />
	<log message="put.."/>
        <!-- If using version 2.8 and above set headerName to "CamelHazelcastOperationType" -->
	<setHeader headerName="hazelcast.operation.type">
		<constant>put</constant>
	</setHeader>
	<to uri="hazelcast:replicatedmap:foo" />
</route>
Sample for get:

Java DSL:

Code Block
from("direct:get")
.setHeader(HazelcastConstants.OPERATION, constant(HazelcastConstants.GET_OPERATION))
.toF("hazelcast:%sbar", HazelcastConstants.REPLICATEDMAP_PREFIX)
.to("seda:out");

...

Code Block
<route>
	<from uri="direct:get" />
	<log message="get.."/>
        <!-- If using version 2.8 and above set headerName to "CamelHazelcastOperationType" -->
	<setHeader headerName="hazelcast.operation.type">
		<constant>get</constant>
	</setHeader>
	<to uri="hazelcast:replicatedmap:foo" />
	<to uri="seda:out" />
</route>
Sample for delete:

Java DSL:

Code Block
from("direct:delete")
.setHeader(HazelcastConstants.OPERATION, constant(HazelcastConstants.DELETE_OPERATION))
.toF("hazelcast:%sbar", HazelcastConstants.REPLICATEDMAP_PREFIX);

...

Code Block
<route>
	<from uri="direct:delete" />
	<log message="delete.."/>
        <!-- If using version 2.8 and above set headerName to "CamelHazelcastOperationType" -->
	<setHeader headerName="hazelcast.operation.type">
		<constant>delete</constant>
	</setHeader>
	<to uri="hazelcast:replicatedmap:foo" />
</route>

you can call them in your test class with:

Code Block
template.sendBodyAndHeader("direct:[put|get|delete|clear]", "my-foo", HazelcastConstants.OBJECT_ID, "4711");

replicatedmap cache consumer - from("hazelcast:replicatedmap:foo")

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 multimap prefix inside the URI. Here is a sample:


</route>

you can call them in your test class with:

Code Block
template.sendBodyAndHeader("direct:[put|get|delete|clear]", "my-foo", HazelcastConstants.OBJECT_ID, "4711");

replicatedmap cache consumer - from("hazelcast:replicatedmap:foo")

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 multimap prefix inside the URI. Here is a sample:

Code Block
fromF("hazelcast:%sbar", HazelcastConstants.MULTIMAP_PREFIX)
.log("object...")
.choice()
	.when(header(HazelcastConstants.LISTENER_ACTION).isEqualTo(HazelcastConstants.ADDED))
		.log("...added")
                .to("mock:added")
        //.when(header(HazelcastConstants.LISTENER_ACTION).isEqualTo(HazelcastConstants.ENVICTED))
        //        .log("...envicted")
        //        .to("mock:envicted")
        
Code Block
fromF("hazelcast:%sbar", HazelcastConstants.MULTIMAP_PREFIX)
.log("object...")
.choice()
	.when(header(HazelcastConstants.LISTENER_ACTION).isEqualTo(HazelcastConstants.ADDEDREMOVED))
		                .log("...addedremoved")
                .to("mock:addedremoved")
        //.when(header(HazelcastConstants.LISTENER_ACTION).isEqualTo(HazelcastConstants.ENVICTED))
.otherwise()
           //        .log("...envicted")
        //        .to("mock:envicted")
        .when(header(HazelcastConstants.LISTENER_ACTION).isEqualTo(HazelcastConstants.REMOVED))
                .log("...removed")
                .to("mock:removed")
        .otherwise()
                .log("fail!");
      .log("fail!");

Header Variables inside the response message:

Name

Type

Description

hazelcast.listener.time

Long

time of the event in millis

hazelcast.listener.type

String

the map consumer sets here "cachelistener"

hazelcast.listener.action

String

type of event - here added and removed (and soon envicted)

hazelcast.objectId

String

the oid of the object

hazelcast.cache.name

String

the name of the cache - e.g. "foo"

hazelcast.cache.type

String

the type of the cache - here replicatedmap

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

Warning

Header variables have changed in Camel 2.8

Name

Type

Description

CamelHazelcastListenerTime

Long

time of the event in millis Version 2.8

CamelHazelcastListenerType

String

the map consumer sets here "cachelistener" Version 2.8

CamelHazelcastListenerAction

String

type of event - here added and removed (and soon envicted) Version 2.8

CamelHazelcastObjectId

String

the oid of the object Version 2.8

CamelHazelcastCacheName

String

the name of the cache - e.g. "foo" Version 2.8

CamelHazelcastCacheType

String

the type of the cache - here replicatedmap Version 2.8

Anchor
ringbuffer
ringbuffer

Usage of Ringbuffer

Avalaible from Camel 2.16

ringbuffer cache producer - to("hazelcast:ringbuffer:foo")

Ringbuffer is a distributed data structure where the data is stored in a ring-like structure. You can think of it as a circular array with a certain capacity. The ringbuffer producer provides 5 operations (add, readonceHead, readonceTail, remainingCapacity, capacity).

Header Variables for the request Header Variables inside the response message:

Name

Type

Description

hazelcast.listener.time

Long

time of the event in millis

hazelcast.listener.operation.type

String

the map consumer sets here "cachelistener"

hazelcast.listener.action

String

type of event - here added and removed (and soon envicted)

hazelcast.objectId

String

the oid of the object

hazelcast.cache.name

String

the name of the cache - e.g. "foo"

hazelcast.cache.type

String

the type of the cache - here replicatedmap

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

Warning

Header variables have changed in Camel 2.8

...

Name

...

Type

...

Description

...

CamelHazelcastListenerTime

...

Long

...

time of the event in millis Version 2.8

...

CamelHazelcastListenerType

...

String

...

the map consumer sets here "cachelistener" Version 2.8

...

CamelHazelcastListenerAction

...

String

...

type of event - here added and removed (and soon envicted) Version 2.8

...

CamelHazelcastObjectId

...

String

...

the oid of the object Version 2.8

...

CamelHazelcastCacheName

...

String

...

the name of the cache - e.g. "foo" Version 2.8

valid values are: add, readonceHead, readonceTail, remainingCapacity, capacity

Warning

Header variables have changed in Camel 2.8

Name

Type

Description

CamelHazelcastOperationType

String

valid values are: put, get, removevalue, delete Version 2.8

CamelHazelcastObjectId

String

the object id to store / find your object inside the cache Version 2.8

Sample for put:

Java DSL:

Code Block
from("direct:put")
.setHeader(HazelcastConstants.OPERATION, constant(HazelcastConstants.ADD_OPERATION))
.to(String.format("hazelcast:%sbar", HazelcastConstants.RINGBUFFER_PREFIX));

Spring DSL:

Code Block
<route>
	<from uri="direct:put" />
	<log message="put.."/>
        <!-- If using version 2.8 and above set headerName to "CamelHazelcastOperationType" -->
	<setHeader headerName="hazelcast.operation.type">
		<constant>add</constant>
	</setHeader>
	<to uri="hazelcast:ringbuffer:foo" />
</route>
Sample for readonce from head:

Java DSL:

Code Block
from("direct:get")
.setHeader(HazelcastConstants.OPERATION, constant(HazelcastConstants.READ_ONCE_HEAD_OPERATION))
.toF("hazelcast:%sbar", HazelcastConstants.RINGBUFFER_PREFIX)
.to("seda:out");

...

CamelHazelcastCacheType

...

String

...