简体   繁体   English

Pivotal GemFire多会话的春季会议

[英]Spring Session for Pivotal GemFire Multi-Session

We are trying for a solution of non-sticky session for a retailer across servers. 我们正在尝试为零售商提供跨服务器的非粘性会话解决方案。 Servers used are WebLogic 12.2.1.3 and TomcatEE 7.0.5. 使用的服务器是WebLogic 12.2.1.3和TomcatEE 7.0.5。 We are able to see sessions persisting across servers. 我们能够看到会话在服务器之间持续存在。

httpServletRequest.getSession() is at times trying to retrieve the session from the container rather than GemFire. httpServletRequest.getSession()有时试图从容器而不是GemFire检索会话。

Also the session id we see in client cookie and server logs are different from what is being seen inside GemFire. 同样,我们在客户端Cookie和服务器日志中看到的会话ID与在GemFire内部看到的会话ID不同。 Is this expected? 这是预期的吗?

EDIT: The session id created inside GemFire is base64 encoded on the client browser. 编辑:在GemFire内部创建的会话ID在客户端浏览器上是base64编码的。 This would answer the above question. 这将回答上述问题。

Be sure that you have "enabled" Spring Session for Pivotal GemFire in all the (Spring Boot) application instances you have deployed across both WebLogic and TomcatEE. 确保已在跨WebLogic和TomcatEE部署的所有(Spring Boot)应用程序实例中为“ Pivotal GemFire ”启用了Spring Session This is as simple as the following: 这很简单,如下所示:

@SpringBootApplication
@EnableGemFireHttpSession
class MySpringBootWebApplication {

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

    ...
}

@EnableGemFireHttpSession is key. @EnableGemFireHttpSession是关键。 Also make sure the app instances deployed in each WebLogic and TomcatEE are sharing the same Region in the backend Pivotal GemFire cluster, assuming there is a single GemFire cluster serving apps in both WebLogic and TomcatEE. 还要确保部署在每个WebLogic和TomcatEE中的应用程序实例在后端Pivotal GemFire群集中共享相同的Region(假设在WebLogic和TomcatEE中都有一个为应用程序提供服务的GemFire群集)。

For instance, if you explicitly set the Region, using: 例如,如果您使用以下命令显式设置“区域”:

@EnableGemFireHttpSession(regionName = "MySessionRegion")

Make sure all app instances use the same Region name (ie "MySessionRegion"). 确保所有应用程序实例使用相同的区域名称(即“ MySessionRegion”)。 Alternatively, as of SSDG 2.0.5.RELEASE the Region name can be configured using a property in Spring Boot's application.properties file: 另外,从SSDG 2.0.5.RELEASE ,可以使用Spring Boot的application.properties文件中的属性来配置Region名称:

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

Also, make sure all apps are configured to talk to the same GemFire cluster. 另外,请确保所有应用程序都配置为与同一个GemFire集群通信。 This depends on the Pool that the Spring Session Region uses to talk to the GemFire cluster. 这取决于Spring Session Region用来与GemFire集群通信的Pool The Pool name is configurable with the annotation, like so: 池名称可以使用注释进行配置,如下所示:

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

Then, you must configure the Pool for all app instances to connect to the same GemFire cluster, ideally with Locators, like so: 然后,您必须为所有应用程序实例配置“池”以连接到同一个GemFire集群,最好使用定位器,如下所示:

@Configuration class MyGemFireConfiguration { @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;
}

...

} }

Alternatively, you can configure the "DEFAULT" GemFire Pool, assuming the configured client PROXY Region storing Session state uses the "DEFAULT" Pool, which it will when no Pool is explicitly configured/named. 另外,您可以配置“ DEFAULT” GemFire池,假设已配置的存储会话状态的客户端PROXY区域使用“ DEFAULT”池,当没有显式配置/命名池时,它将使用“ DEFAULT”池。 For example . 例如

The last thing to be mindful of is if you are using the GemFire WAN topology, with multiple sites where each site is serving a particular collection of apps segregated by app server, perhaps (ie WebLogic vs. TomcatEE). 最后要注意的是,如果您使用的是GemFire WAN拓扑,其中有多个站点,每个站点都服务于由应用程序服务器隔离的特定应用程序集合(例如,WebLogic与TomcatEE)。 Then you must ensure that you have configured GemFire WAN appropriate to coordinate across your multiple GemFire clusters. 然后,您必须确保已配置适当的GemFire WAN,以跨多个GemFire群集进行协调。 This is beyond the scope of this answer and so I will encourage you to look at this . 这超出了此答案的范围,因此,我鼓励您研究此问题

Feel free to share any sample code, configuration and/or tests you have that might shed light on the problems you are experiencing. 随意分享您可能会发现的所有示例代码,配置和/或测试。

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

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