繁体   English   中英

Pivotal GemFire多会话的春季会议

[英]Spring Session for Pivotal GemFire Multi-Session

我们正在尝试为零售商提供跨服务器的非粘性会话解决方案。 使用的服务器是WebLogic 12.2.1.3和TomcatEE 7.0.5。 我们能够看到会话在服务器之间持续存在。

httpServletRequest.getSession()有时试图从容器而不是GemFire检索会话。

同样,我们在客户端Cookie和服务器日志中看到的会话ID与在GemFire内部看到的会话ID不同。 这是预期的吗?

编辑:在GemFire内部创建的会话ID在客户端浏览器上是base64编码的。 这将回答上述问题。

确保已在跨WebLogic和TomcatEE部署的所有(Spring Boot)应用程序实例中为“ Pivotal GemFire ”启用了Spring Session 这很简单,如下所示:

@SpringBootApplication
@EnableGemFireHttpSession
class MySpringBootWebApplication {

    public static void main(String[] args) {
        SpringApplication.run(MySpringBootApplication.class, args);
    }

    ...
}

@EnableGemFireHttpSession是关键。 还要确保部署在每个WebLogic和TomcatEE中的应用程序实例在后端Pivotal GemFire群集中共享相同的Region(假设在WebLogic和TomcatEE中都有一个为应用程序提供服务的GemFire群集)。

例如,如果您使用以下命令显式设置“区域”:

@EnableGemFireHttpSession(regionName = "MySessionRegion")

确保所有应用程序实例使用相同的区域名称(即“ MySessionRegion”)。 另外,从SSDG 2.0.5.RELEASE ,可以使用Spring Boot的application.properties文件中的属性来配置Region名称:

spring.session.data.gemfire.session.region.name=MySessionRegion

另外,请确保所有应用程序都配置为与同一个GemFire集群通信。 这取决于Spring Session Region用来与GemFire集群通信的Pool 池名称可以使用注释进行配置,如下所示:

@EnableGemFireHttpSession(..., poolName = "SessionPool")

然后,您必须为所有应用程序实例配置“池”以连接到同一个GemFire集群,最好使用定位器,如下所示:

@Configuration类MyGemFireConfiguration {

@Bean("SessionPool")
PoolFactoryBean sessionPool() {

    PoolFactoryBean sessionPool = new PoolFactoryBean();

    sessionPool.setName("SessionPool");
    sessionPool.setLocators(Arrays.asList(new ConnectionEndpoint("host1", port1),
        new ConnectionEndpoint("host2", port2),
        ...,
        new ConnectionEndpoint("hostN", portN));

    return sessionPool;
}

...

}

另外,您可以配置“ DEFAULT” GemFire池,假设已配置的存储会话状态的客户端PROXY区域使用“ DEFAULT”池,当没有显式配置/命名池时,它将使用“ DEFAULT”池。 例如

最后要注意的是,如果您使用的是GemFire WAN拓扑,其中有多个站点,每个站点都服务于由应用程序服务器隔离的特定应用程序集合(例如,WebLogic与TomcatEE)。 然后,您必须确保已配置适当的GemFire WAN,以跨多个GemFire群集进行协调。 这超出了此答案的范围,因此,我鼓励您研究此问题

随意分享您可能会发现的所有示例代码,配置和/或测试。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM