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


  • 相关阅读:
    UVA 12657 Boxes in a Line 双向链表模拟
    C语言单片和C#语言服务器端DES及3DES加密的实现
    关于TcpClient,Socket连接超时的几种处理方法
    拿来参考的学习计划
    faire la course
    今日法语2
    炸鱼
    今日法语
    今日疑问
    下周想做的菜
  • 原文地址:https://www.cnblogs.com/draymond/p/12782730.html
Copyright © 2011-2022 走看看