= Hazelcast List Component
:doctitle: Hazelcast List
:shortname: hazelcast-list
:artifactid: camel-hazelcast
:description: Perform operations on Hazelcast distributed list.
:since: 2.7
:supportlevel: Stable
:component-header: Both producer and consumer are supported
//Manually maintained attributes
:group: Hazelcast
:camel-spring-boot-name: hazelcast

*Since Camel {since}*

*{component-header}*

The http://www.hazelcast.com/[Hazelcast] List component is one of Camel Hazelcast Components which allows you to access Hazelcast distributed list.

== Options

// component-configure options: START

// component-configure options: END

// component options: START
include::partial$component-configure-options.adoc[]
include::partial$component-endpoint-options.adoc[]
// component options: END

// endpoint options: START

// endpoint options: END


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

The list producer provides 8 operations:

* add
* addAll
* setvalue
* get
* removevalue
* removeAll
* clear
* retainAll

// component headers: START
include::partial$component-endpoint-headers.adoc[]
// component headers: END

=== Sample for *add*:

[source,java]
------------------------------------------------------------------------------------
from("direct:add")
.setHeader(HazelcastConstants.OPERATION, constant(HazelcastOperation.ADD))
.toF("hazelcast-%sbar", HazelcastConstants.LIST_PREFIX);
------------------------------------------------------------------------------------

=== Sample for *get*:

[source,java]
------------------------------------------------------------------------------------
from("direct:get")
.setHeader(HazelcastConstants.OPERATION, constant(HazelcastOperation.GET))
.toF("hazelcast-%sbar", HazelcastConstants.LIST_PREFIX)
.to("seda:out");
------------------------------------------------------------------------------------

=== Sample for *setvalue*:

[source,java]
-----------------------------------------------------------------------------------------
from("direct:set")
.setHeader(HazelcastConstants.OPERATION, constant(HazelcastOperation.SET_VALUE))
.toF("hazelcast-%sbar", HazelcastConstants.LIST_PREFIX);
-----------------------------------------------------------------------------------------

=== Sample for *removevalue*:

[source,java]
--------------------------------------------------------------------------------------------
from("direct:removevalue")
.setHeader(HazelcastConstants.OPERATION, constant(HazelcastOperation.REMOVE_VALUE))
.toF("hazelcast-%sbar", HazelcastConstants.LIST_PREFIX);
--------------------------------------------------------------------------------------------

Note that *CamelHazelcastObjectIndex* header is used for indexing
purpose.


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

The list consumer provides 2 operations:
* add
* remove

[source,java]
-----------------------------------------------------------------------------------------------
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!");
-----------------------------------------------------------------------------------------------


include::spring-boot:partial$starter.adoc[]
