Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
296 views
in Technique[技术] by (71.8m points)

how to invalidate sessions in jetty Hazelcast?

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

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...