= Hazelcast Atomic Number Component
:doctitle: Hazelcast Atomic Number
:shortname: hazelcast-atomicvalue
:artifactid: camel-hazelcast
:description: Increment, decrement, set, etc. Hazelcast atomic number (a grid wide number).
:since: 2.7
:supportlevel: Stable
:component-header: Only producer is supported
//Manually maintained attributes
:group: Hazelcast
:camel-spring-boot-name: hazelcast

*Since Camel {since}*

*{component-header}*

The http://www.hazelcast.com/[Hazelcast] atomic number component is one of Camel Hazelcast Components which allows you to access Hazelcast atomic number.
An atomic number is an object that simply provides a grid wide number (long). 


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


== atomic number producer - to("hazelcast-atomicvalue:foo")

The operations for this producer are:
* setvalue (set the number with a given value)
* get
* increase (+1)
* decrease (-1)
* destroy

Header Variables for the request message:

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

|`CamelHazelcastOperationType` |`String` |valid values are: setvalue, get, increase, decrease, destroy 
|=======================================================================

=== Sample for *set*:

Java DSL:

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

Spring DSL:

[source,xml]
-----------------------------------------------------------------------------------------------
<route>
    <from uri="direct:set" />
    <setHeader name="hazelcast.operation.type">
        <constant>setvalue</constant>
    </setHeader>
    <to uri="hazelcast-atomicvalue:foo" />
</route>
-----------------------------------------------------------------------------------------------

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

=== Sample for *get*:

Java DSL:

[source,java]
------------------------------------------------------------------------------------
from("direct:get")
.setHeader(HazelcastConstants.OPERATION, constant(HazelcastOperation.GET))
.toF("hazelcast-%sfoo", HazelcastConstants.ATOMICNUMBER_PREFIX);
------------------------------------------------------------------------------------

Spring DSL:

[source,xml]
-----------------------------------------------------------------------------------------------
<route>
    <from uri="direct:get" />
    <setHeader name="hazelcast.operation.type">
        <constant>get</constant>
    </setHeader>
    <to uri="hazelcast-atomicvalue:foo" />
</route>
-----------------------------------------------------------------------------------------------

You can get the number with
`long body = template.requestBody("direct:get", null, Long.class);`.

=== Sample for *increment*:

Java DSL:

[source,java]
------------------------------------------------------------------------------------------
from("direct:increment")
.setHeader(HazelcastConstants.OPERATION, constant(HazelcastOperation.INCREMENT))
.toF("hazelcast-%sfoo", HazelcastConstants.ATOMICNUMBER_PREFIX);
------------------------------------------------------------------------------------------

Spring DSL:

[source,xml]
-----------------------------------------------------------------------------------------------
<route>
    <from uri="direct:increment" />
    <setHeader name="hazelcast.operation.type">
        <constant>increment</constant>
    </setHeader>
    <to uri="hazelcast-atomicvalue:foo" />
</route>
-----------------------------------------------------------------------------------------------

The actual value (after increment) will be provided inside the message
body.

=== Sample for *decrement*:

Java DSL:

[source,java]
------------------------------------------------------------------------------------------
from("direct:decrement")
.setHeader(HazelcastConstants.OPERATION, constant(HazelcastOperation.DECREMENT))
.toF("hazelcast-%sfoo", HazelcastConstants.ATOMICNUMBER_PREFIX);
------------------------------------------------------------------------------------------

Spring DSL:

[source,xml]
-----------------------------------------------------------------------------------------------
<route>
    <from uri="direct:decrement" />
    <setHeader name="hazelcast.operation.type">
        <constant>decrement</constant>
    </setHeader>
    <to uri="hazelcast-atomicvalue:foo" />
</route>
-----------------------------------------------------------------------------------------------

The actual value (after decrement) will be provided inside the message
body.

=== Sample for *destroy*

Java DSL:

[source,java]
----------------------------------------------------------------------------------------
from("direct:destroy")
.setHeader(HazelcastConstants.OPERATION, constant(HazelcastOperation.DESTROY))
.toF("hazelcast-%sfoo", HazelcastConstants.ATOMICNUMBER_PREFIX);
----------------------------------------------------------------------------------------

Spring DSL:

[source,xml]
-----------------------------------------------------------------------------------------------
<route>
    <from uri="direct:destroy" />
    <setHeader name="hazelcast.operation.type">
        <constant>destroy</constant>
    </setHeader>
    <to uri="hazelcast-atomicvalue:foo" />
</route>
-----------------------------------------------------------------------------------------------


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