通知
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 项目将一直维护到 OSS 和商业支持结束。维护仅包括 CVE 和关键修复。不会进行任何新功能或增强。可以在此处查看 Apache Geode 支持时间表的 Spring Session。
概述
Spring Session for Apache Geode (SSDG) 提供了使用 Apache Geode 来管理用户会话信息的核心 Spring Session 框架的实现。
会话状态通过利用 Spring Data for Apache Geode 存储在 Apache Geode 中。通过与 Apache Geode 集成,您可以在 Spring Boot 应用程序中轻松获得该技术的全部功能(强一致性、低延迟、高可用性、弹性等)。
在 Pivotal CloudFoundry 中部署和运行 Spring Boot 应用程序时,甚至可以使用 SSDG,使用 Pivotal Cloud Cache,它本身基于 Apache Geode。
特征
Spring Session for Apache Geode (SSDG) 提供以下功能:
-
使用 Apache Geode 作为后端的 HTTP 和 WebSocket 会话状态管理。
-
集群和分布式会话管理 - 提高系统架构的可用性和弹性。
-
强一致性 - Apache Geode 实现了强一致性保证,就像数据库一样。
-
自定义过期策略 - 例如,支持固定会话超时。
-
自定义数据序列化 - 启用 (HTTP) 会话状态,而不是通过 Java 序列化进行序列化,以便您放入会话中的应用程序类不需要实现 。java.io.Serializable
-
自定义更改检测 - 您可以决定会话是否脏,以及在客户端/服务器拓扑中的 Spring Boot 应用程序和 Apache Geode 集群之间发送的内容(例如增量)。
-
强大的 Pub/Sub 机制 - 允许您使用查询谓词注册对会话更改的兴趣或表达兴趣,以接收更新通知。
将 Spring Session for Apache Geode 添加到您的构建中
Spring Session for Apache Geode 是 Maven BOM(物料清单)的一部分,用于协调核心 Spring Session 项目和此 Apache Geode 扩展之间的版本。每个 BOM 版本称为发布列车,并具有命名策略,例如:、 和 。Apple-SR9
Bean-SR12
Corn-SR6
Dragonfruit-SR3
2020.0.7
2021.0.4
2021.1.1
2021.2.0-M1
2022.0.0-M1
将 BOM 与 Maven 结合使用
<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>
将 BOM 与 Gradle 结合使用
由于 Gradle 没有对 Maven BOM 的一流支持,因此您可以使用 Spring 的依赖管理插件。
从 Gradle 插件门户应用插件(根据需要更新版本):
plugins {
id 'io.spring.dependency-management' version '1.0.11.RELEASE'
}
然后使用它导入 BOM:
dependencyManagement {
imports {
mavenBom 'org.springframework.session:spring-session-bom:2021.1.1'
}
}
最后,向没有版本的项目添加依赖项:
dependencies {
compile 'org.springframework.session:spring-session-data-geode'
}