如何使码头Hazelcast中的会话无效?

时间:2018-11-29 08:26:58

标签: session jetty apache-zookeeper hazelcast embedded-jetty

我正在Jetty 9.4.8中使用hazelcast 3.6.3进行会话复制,我们希望基于单独的JMS消息使多个会话无效。

hazelcast配置为(使用Zookeeper进行对等发现)

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);

我从事的工作

Session session = sessionHandler.getSession(id);
session.invalidate(); // or sessionHandler.invalidate(id)

,但这不会使所有实例上的会话无效。为什么会这样?

我们需要在所有实例上使会话无效吗?

0 个答案:

没有答案