nacos收到的流控规则如下:
[{"app":"service-consumer","clusterConfig":{"fallbackToLocalWhenFail":true,"sampleCount":10,"strategy":0,"thresholdType":0,"windowIntervalMs":1000},"clusterMode":false,"controlBehavior":0,"count":1.0,"gmtCreate":1573130440602,"gmtModified":1573130440602,"grade":1,"id":1,"ip":"172.18.54.192","limitApp":"default","port":8720,"resource":"/hello","strategy":0}]
服务启动异常,规则无法生效:
java.lang.RuntimeException: convert error: convert 0 rules but there are 1 rules from datasource. RuleClass: FlowRule at org.springframework.cloud.alibaba.sentinel.datasource.converter.SentinelConverter.convert(SentinelConverter.java:84) ~[spring-cloud-alibaba-sentinel-datasource-0.9.0.RELEASE.jar:0.9.0.RELEASE] at org.springframework.cloud.alibaba.sentinel.datasource.converter.SentinelConverter.convert(SentinelConverter.java:37) ~[spring-cloud-alibaba-sentinel-datasource-0.9.0.RELEASE.jar:0.9.0.RELEASE] at com.alibaba.csp.sentinel.datasource.AbstractDataSource.loadConfig(AbstractDataSource.java:48) ~[sentinel-datasource-extension-1.6.3.jar:na] at com.alibaba.csp.sentinel.datasource.AbstractDataSource.loadConfig(AbstractDataSource.java:44) ~[sentinel-datasource-extension-1.6.3.jar:na] at org.springframework.cloud.alibaba.sentinel.custom.SentinelDataSourceHandler.logAndCheckRuleType(SentinelDataSourceHandler.java:195) [spring-cloud-alibaba-sentinel-0.9.0.RELEASE.jar:0.9.0.RELEASE] at org.springframework.cloud.alibaba.sentinel.custom.SentinelDataSourceHandler.registerBean(SentinelDataSourceHandler.java:184) [spring-cloud-alibaba-sentinel-0.9.0.RELEASE.jar:0.9.0.RELEASE] at org.springframework.cloud.alibaba.sentinel.custom.SentinelDataSourceHandler.lambda$afterSingletonsInstantiated$0(SentinelDataSourceHandler.java:72) [spring-cloud-alibaba-sentinel-0.9.0.RELEASE.jar:0.9.0.RELEASE] at java.util.TreeMap.forEach(TreeMap.java:1005) ~[na:1.8.0_111] at org.springframework.cloud.alibaba.sentinel.custom.SentinelDataSourceHandler.afterSingletonsInstantiated(SentinelDataSourceHandler.java:60) [spring-cloud-alibaba-sentinel-0.9.0.RELEASE.jar:0.9.0.RELEASE] at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:864) ~[spring-beans-5.1.10.RELEASE.jar:5.1.10.RELEASE] at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:877) ~[spring-context-5.1.10.RELEASE.jar:5.1.10.RELEASE] at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:549) ~[spring-context-5.1.10.RELEASE.jar:5.1.10.RELEASE] at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:141) ~[spring-boot-2.1.9.RELEASE.jar:2.1.9.RELEASE] at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:744) ~[spring-boot-2.1.9.RELEASE.jar:2.1.9.RELEASE] at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:391) ~[spring-boot-2.1.9.RELEASE.jar:2.1.9.RELEASE] at org.springframework.boot.SpringApplication.run(SpringApplication.java:312) ~[spring-boot-2.1.9.RELEASE.jar:2.1.9.RELEASE] at org.springframework.boot.SpringApplication.run(SpringApplication.java:1215) ~[spring-boot-2.1.9.RELEASE.jar:2.1.9.RELEASE] at org.springframework.boot.SpringApplication.run(SpringApplication.java:1204) ~[spring-boot-2.1.9.RELEASE.jar:2.1.9.RELEASE] at com.example.demo.DemoApplication.main(DemoApplication.java:15) ~[classes/:na] Caused by: java.lang.IllegalArgumentException: convert 0 rules but there are 1 rules from datasource. RuleClass: FlowRule at org.springframework.cloud.alibaba.sentinel.datasource.converter.SentinelConverter.convert(SentinelConverter.java:80) ~[spring-cloud-alibaba-sentinel-datasource-0.9.0.RELEASE.jar:0.9.0.RELEASE] ... 18 common frames omitted
尝试将服务组件都升级到最新版本也无法解决问题
通过sentinel源码手动编写json属性过滤器 可以临时解决问题
原提问者GitHub用户liupanjjjj
2.1.0.版本可以解决这个问题。
https://github.com/alibaba/spring-cloud-alibaba/issues/569
原回答者GitHub用户fangjian0423
版权声明:本文内容由阿里云实名注册用户自发贡献,版权归原作者所有,阿里云开发者社区不拥有其著作权,亦不承担相应法律责任。具体规则请查看《阿里云开发者社区用户服务协议》和《阿里云开发者社区知识产权保护指引》。如果您发现本社区中有涉嫌抄袭的内容,填写侵权投诉表单进行举报,一经查实,本社区将立刻删除涉嫌侵权内容。
阿里云拥有国内全面的云原生产品技术以及大规模的云原生应用实践,通过全面容器化、核心技术互联网化、应用 Serverless 化三大范式,助力制造业企业高效上云,实现系统稳定、应用敏捷智能。拥抱云原生,让创新无处不在。