= 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
:tabs-sync-option:
: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
* increment (+1)
* decrement (-1)
* destroy
* compareAndSet
* getAndAdd

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

=== Example for *set*:

[tabs]
====

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

Spring XML::
+
[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);`

=== Example for *get*:

[tabs]
====

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

Spring XML::
+
[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);`.

=== Example for *increment*:

[tabs]
====

Java DSL::
+

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

Spring XML::
+
[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.

=== Example for *decrement*:

[tabs]
====

Java DSL::
+

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

Spring XML::
+
[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.

=== Example for *destroy*

[tabs]
====

Java DSL::
+

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

Spring XML::
+
[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[]
