zoukankan      html  css  js  c++  java
  • Hystrix 服务熔断

    1:方法的熔断

        /**
         * 服务熔断
         *
         * @return
         */
        @HystrixCommand(fallbackMethod = "numLessZeroException", commandProperties = {                  //ctrl+shift+A 查询HystrixCommandProperties
                @HystrixProperty(name = "circuitBreaker.enabled", value = "true"),                      //是否开启断路器
                @HystrixProperty(name = "circuitBreaker.requestVolumeThreshold", value = "10"),         //请求次数
                @HystrixProperty(name = "circuitBreaker.sleepWindowInMilliseconds", value = "10000"),   //时间窗口期
                @HystrixProperty(name = "circuitBreaker.errorThresholdPercentage", value = "60")        //失败率达到多少后跳闸
        })
        public String paymentInfo_service_fusing(Integer id) {
            if (id == null || id < 0) {
                throw new RuntimeException("id 不能小于0");
            }
            return Thread.currentThread().getName() + "	" + "调用成功,流水号:" + id;
        }

    2:注解

    @EnableEurekaClient
    @SpringBootApplication
    @EnableCircuitBreaker   //启动hystrix熔断
    @EnableHystrixDashboard //开启图形化界面
    public class HystrixPaytment8001 {
    
        public static void main(String[] args) {
            SpringApplication.run(HystrixPaytment8001.class);
        }
    }
    @EnableCircuitBreaker   //启动hystrix熔断


  • 相关阅读:
    系统集群安装
    用ASP.net判断上传文件类型的三种方法
    C#中利用JQuery实现视频网站
    云计算和大数据
    c# Dictionary 中Keys.ToArray<>方法的细节测试
    DateTime compare
    Dictionary的遍历和修改
    C# 键值对数据排序
    ant使用小结
    给我们的7句话
  • 原文地址:https://www.cnblogs.com/draymond/p/12782730.html
Copyright © 2011-2022 走看看