最近在尝试sentinel的限流,并接入的apollo配置中心。
在编码测试过程中发现,已经能从配置中心获取到更新的配置数据。但是dashboard查询client端的限流规则时没有数据,并且限流规则也没有生效。于是debug跟了下代码发现。apollo数据变更监听拿到的数据是对的,只是在ApolloDataSource里面利用fastjson去解析成FlowRule对象的时候对象里面的resource被解析成了null。 于是对比了github的demo发现fastjson版本不一样。于是替换成同demo一样的1.2.55果然问题就没有了。暂时不清楚是否是fastjson1.2.7的bug还是sentinel自身bug。
因为公司本身项目中目前fastjson版本为1.2.7.如问题不能很好解决后期在推动sentinel应用过程中需要接入项目全部调整fastjson版本。不知道这个问题是否已经解决或者有更优处理方案。
以下是部分sentile-recode日志记录的: <2019-04-18 15:15:51 Receiving rule change (type: flow): [{"clusterConfig":{"fallbackToLocalWhenFail":true,"sampleCount":10,"strategy":0,"thresholdType":0,"windowIntervalMs":1000},"clusterMode":false,"controlBehavior":0,"count":3.0,"grade":1,"limitApp":"default","maxQueueingTimeMs":500,"resource":"/test","strategy":0,"warmUpPeriodSec":10},{"clusterConfig":{"fallbackToLocalWhenFail":true,"sampleCount":10,"strategy":0,"thresholdType":0,"windowIntervalMs":1000},"clusterMode":false,"controlBehavior":0,"count":1.0,"grade":1,"limitApp":"default","maxQueueingTimeMs":500,"resource":"/v2/user/isExisted","strategy":0,"warmUpPeriodSec":10},{"clusterConfig":{"fallbackToLocalWhenFail":true,"sampleCount":10,"strategy":0,"thresholdType":0,"windowIntervalMs":1000},"clusterMode":false,"controlBehavior":0,"count":2.0,"grade":1,"limitApp":"default","maxQueueingTimeMs":500,"resource":"/v2/user/test","strategy":0,"warmUpPeriodSec":10}] 2019-04-18 15:15:51 [DynamicSentinelProperty] Config will be updated to: [FlowRule{resource=null, limitApp=default, grade=1, count=3.0, strategy=0, refResource=null, controlBehavior=0, warmUpPeriodSec=10, maxQueueingTimeMs=500, clusterMode=false, clusterConfig=ClusterFlowConfig{flowId=null, thresholdType=0, fallbackToLocalWhenFail=true, strategy=0, sampleCount=10, windowIntervalMs=1000}, controller=null}, FlowRule{resource=null, limitApp=default, grade=1, count=1.0, strategy=0, refResource=null, controlBehavior=0, warmUpPeriodSec=10, maxQueueingTimeMs=500, clusterMode=false, clusterConfig=ClusterFlowConfig{flowId=null, thresholdType=0, fallbackToLocalWhenFail=true, strategy=0, sampleCount=10, windowIntervalMs=1000}, controller=null}, FlowRule{resource=null, limitApp=default, grade=1, count=2.0, strategy=0, refResource=null, controlBehavior=0, warmUpPeriodSec=10, maxQueueingTimeMs=500, clusterMode=false, clusterConfig=ClusterFlowConfig{flowId=null, thresholdType=0, fallbackToLocalWhenFail=true, strategy=0, sampleCount=10, windowIntervalMs=1000}, controller=null}] 2019-04-18 15:15:51 [FlowRuleManager] Ignoring invalid flow rule when loading new flow rules: FlowRule{resource=null, limitApp=default, grade=1, count=3.0, strategy=0, refResource=null, controlBehavior=0, warmUpPeriodSec=10, maxQueueingTimeMs=500, clusterMode=false, clusterConfig=ClusterFlowConfig{flowId=null, thresholdType=0, fallbackToLocalWhenFail=true, strategy=0, sampleCount=10, windowIntervalMs=1000}, controller=null} 2019-04-18 15:15:51 [FlowRuleManager] Ignoring invalid flow rule when loading new flow rules: FlowRule{resource=null, limitApp=default, grade=1, count=1.0, strategy=0, refResource=null, controlBehavior=0, warmUpPeriodSec=10, maxQueueingTimeMs=500, clusterMode=false, clusterConfig=ClusterFlowConfig{flowId=null, thresholdType=0, fallbackToLocalWhenFail=true, strategy=0, sampleCount=10, windowIntervalMs=1000}, controller=null} 2019-04-18 15:15:51 [FlowRuleManager] Ignoring invalid flow rule when loading new flow rules: FlowRule{resource=null, limitApp=default, grade=1, count=2.0, strategy=0, refResource=null, controlBehavior=0, warmUpPeriodSec=10, maxQueueingTimeMs=500, clusterMode=false, clusterConfig=ClusterFlowConfig{flowId=null, thresholdType=0, fallbackToLocalWhenFail=true, strategy=0, sampleCount=10, windowIntervalMs=1000}, controller=null}
原提问者GitHub用户haoleng
这是一个已知的问题。不推荐也不支持旧版本的fastjson。您需要将fastjson升级到最新版本。
原回答者GitHub用户sczyh30
版权声明:本文内容由阿里云实名注册用户自发贡献,版权归原作者所有,阿里云开发者社区不拥有其著作权,亦不承担相应法律责任。具体规则请查看《阿里云开发者社区用户服务协议》和《阿里云开发者社区知识产权保护指引》。如果您发现本社区中有涉嫌抄袭的内容,填写侵权投诉表单进行举报,一经查实,本社区将立刻删除涉嫌侵权内容。
阿里云拥有国内全面的云原生产品技术以及大规模的云原生应用实践,通过全面容器化、核心技术互联网化、应用 Serverless 化三大范式,助力制造业企业高效上云,实现系统稳定、应用敏捷智能。拥抱云原生,让创新无处不在。