I am using hazelcast 3.6.3 in jetty 9.4.8 for session replication and we would like to invalidate multiple sessions based on a separate JMS message.
the hazelcast config is (using zookeeper for peer discovery)
Config config = new Config();
config.setInstanceName(HAZELCAST_INSTANCE_NAME);
// logger config
config.setProperty("hazelcast.logging.type", "slf4j");
// config for session map
MapConfig sessionMapConfig = new MapConfig();
sessionMapConfig.setName(SESSION_MAP_NAME)
.setBackupCount(2);
config.addMapConfig(sessionMapConfig);
// peer discovery with zookeeper
config.getNetworkConfig().getJoin().getMulticastConfig().setEnabled(false);
config.setProperty(GroupProperty.DISCOVERY_SPI_ENABLED, "true");
DiscoveryStrategyConfig discoveryStrategyConfig = new DiscoveryStrategyConfig(new ZookeeperDiscoveryStrategyFactory());
discoveryStrategyConfig.addProperty(ZookeeperDiscoveryProperties.ZOOKEEPER_URL.key(), serviceDiscoveryNode);
discoveryStrategyConfig.addProperty(ZookeeperDiscoveryProperties.ZOOKEEPER_PATH.key(), "sessionstore/APP");
discoveryStrategyConfig.addProperty(ZookeeperDiscoveryProperties.GROUP.key(), "cluster-name");
config.getNetworkConfig().getJoin().getDiscoveryConfig().addDiscoveryStrategyConfig(discoveryStrategyConfig);
in a job I called
Session session = sessionHandler.getSession(id);
session.invalidate(); // or sessionHandler.invalidate(id)
but this does not invalidate the session on all instances. Why is that ?
do we need to invalidate session on all instances?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…