什么是 Spring Cloud Alibaba?
Aliware

新版本预览
Aliware
Nacos:升级 Nacos 客户端到 1.4.2 版本,修复了 Nacos 1.4.1 所存在的相关问题,支持了 Nacos 服务发现失败容错等相关能力。 RocketMQ:升级到了 4.9.2,并将之前项目中的 RocketMQ 单独分支融入到了项目主分支,跟随大版本一起发布迭代,使用户可在最新 Spring Cloud Alibaba 中直接使用 RocketMQ 新支持的批量消息、异步消息回调处理、Push 模式下指定消费起始位等众多新特性。 Sentinel:升级到了 1.8.3,除了修复部分之前版本所存在的问题外,还提供了丰富的针对 FeignClient 的容错能力,支持针对全局 FeignClient 配置默认熔断规则,支持对单个 FeignClient 配置特定容错规则以及支持针对单个方法配置熔断规则等能力。 Spring Boot:在Spring Boot 2.6.3 版本基础上,支持了 spring.config.import 的应用配置方式,方便用户更友好地在应用中配置和使用 Nacos 配置中心。
升级指导
Aliware
版本号
升级操作
<dependencyManagement>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-dependencies</artifactId>
<version>2.6.3</version>
<type>pom</type>
<scope>import</scope>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-dependencies</artifactId>
<version>2021.0.1</version>
<type>pom</type>
<scope>import</scope>
</dependency>
<dependency>
<groupId>com.alibaba.cloud</groupId>
<artifactId>spring-cloud-alibaba-dependencies</artifactId>
<version>2021.0.1.0</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencyManagement>
新特性以及使用方式
1、支持 spring.config.import
# bootstrap.yml
spring:
cloud:
nacos:
config:
name: test.yml
group: DEFAULT_GROUP
server-addr: 127.0.0.1:8848
extension-configs:
- dataId: test01.yml
group: group_01
- dataId: test02.yml
group: group_02
refresh: false
# application.yml
spring:
cloud:
nacos:
config:
group: DEFAULT_GROUP
server-addr: 127.0.0.1:8848
config:
import:
- optional:nacos:test.yml # 监听 DEFAULT_GROUP:test.yml
- optional:nacos:test01.yml?group=group_01 # 覆盖默认 group,监听 group_01:test01.yml
- optional:nacos:test02.yml?group=group_02&refreshEnabled=false # 不开启动态刷新
- nacos:test03.yml # 在拉取nacos配置异常时会快速失败,会导致 spring 容器启动失败
如果使用 spring.config.import 就不能使用 bootstrap.yml/properties 引入配置的方式了 !!! 如果引入了 spring-cloud-starter-alibaba-nacos-config,并且使用 import 方式导入配置, 项目启动时会自动检测是否引入了 nacos: 条目,如果没有 import nacos 条目,会出现如下错误:
The spring.config.import property is missing a nacos: entry
Action:
Add a spring.config.import=nacos: property to your configuration.
If configuration is not required add spring.config.import=optional:nacos: instead.
To disable this check, set spring.cloud.nacos.config.import-check.enabled=false.
假如想保留以前的使用方式 (bootstrap引入配置),你只需要添加依赖 spring-cloud-starter-bootstrap 依赖,不需要修改一行代码
2、Nacos 容错能力
3、支持 FeignClient 灵活的熔断配置
<dependency>
<groupId>com.alibaba.cloud</groupId>
<artifactId>spring-cloud-circuitbreaker-sentinel</artifactId>
</dependency>
@FeignClient(value = "user", fallback = UserFallback.class)
public interface UserClient {
@GetMapping("/{success}")
String success(@PathVariable Boolean success);
}
@FeignClient(value = "order", fallback = OrderFallback.class)
public interface OrderClient {
@GetMapping("/{success}")
String success(@PathVariable Boolean success);
@GetMapping("/{success}")
String error(@PathVariable Boolean success);
}
想要对全局的 FeignClient 配置一个默认熔断规则。 想要对 user FeignClient 配置熔断规则。
想要对 order FeignClient 的指定方法(error)配置熔断规则。
feign:
circuitbreaker:
enabled: true
sentinel:
default-rule: default # 全局规则名称
rules:
# 全局配置,这些参数的意思请查看 com.alibaba.csp.sentinel.slots.block.degrade.DegradeRule
# 可配置多条规则
default:
- grade: 2
count: 1
timeWindow: 1
statIntervalMs: 1000
minRequestAmount: 5
- grade: 2
count: 1
# 针对 user FeignClient
user:
- grade: 2
count: 1
timeWindow: 1
statIntervalMs: 1000
minRequestAmount: 5
# 针对 order FeignClient error 方法,注意中括号,不然会解析出来的值会不一致
"[order#error(Boolean)]":
- grade: 2
count: 1
timeWindow: 1
statIntervalMs: 1000
minRequestAmount: 5
4、升级建议
在 spring boot 2.6 之后默认开启了禁止循环引入,建议大家不要关闭,这是一种不好的编码习惯,如果你的项目里出现了循环引用,请选择重构它。 抛弃 bootstrap 引入配置的方式,使用 spring.config.import 方式引入配置,spring boot 2.4 对这一块做了很大的优化工作,不再需要全量启动一个容器来刷新配置。
回顾展望
Aliware


社区建设
Aliware
开发角色
Spring Cloud Alibaba 项目开发者包含 Steering Committee Member、Committer、Contributor 三种角色,每种角色的标准定义如下。
1、Steering Committee Member
完成多个关键模块或者工程的设计与开发,是项目的核心开发人员; 持续的投入和激情,能够积极参与社区、官网、issue、PR 等项目相关事项的维护;
在社区中具有有目共睹的影响力,能够代表 Spring Cloud Alibaba 参加重要的社区会议和活动; 具有培养 Committer 和 Contributor 的意识和能力;
2、Committer
能够在长时间内做持续贡献 issue、PR 的个人; 参与 issue 列表的维护及重要 feature 的讨论;
参与 code review;
3、Contributor
提交过 PR 并被合并;
开发团队
Steering Committee Member 成员:
Committer 成员:
双周会
新 Committer 介绍

Spring Cloud Alibaba 企业版
Aliware
相关链接
文章转载自阿里巴巴中间件,如果涉嫌侵权,请发送邮件至:contact@modb.pro进行举报,并提供相关证据,一经查实,墨天轮将立刻删除相关内容。