Book Image

Learning Karaf Cellar

By : Jean Baptiste Onofre, Jean-Baptiste Onofré
Book Image

Learning Karaf Cellar

By: Jean Baptiste Onofre, Jean-Baptiste Onofré

Overview of this book

Table of Contents (16 chapters)

Caching with a distributed map


Another use case for Cellar and camel-hazelcast together is the implementation of a distributed cache solution.

The camel-hazelcast component allows you to use a distributed map and execute different operations on this map.

As it's distributed, it means that the data is spread between different nodes: all nodes can see the same data (entries/values) from the distributed map. This means that you can share data between nodes.

In a Camel route, you can perform the following operations on the distributed map:

  • put: To add new data in the map

  • delete: To remove data from the map

  • get: To retrieve all data from the map

  • query: To retrieve particular data from the map

The operation type is defined in the CamelHazelcastOperationType header.

For instance, we can implement a route that updates the cache with the following code:

<route>
  <from uri="direct-vm:add-in-cache"/>
  <setHeader headerName="CamelHazelcastOperationType">
    <constant>put</constant...