我正在尝试使用Camel蓝图实现Hazelcast缓存。但是我无法完成,我能够通过Java代码(而不是通过hazelcast XML配置文件)创建hazelcast实例。已创建实例,但是在实例创建期间未调用缓存加载器类(即使初始化方法为EAGER)。附加了一些代码片段。
让我知道,如果有人遇到这个问题。
代码:
Hazelcast配置
public class ConfigHack extends Config {
public ConfigHack(String instanceName ){
super(instanceName);
System.out.println("Going to create Hazelcast instance
................"+instanceName);
TcpIpConfig tcpIpConfig = new TcpIpConfig();
List membersList = new ArrayList<String>();
membersList.add("localhost");
tcpIpConfig.setMembers(membersList);
MulticastConfig multicastConfig = new MulticastConfig();
multicastConfig.setEnabled(true);
JoinConfig join = new JoinConfig();
join.setTcpIpConfig(tcpIpConfig);
join.setMulticastConfig(multicastConfig);
NetworkConfig networkConfig = new NetworkConfig();
networkConfig.setPort(5701);
networkConfig.setPortAutoIncrement(true);
networkConfig.setJoin(join);
GroupConfig groupConfig = new GroupConfig();
groupConfig.setName("devuser");
groupConfig.setPassword("devpassword");
MapStoreConfig mapStoreConfig = new MapStoreConfig();
//Absolute path in class name field below
mapStoreConfig.setClassName("VehicleCacheLoader");
mapStoreConfig.setImplementation(new VehicleCacheLoader());
mapStoreConfig.setEnabled(true);
mapStoreConfig.setInitialLoadMode(InitialLoadMode.EAGER);
mapStoreConfig.setWriteDelaySeconds(500);
MapConfig mapConfig = new MapConfig();
mapConfig.setName("vehicleMap");
mapConfig.setBackupCount(2);
mapConfig.setMaxIdleSeconds(1000000);
mapConfig.setEvictionPercentage(30);
mapConfig.setEvictionPolicy(EvictionPolicy.LFU);
mapConfig.setMapStoreConfig(mapStoreConfig);
Map<String,MapConfig> mapConfigs = new HashMap<String,MapConfig>();
mapConfigs.put("vehicleMap", mapConfig);
//config.setMapConfigs(mapConfigs);
addMapConfig(mapConfig);
setGroupConfig(groupConfig);
setNetworkConfig(networkConfig);
}
}
元芳怎么了
相关分类