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

posted @ 2019-09-30 09:28  B1ack_Wall  阅读(191)  评论(0编辑  收藏  举报