= Hazelcast Instance Component
:doctitle: Hazelcast Instance
:shortname: hazelcast-instance
:artifactid: camel-hazelcast
:description: Consume join/leave events of a cache instance in a Hazelcast cluster.
:since: 2.7
:supportlevel: Stable
:component-header: Only consumer is supported
//Manually maintained attributes
:group: Hazelcast
:camel-spring-boot-name: hazelcast

*Since Camel {since}*

*{component-header}*

The http://www.hazelcast.com/[Hazelcast] instance component is one of Camel Hazelcast Components which allows you to consume join/leave events of the cache instance in the cluster.
Hazelcast makes sense in one single "server node", but it's extremly powerful in a clustered environment.

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


== instance consumer - from("hazelcast-instance:foo")

The instance consumer fires if a new cache instance will join or leave the cluster.
 
Here's a sample:

[source,java]
-----------------------------------------------------------------------------------------
fromF("hazelcast-%sfoo", HazelcastConstants.INSTANCE_PREFIX)
.log("instance...")
.choice()
    .when(header(HazelcastConstants.LISTENER_ACTION).isEqualTo(HazelcastConstants.ADDED))
        .log("...added")
        .to("mock:added")
    .otherwise()
        .log("...removed")
        .to("mock:removed");
-----------------------------------------------------------------------------------------

Each event provides the following information inside the message header:

Header Variables inside the response message:


[width="100%",cols="10%,10%,80%",options="header",]
|=======================================================================
|Name |Type |Description

|`CamelHazelcastListenerTime` |`Long` |time of the event in millis

|`CamelHazelcastListenerType` |`String` |the map consumer sets here "instancelistener"

|`CamelHazelcastListenerAction` |`String` |type of event - here *added* or *removed*.

|`CamelHazelcastInstanceHost` |`String` | host name of the instance

|`CamelHazelcastInstancePort` |`Integer` |port number of the instance
|=======================================================================


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