微服务——Sentinel限流熔断--降级

x33g5p2x  于2021-10-28 转载在 其他  
字(0.3k)|赞(0)|评价(0)|浏览(411)

降级入门

1.编辑Controller层

/*降级入门*/
    /*构建一个AtomicLong对象,提供了线程安全的自增,自减的操作*/
    private AtomicLong atomicLong=new AtomicLong(1);
    private int count;
    @GetMapping("/sentinel04")
    public String sentinel04() throws InterruptedException {
        long num=atomicLong.getAndDecrement();
        if(num%2==0){/*模拟慢调用*/
            Thread.sleep(200);
        }
        return "sentinel 04 text";
    }

相关文章

微信公众号

最新文章

更多