把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 120 分享 版权
1 条回答
写回答
取消 提交回答
  • 规则配的有问题,配置 QPS 模式(阈值类型)应该用 setGrade;setStrategy 用于设置流控方式(调用关系限流)。

    原回答者GitHub用户sczyh30

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