[英]Pivotal GemFire 9.3.0: Spring Data GemFire XML config in GemFire cluster
[英]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.