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熔断


  • 相关阅读:
    DM7 安装
    LeetCode 第 183 场周赛
    MySQL 源码中的 ut_a 、 ut_ad
    存储领域的会议和研究机构
    LeetCode 第 15 场双周赛
    LeetCode 第 167 场周赛
    值得推荐的C/C++框架和库
    InnoDB 中的锁实现
    LeetCode-第 166 场周赛
    LeetCode 第 165 场周赛
  • 原文地址:https://www.cnblogs.com/draymond/p/12782730.html
Copyright © 2011-2022 走看看