通知
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 for Apache Geode (SSDG) 使用 Apache Geode 管理用户的会话信息,提供核心 Spring Session 框架的实现。
会话状态通过利用 Apache Geode 的 Spring Data 存储在 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 集群之间发送的内容(例如增量)。
-
强大的发布/订阅机制 - 允许您使用查询谓词注册兴趣或表达对会话更改的兴趣,以接收更新通知。
将 Spring Session for Apache Geode 添加到您的构建中
Apache Geode 的 Spring Session 是 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'
}