= Hazelcast Atomic Number Component (deprecated)
: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-deprecated
:deprecated: *deprecated*
:tabs-sync-option:
:component-header: Only producer is supported
//Manually maintained attributes
:group: Hazelcast
:camel-spring-boot-name: hazelcast

*Since Camel {since}*

*{component-header}*

[WARNING]
====
*Deprecated*: This component is deprecated as of Camel 4.19.0 and will be removed in a future release.

Since Hazelcast 5.5, IAtomicLong requires the CP Subsystem which is only available in Hazelcast Enterprise Edition.
This component will throw `UnsupportedOperationException` at runtime when used with Hazelcast Community Edition 5.5+.
====

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 options: START
include::partial$component-configure-options.adoc[]
include::partial$component-endpoint-options.adoc[]
include::partial$component-endpoint-headers.adoc[]
// component 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

=== 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[]
