zoukankan      html  css  js  c++  java
  • 在线教育项目-day10【整合熔断器】

    1添加依赖

            <!--hystrix依赖,主要是用  @HystrixCommand -->
            <dependency>
                <groupId>org.springframework.cloud</groupId>
                <artifactId>spring-cloud-starter-netflix-hystrix</artifactId>
            </dependency>

    2.添加hystrix配置

    #开启熔断机制
    feign.hystrix.enabled=true
    
    # 设置hystrix超时时间,默认1000ms
    hystrix.command.default.execution.isolation.thread.timeoutInMilliseconds=6000

    3.创建一个实现类如果出错执行对应的方法

    @Component
    public class VodFileDegradeFeignClient implements VodClient{
        
        @Override
        public R deleteAlyiVideo(String videoId) {
            return R.Error().message("删除视频出错了");
        }
    
        @Override
        public R delete_bantch(List<String> videolist) {
            return R.Error().message("删除多个视频出错了");
        }
    }

    4.更改注解

    @FeignClient(name="service-vod",fallback =VodFileDegradeFeignClient.class)
    @Component
    public interface VodClient {
        //定义调用方法的路径
        @DeleteMapping("/eduvod/video/deleteAlyiVideo/{videoId}")
        public R deleteAlyiVideo(@PathVariable("videoId") String videoId);
    
        //定义调用删除多个视频方法的路径
        //删除多个视频
        @DeleteMapping("/eduvod/video/delete-bantch")
        public R delete_bantch(List<String> videolist);
    }
  • 相关阅读:
    关于Jquery内存的释放
    jQuery 事件 mouseleave() 方法 mouseenter() 方法
    模版方法模式
    js中return的用法
    HTTP返回码中301与302的区别
    DS介绍
    Java MySql乱码解决
    [IOS] UIViewController的parentViewController属性
    LinuxFind命令
    Linux第一课
  • 原文地址:https://www.cnblogs.com/dmzna/p/12844526.html
Copyright © 2011-2022 走看看