领先一步
VMware 提供培训和认证,助您加速进步。
了解更多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 和关键修复。不会添加新功能或增强功能。Spring Session for Apache Geode 的支持时间表可以在此处查看。
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 集群之间发送什么(例如,增量)。
强大的发布/订阅机制 - 允许您注册兴趣或使用查询谓词表达对会话变更的兴趣,以接收更新通知。
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。
<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 不直接支持 Maven BOM,您可以使用 Spring 的 Dependency Management Plugin。
从 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'
}
如果您正在使用 Spring Boot,特别是 Spring Boot for Apache Geode (SBDG),您可以在您的 Spring Boot 应用程序 Maven POM 文件中包含 Spring Session for Apache Geode (SSDG) 的 starter。
例如
<dependencies>
<dependency>
<groupId>org.springframework.geode</groupId>
<artifactId>spring-geode-starter-session</artifactId>
<version>1.6.3.RELEASE</version>
</dependency>
</dependencies>
有关更多详细信息,请参阅 SBDG 版本兼容性矩阵。