OpenFeign超时控制功能

时间:2024-6-24    作者:老大夫    分类: SpringCloud


默认等待60秒钟

在openfeign的application中配置

全局配置

server:
  port: 80

spring:
  application:
    name: cloud-consumer-openfeign-order
  ####Spring Cloud Consul for Service Discovery
  cloud:
    consul:
      host: localhost
      port: 8500
      discovery:
        prefer-ip-address: true #优先使用服务ip进行注册
        service-name: ${spring.application.name}
    openfeign:
      client:
        config:
          default:
            #连接超时时间
            connectTimeout: 3000
            #读取超时时间
            readTimeout: 3000

指定配置

指定配置会覆盖全局配置

server:
  port: 80

spring:
  application:
    name: cloud-consumer-openfeign-order
  ####Spring Cloud Consul for Service Discovery
  cloud:
    consul:
      host: localhost
      port: 8500
      discovery:
        prefer-ip-address: true #优先使用服务ip进行注册
        service-name: ${spring.application.name}
    openfeign:
      client:
        config:
          cloud-payment-service:
            #连接超时时间
            connectTimeout: 3000
            #读取超时时间
            readTimeout: 3000


扫描二维码,在手机上阅读

推荐阅读: