= Atomix Map Component
:doctitle: Atomix Map
:shortname: atomix-map
:artifactid: camel-atomix
:description: Access Atomix's distributed map.
:since: 2.20
:supportlevel: Stable
:component-header: Both producer and consumer are supported
//Manually maintained attributes
:camel-spring-boot-name: atomix

*Since Camel {since}*

*{component-header}*

The camel Atomix-Map component allows you to work with http://atomix.io[Atomix's] https://atomix.io/docs/latest/user-manual/primitives/DistributedMap/[Distributed Map] collection.

Maven users will need to add the following dependency to their pom.xml for this component:

[source,xml]
----
    <dependency>
        <groupId>org.apache.camel</groupId>
        <artifactId>camel-atomix</artifactId>
        <version>${camel-version}</version>
    </dependency>
----

== URI format

----
atomix-map:mapName
----

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


== Headers

[width="100%",cols="10%,10%,20%a,60%",options="header",]
|===
| Name
| Type
| Values
| Description

| CamelAtomixResourceAction
| AtomixMap.Action
| * PUT
  * PUT_IF_ABSENT
  * GET
  * CLEAR
  * SIZE
  * CONTAINS_KEY
  * CONTAINS_VALUE
  * IS_EMPTY
  * ENTRY_SET
  * REMOVE
  * REPLACE
  * VALUES
| The action to perform

| CamelAtomixResourceKey
| Object
| -
| The key to operate on

| CamelAtomixResourceValue
| Object
| -
| The value, if missing In Body is used

| CamelAtomixResourceOldValue
| Object
| -
| The old value

| CamelAtomixResourceTTL
| String / long
| -
| The entry TTL

| CamelAtomixResourceReadConsistency
| ReadConsistency
| * ATOMIC
  * ATOMIC_LEASE
  * SEQUENTIAL
  * LOCAL
| The read consistency level

|===

== Configuring the component to connect to an Atomix cluster

The nodes of the Atomix cluster you want to join can be se at Endpoint or component level (recommended), below some examples:

* *Endpoint:*
+
[source,xml]
----
<beans xmlns="...">
    <camelContext xmlns="http://camel.apache.org/schema/spring">
        <route>
          <from uri="direct:start"/>
          <to uri="atomix-map:myMap?nodes=node-1.atomix.cluster:8700,node-2.atomix.cluster:8700"/>
        </route>
    </camelContext>
</beans>
----

* *Component:*
+
[source,xml]
----
<beans xmlns="...">
    <bean id="atomix-map" class="org.apache.camel.component.atomix.client.map.AtomixMapComponent">
        <property name="nodes" value="nodes=node-1.atomix.cluster:8700,node-2.atomix.cluster:8700"/>
    </bean>

    <camelContext xmlns="http://camel.apache.org/schema/spring">
        <route>
            <from uri="direct:start"/>
            <to uri="atomix-map:myMap"/>
        </route>
    </camelContext>
</beans>
----

== Examples

=== Consumer Example

Consuming from an Atomix Map

[source,java]
----
fromF("atomix-map:map")
  .to("mock:result");
----

=== Producer Example

PUT an element with TTL of 1 second:

[source,java]
----
FluentProducerTemplate.on(context)
    .withHeader(AtomixClientConstants.RESOURCE_ACTION, AtomixMap.Action.PUT)
    .withHeader(AtomixClientConstants.RESOURCE_KEY, key)
    .withHeader(AtomixClientConstants.RESOURCE_TTL, "1s")
    .withBody(val)
    .to("atomix-map:map")
    .send();
----


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