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")

...

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

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

...

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..

Note that CamelHazelcastObjectIndex header is used for indexing purpose.

The list consumer provides 2 operations (add, remove).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!");

...

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 message:

Name

Type

Description

hazelcast.operation.type

String

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");