[[hazelcast-atomicvalue-component]]
= Hazelcast Atomic Number Component
//THIS FILE IS COPIED: EDIT THE SOURCE FILE:
:page-source: components/camel-hazelcast/src/main/docs/hazelcast-atomicvalue-component.adoc
:docTitle: Hazelcast Atomic Number
: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
include::{cq-version}@camel-quarkus:ROOT:partial$reference/components/hazelcast-atomicvalue.adoc[opts=optional]
//Manually maintained attributes
:group: 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). 

*There is no consumer for this endpoint!*


== Options

// component options: START
The Hazelcast Atomic Number component supports 4 options, which are listed below.



[width="100%",cols="2,5,^1,2",options="header"]
|===
| Name | Description | Default | Type
| *lazyStartProducer* (producer) | Whether the producer should be started lazy (on the first message). By starting lazy you can use this to allow CamelContext and routes to startup in situations where a producer may otherwise fail during starting and cause the route to fail being started. By deferring this startup to be lazy then the startup failure can be handled during routing messages via Camel's routing error handlers. Beware that when the first message is processed then creating and starting the producer may take a little time and prolong the total processing time of the processing. | false | boolean
| *autowiredEnabled* (advanced) | Whether autowiring is enabled. This is used for automatic autowiring options (the option must be marked as autowired) by looking up in the registry to find if there is a single instance of matching type, which then gets configured on the component. This can be used for automatic configuring JDBC data sources, JMS connection factories, AWS Clients, etc. | true | boolean
| *hazelcastInstance* (advanced) | The hazelcast instance reference which can be used for hazelcast endpoint. If you don't specify the instance reference, camel use the default hazelcast instance from the camel-hazelcast instance. |  | HazelcastInstance
| *hazelcastMode* (advanced) | The hazelcast mode reference which kind of instance should be used. If you don't specify the mode, then the node mode will be the default. | node | String
|===
// component options: END

// endpoint options: START
The Hazelcast Atomic Number endpoint is configured using URI syntax:

----
hazelcast-atomicvalue:cacheName
----

with the following path and query parameters:

=== Path Parameters (1 parameters):


[width="100%",cols="2,5,^1,2",options="header"]
|===
| Name | Description | Default | Type
| *cacheName* | *Required* The name of the cache |  | String
|===


=== Query Parameters (5 parameters):


[width="100%",cols="2,5,^1,2",options="header"]
|===
| Name | Description | Default | Type
| *defaultOperation* (producer) | To specify a default operation to use, if no operation header has been provided. There are 36 enums and the value can be one of: put, delete, get, update, query, getAll, clear, putIfAbsent, allAll, removeAll, retainAll, evict, evictAll, valueCount, containsKey, containsValue, keySet, removevalue, increment, decrement, setvalue, destroy, compareAndSet, getAndAdd, add, offer, peek, poll, remainingCapacity, drainTo, removeIf, take, publish, readOnceHeal, readOnceTail, capacity |  | HazelcastOperation
| *hazelcastInstance* (producer) | The hazelcast instance reference which can be used for hazelcast endpoint. |  | HazelcastInstance
| *hazelcastInstanceName* (producer) | The hazelcast instance reference name which can be used for hazelcast endpoint. If you don't specify the instance reference, camel use the default hazelcast instance from the camel-hazelcast instance. |  | String
| *lazyStartProducer* (producer) | Whether the producer should be started lazy (on the first message). By starting lazy you can use this to allow CamelContext and routes to startup in situations where a producer may otherwise fail during starting and cause the route to fail being started. By deferring this startup to be lazy then the startup failure can be handled during routing messages via Camel's routing error handlers. Beware that when the first message is processed then creating and starting the producer may take a little time and prolong the total processing time of the processing. | false | boolean
| *synchronous* (advanced) | Sets whether synchronous processing should be strictly used, or Camel is allowed to use asynchronous processing (if supported). | false | boolean
|===
// 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,java]
-----------------------------------------------------------------------------------------------
<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,java]
-----------------------------------------------------------------------------------------------
<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,java]
-----------------------------------------------------------------------------------------------
<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,java]
-----------------------------------------------------------------------------------------------
<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,java]
-----------------------------------------------------------------------------------------------
<route>
    <from uri="direct:destroy" />
    <setHeader name="hazelcast.operation.type">
        <constant>destroy</constant>
    </setHeader>
    <to uri="hazelcast-atomicvalue:foo" />
</route>
-----------------------------------------------------------------------------------------------

include::camel-spring-boot::page$hazelcast-starter.adoc[]
