开发者社区 > 云原生 > 正文

把DemoController修改了 很奇怪 这个service.test不是 已经用了注解了吗 为

@RestController public class DemoController {

@Autowired private TestService service;

private static CountDownLatch countDownLatch = new CountDownLatch(500);

private static volatile boolean flag = false;

@GetMapping("/foo") public String foo() throws Exception { FlowRule flowRule = new FlowRule(); flowRule.setResource("test"); flowRule.setCount(1); flowRule.setStrategy(RuleConstant.FLOW_GRADE_QPS); ArrayList list = new ArrayList<>(1); list.add(flowRule); FlowRuleManager.loadRules(list); for (int i = 0; i < 500 ; i++) { new Thread(new Runnable() { @Override public void run() { countDownLatch.countDown(); while (flag) { service.test(); } } }).start(); } countDownLatch.await(); flag = true; return service.hello(System.currentTimeMillis());

} }

奇怪 我把你们DemoController修改了 很奇怪 这个service.test()不是 已经用了注解了吗 为什么规则没有生效.

原提问者GitHub用户huihui1112

展开
收起
码字王 2023-05-19 19:15:24 100 0
1 条回答
写回答
取消 提交回答
  • 规则配的有问题,配置 QPS 模式(阈值类型)应该用 setGrade;setStrategy 用于设置流控方式(调用关系限流)。

    原回答者GitHub用户sczyh30

    2023-05-19 22:46:00
    赞同 展开评论 打赏
问答地址:

阿里云拥有国内全面的云原生产品技术以及大规模的云原生应用实践,通过全面容器化、核心技术互联网化、应用 Serverless 化三大范式,助力制造业企业高效上云,实现系统稳定、应用敏捷智能。拥抱云原生,让创新无处不在。

相关电子书

更多
低代码开发师(初级)实战教程 立即下载
冬季实战营第三期:MySQL数据库进阶实战 立即下载
阿里巴巴DevOps 最佳实践手册 立即下载