zoukankan      html  css  js  c++  java
  • feign

        feign

    l  整合ribbon和hystrix

    l  声明式客户端

    n  只需要定义一个远程调用接口,不需要写远程调用代码

    1  声明式客户端

    声明远程调用接口,不用写远程调用的代码

    @FeignClient(name="service-id")
    
    interface A {
    
       @GetMapping("/{orderId}")
    
       void a(@PathVariable String orderId);
    
    }
    
     

    2  feign+ribbon

    不用配置,默认启动负载均衡和重试

    重试参数的默认值:

    ConnectTimeout: 1000
    
    ReadTimeout: 1000
    
    MaxAutoRetries: 0
    
    MaxAutoRetriesNextServer: 1
    
     

    3  feign+hystrix

    降级

    启用hystrix: feign.hystrix.enabled=true

    实现远程调用接口,在子类中添加降级代码

    @Component
    
    class AFb implements A {
    
       public void a() {
    
          降级代码
    
        }
    
    }
    
     
    
    @FeignClient(name="...", fallback=AFb.class)
    
    interface A {
    
    }
    
     

    熔断

    l  hystrix的完整依赖

    l  actuator依赖

    l  @EnableCircuitBreaker

    l  暴露 hystrix.stream 监控端点

    4  feign 整合ribbon+hystrix

    项目中,不会单独使用ribbon和hystrix,都是用 Feign

    Feign用来在服务之间互相调用

      turbine

    聚合监控

    从多台服务器获取监控数据,把数据聚合后,交给仪表盘展示

    turbine:
    
      app-config: feign, order-service
    
     

    turbine不使用actuator暴露监控端点,它自己暴露的监控端点是 /turbine.stream

  • 相关阅读:
    积分图像
    [悟] 因上努力,果上随缘(转)
    不要走的太匆忙( 转)
    一个程序员如何快速赚到一百万?(转)
    vi文字处理器
    Linux常用命令
    Hadoop之MapReduce
    Hadoop全分布模式操作
    Hadoop之HDFS
    Hadoop生态系统
  • 原文地址:https://www.cnblogs.com/B1ackWall/p/11611016.html
Copyright © 2011-2022 走看看