feat(openFeign): SentinelResource注解使用

This commit is contained in:
Bunny 2025-02-09 21:47:12 +08:00
parent 79dc92805a
commit 2dfe3cbac2
1 changed files with 8 additions and 1 deletions

View File

@ -28,13 +28,20 @@ public class PropertiesController {
@SentinelResource(value = "getConfig", fallback = "getConfigFallBack") @SentinelResource(value = "getConfig", fallback = "getConfigFallBack")
@Operation(summary = "获取云端配置属性", description = "获取云端配置属性") @Operation(summary = "获取云端配置属性", description = "获取云端配置属性")
public String getConfig() { public String getConfig() {
// 也可以使用try进行捕获和处理
// try {
// SphU.entry("zzz");
// } catch (BlockException e) {
// throw new RuntimeException(e);
// }
return "timeout" + orderProperties.getTimeout() + "autoConfirm" + orderProperties.getConfirm() + "dbUrl" + orderProperties.getDbUrl(); return "timeout" + orderProperties.getTimeout() + "autoConfirm" + orderProperties.getConfirm() + "dbUrl" + orderProperties.getDbUrl();
} }
/** /**
* 当获取速度过快时会走这个 * 当获取速度过快时会走这个
* Throwable 好处还可以处理业务错误也可以走这个
*/ */
public String getConfigFallBack() { public String getConfigFallBack(Throwable throwable) {
return "获取云端配置属性,操作过快。。。"; return "获取云端配置属性,操作过快。。。";
} }