Hazelcast Tutorial- Understanding Replicated Maps using example
A replicated map is a weakly consistent, distributed key-value data structure provided by Hazelcast.
All other data structures are partitioned in design.
A replicated map does not partition data (it does not spread data to different cluster members);
instead, it replicates the data to all nodes.

This leads to higher memory consumption. However, a replicated map has faster read and write access since the data are available on all nodes and writes take place on local nodes, eventually being replicated to all other nodes. Weak consistency compared to eventually consistency means that replication is done on a best efforts basis. Lost or missing updates are neither tracked nor resent.
This kind of data structure is suitable for immutable objects, catalogue data, or idempotent calculable data (like HTML pages). Used in cases of immutable slow movin data like config. ReplicatedMap interface supports EntryListeners.
Replicated map nearly fully implements the java.util.Map interface, but it lacks the methods from java.util.concurrent.ConcurrentMap since there are no atomic guarantees to writes or reads.

This leads to higher memory consumption. However, a replicated map has faster read and write access since the data are available on all nodes and writes take place on local nodes, eventually being replicated to all other nodes. Weak consistency compared to eventually consistency means that replication is done on a best efforts basis. Lost or missing updates are neither tracked nor resent.
This kind of data structure is suitable for immutable objects, catalogue data, or idempotent calculable data (like HTML pages). Used in cases of immutable slow movin data like config. ReplicatedMap interface supports EntryListeners.
Replicated map nearly fully implements the java.util.Map interface, but it lacks the methods from java.util.concurrent.ConcurrentMap since there are no atomic guarantees to writes or reads.
package com.javainuse.main;
import java.util.Map;
import com.hazelcast.core.Hazelcast;
import com.hazelcast.core.HazelcastInstance;
public class FirstMapExample {
public static void main(String[] args) {
HazelcastInstance hz = Hazelcast.newHazelcastInstance();
Map<String, String> employees = hz.getReplicatedMap("employees");
employees.put("1", "emp1");
employees.put("2", "emp2");
employees.put("3", "emp3");
employees.put("4", "emp4");
employees.put("5", "emp5");
System.out.println("Total number of employees " + employees.size());
}
}
Download Source Code
Download it - Hazelcast Collections- Map, Set and QueueSee Also
Hazelcast Hello World Example- Getting started with Hazelcast. Hazelcast Tutorial- Working with Hazelcast collections- Distributed Map,List,Set,Queues. Hazelcast - Main Menu
Popular Posts
1Z0-830 Java SE 21 Developer Certification
Azure AI Foundry Hello World
Azure AI Agent Hello World
Foundry vs Hub Projects
Build Agents with SDK
Bing Web Search Agent
Function Calling Agent
Spring Boot + Azure Key Vault Hello World Example
Spring Boot + Elasticsearch + Azure Key Vault Example
Spring Boot Azure AD (Entra ID) OAuth 2.0 Authentication
Deploy Spring Boot App to Azure App Service
Secure Azure App Service using Azure API Management
Deploy Spring Boot JAR to Azure App Service
Deploy Spring Boot + MySQL to Azure App Service
Spring Boot + Azure Managed Identity Example
Secure Spring Boot Azure Web App with Managed Identity + App Registration
Elasticsearch 8 Security - Integrate Azure AD OIDC