【发布时间】:2016-10-17 09:23:19
【问题描述】:
地图的hazelcast配置是
<map name="test">
<max-idle-seconds>120</max-idle-seconds>
<entry-listeners>
<entry-listener include-value="true" local="false">com.test.listener.SessionListener</entry-listener>
</entry-listeners>
</map>
我为驱逐操作配置了一个监听器。 Listener 无法始终如一地捕捉到 evict 动作。 Hazelcast 版本:3.6.5
监听类实现:
public class SessionListener implements EntryListener<String, Object> {
@Override
public void entryEvicted(EntryEvent<String, Object> evictData) {
try {
Session sessionObjValue = (Session) evictData.getOldValue();
String sessionId = sessionObjValue.getSessionId();
String userName = sessionObjValue.getUsername();
JSONObject inputJSON = new JSONObject();
inputJSON.put(Constants.SESSIONID, sessionId);
inputJSON.put(Constants.USER_NAME, userName);
//Operations to be performed based on the JSON Value
} catch (Exception exception) {
LOGGER.logDebug(Constants.ERROR, methodName, exception.toString());
}
}
【问题讨论】:
-
能贴出
com.test.listener.SessionListener类的实现吗? -
在问题中添加了侦听器类实现。谢谢。