通知
2022年底,VMware宣布Spring for VMware GemFire项目正式发布。
虽然这些基于 Spring 的 VMware GemFire 项目是开源的,是 Spring for Apache Geode 项目的继承,但它们并不是替代品。VMware GemFire 从 Apache Geode 项目分支而来,不是开源的。
不建议开始使用Spring for Apache Geode的新项目,而是从这里开始,转向Spring for VMware GemFire。另外,Spring 产品组合提供了与其他同等会话缓存提供商的一流集成。另外,请看这里。
最后,请记住,Spring for Apache Geode 项目会维护到开源软件和商业支持结束。维护仅包括CVE和关键修复。不会有新功能或增强。Apache Geode 春季会议支持时间线可在此查看。
概述
Apache Geode 的 Spring Session (SSDG) 提供了核心 Spring Session 框架的实现,利用 Apache Geode 管理用户的会话信息。
会话状态通过利用 Spring Data for Apache Geode 存储在 Apache Geode 中。通过与 Apache Geode 集成,你可以在 Spring Boot 应用中掌握这项技术的全部功能(强一致性、低延迟、高可用性、弹性等等)。
在Pivotal CloudFoundry中部署和运行Spring Boot应用时,也可以使用SSDG,使用基于Apache Geode的Pivotal Cloud Cache。
特征
Apache Geode春季会话(SSDG)提供以下功能:
-
HTTP 和 WebSocket 会话状态管理,使用 Apache Geode 作为后端。
-
集群与分布式会话管理——提升系统架构的可用性和弹性。
-
强一致性——Apache Geode 实现了强一致性保证,类似于数据库。
-
自定义过期策略——例如,支持固定会话超时。
-
自定义数据序列化——启用(HTTP)会话状态,除了通过Java序列化外,使得你放入会话中的应用类无需实现。java.io.Serializable
-
自定义变更检测——你可以决定会话是否脏,以及在Spring Boot应用和Apache Geode集群之间以客户端/服务器拓扑方式发送什么(例如差异)。
-
强大的发布/订阅机制——允许你基于查询谓词注册兴趣或表达对会话变更的兴趣,以接收更新通知。
在你的构建中添加Apache Geode的春季会话
Apache Geode 的春季会议是 Maven 物料清单(BOM)的一部分,用于协调核心春季会议项目与该 Apache Geode 扩展之间的版本。每个BOM发布称为释放列车,并有命名策略,例如:, , 。Apple-SR9Bean-SR12Corn-SR6Dragonfruit-SR32020.0.72021.0.42021.1.12021.2.0-M12022.0.0-M1
使用 Maven 的 BOM
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.session</groupId>
<artifactId>spring-session-bom</artifactId>
<version>2021.1.1</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
然后,你可以将BOM作为依赖添加到你的Spring Boot应用程序Maven POM文件中:
<dependencies>
<dependency>
<groupId>org.springframework.session</groupId>
<artifactId>spring-session-data-geode</artifactId>
</dependency>
</dependencies>
使用 Gradle 的 BOM
由于Gradle对Maven BOM没有一流的支持,你可以使用Spring的依赖管理插件。
应用Gradle插件门户中的插件(如有需要,更新版本):
plugins {
id 'io.spring.dependency-management' version '1.0.11.RELEASE'
}
然后用它导入物料清单:
dependencyManagement {
imports {
mavenBom 'org.springframework.session:spring-session-bom:2021.1.1'
}
}
最后,在项目中添加一个无版本的依赖:
dependencies {
compile 'org.springframework.session:spring-session-data-geode'
}