Search code examples
hazelcastdistributed-cachinghazelcast-imap

Sharing hazelcast cache between multiple application and using write behind and read through


Question - Can I share the same hazelcast cluster (cache) between the multiple application while using the write behind and read through functionality using map store and map loaders

Details

  • I have enterprise environment have the multiple application and want to use the single cache
  • I have multiple application(microservices) ie. APP_A, APP_B and APP_C independent of each other.
  • I am running once instance of each application and each node will be the member node of the cluster.
  • APP_A has MAP_A, APP_B has MAP_B and APP_C has MAP_C. Each application has MapStore for their respective maps.
  • If a client sends a command instance.getMap("MAP_A").put("Key","Value") . This has some inconsistent behavior. Some time I see data is persistent in database but some times not.

Note - I wan to use the same hazelcast instance across all application, so that app A and access data from app B and vice versa.

I am assuming this is due to the node who handles the request. If request is handle by node A then it will work fine, but fails if request is handled by node B or C. I am assuming this is due to Mapstore_A implementation is not available with node B and C.

Am I doing something wrong? Is there something we can do to overcome this issue?

Thanks in advance.


Solution

  • Hazelcast is a clustered solution. If you have multiple nodes in the cluster, the data in each may get moved from place to place when data rebalancing occurs.

    As a consequence of this, map store and map loader operations can occur from any node.

    So all nodes in the cluster need the same ability to connect to the database.