Java Code Examples for com.hazelcast.core.IMap#addEntryListener()
The following examples show how to use
com.hazelcast.core.IMap#addEntryListener() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: HazelcastEventStore.java From Moss with Apache License 2.0 | 6 votes |
public HazelcastEventStore(int maxLogSizePerAggregate, IMap<InstanceId, List<InstanceEvent>> eventLog) { super(maxLogSizePerAggregate, eventLog); eventLog.addEntryListener((MapListener) new EntryAdapter<InstanceId, List<InstanceEvent>>() { @Override public void entryUpdated(EntryEvent<InstanceId, List<InstanceEvent>> event) { log.debug("Updated {}", event); long lastKnownVersion = getLastVersion(event.getOldValue()); List<InstanceEvent> newEvents = event.getValue() .stream() .filter(e -> e.getVersion() > lastKnownVersion) .collect(Collectors.toList()); HazelcastEventStore.this.publish(newEvents); } }, true); }
Example 2
Source File: ListenerDemo.java From hazelcast-demo with Apache License 2.0 | 6 votes |
public static void main(String[] args) { HazelcastInstance ins = Hazelcast.newHazelcastInstance(); IMap<Integer, String> map = ins.getMap(""); map.addEntryListener(new ListenerExample(), true);//添加自定义监听器 map.put(1, "Grand Theft Auto"); map.put(1, "Final Fantasy"); map.put(2, "World Of Warcraft"); HazelcastInstance insex = Hazelcast.newHazelcastInstance(); IMap<Integer, String> mapex = insex.getMap(""); System.out.println(mapex.get(1)); System.out.println(mapex.get(2)); mapex.remove(1); mapex.remove(2); System.exit(0); }
Example 3
Source File: SubscriptionMain.java From chuidiang-ejemplos with GNU Lesser General Public License v3.0 | 5 votes |
public static void main(String[] args){ Config config = new Config(); GlobalSerializerConfig globalConfig = new GlobalSerializerConfig(); globalConfig.setOverrideJavaSerialization(true).setImplementation(new DataSerializer()); config.getSerializationConfig().setGlobalSerializerConfig(globalConfig); HazelcastInstance instance = Hazelcast.newHazelcastInstance(config); IMap<String, String> aMap = instance.getMap("aMap"); aMap.addEntryListener(new MyListener(), true); aMap.put("key", "value"); aMap.put("key", "Another value"); aMap.remove("key"); aMap.put("other key", "other value"); aMap.clear(); IMap<String, Data> otherMap = instance.getMap("otherMap"); otherMap.addEntryListener(new MyListener(), true); otherMap.put("key", new Data()); Data data = otherMap.get("key"); data.date=new Date(); data.value=1000; otherMap.put("key",data); instance.shutdown(); }
Example 4
Source File: HazelcastEventStore.java From spring-boot-admin with Apache License 2.0 | 5 votes |
public HazelcastEventStore(int maxLogSizePerAggregate, IMap<InstanceId, List<InstanceEvent>> eventLog) { super(maxLogSizePerAggregate, eventLog); eventLog.addEntryListener((MapListener) new EntryAdapter<InstanceId, List<InstanceEvent>>() { @Override public void entryUpdated(EntryEvent<InstanceId, List<InstanceEvent>> event) { log.debug("Updated {}", event); long lastKnownVersion = getLastVersion(event.getOldValue()); List<InstanceEvent> newEvents = event.getValue().stream() .filter((e) -> e.getVersion() > lastKnownVersion).collect(Collectors.toList()); HazelcastEventStore.this.publish(newEvents); } }, true); }