Skip to content

Commit 5d62b32

Browse files
committed
Spring Cloud Alibaba基础教程:Sentinel Dashboard同步Apollo存储规则
1 parent a6c7745 commit 5d62b32

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

4-Finchley/alibaba-sentinel-dashboard-apollo/src/main/java/com/alibaba/csp/sentinel/dashboard/rule/apollo/FlowRuleApolloPublisher.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,18 @@ public void publish(String app, List<FlowRuleEntity> rules) throws Exception {
5252
return;
5353
}
5454

55+
// TODO 处理不兼容的字段,spring cloud alibaba 0.2.2版本中实现JSON转换的时候,不会忽略不存在的字段,会导致客户端出现出现异常
56+
// 可以通过下面这段代码将这些字段不存入Apollo,以避免客户端加载的错误
57+
for (FlowRuleEntity ruleEntity : rules) {
58+
ruleEntity.setId(null);
59+
ruleEntity.setApp(null);
60+
ruleEntity.setGmtModified(null);
61+
ruleEntity.setGmtCreate(null);
62+
ruleEntity.setIp(null);
63+
ruleEntity.setPort(null);
64+
}
65+
// 请视情况使用
66+
5567
OpenItemDTO openItemDTO = new OpenItemDTO();
5668
openItemDTO.setKey(flowDataId);
5769
openItemDTO.setValue(converter.convert(rules));

0 commit comments

Comments
 (0)