0
点赞
收藏
分享

微信扫一扫

SpringCloud - Eureka & 服务提供者 & 服务消费者,心跳检测时间/缓存拉取时间配置方案



Eureka(A) & 服务提供者(B) & 服务消费者(C),三者关系是:B 和 C 都注册到 A 上,然后 C 走 feign 调用 B的情景~


名词解释

  • leaseRenewalIntervalInSeconds:心跳检测时间
  • fetch-registry:是否需要获取服务注册列表
  • registry-fetch-interval-seconds:获取服务注册列表时间

Eureka 服务端

spring:
application:
name: regist center

server:
port: 8761

eureka:
client:
register-with-eureka: false
fetch-registry: false
service-url:
defaultZone: http://localhost:8761/eureka

Eureka 客户端之服务消费者

eureka:
instance:
hostname: localhost
leaseRenewalIntervalInSeconds: 4
client:
service-url:
defaultZone: http://localhost:8761/eureka
fetch-registry: true
registry-fetch-interval-seconds: 4

Ps:leaseRenewalIntervalInSeconds、fetch-registry、registry-fetch-interval-seconds 必须要配置。

Eureka 客户端之服务提供者

eureka:
instance:
hostname: localhost
leaseRenewalIntervalInSeconds: 4
client:
service-url:
defaultZone: http://localhost:8761/eureka

Ps:只需要配置 leaseRenewalIntervalInSeconds 即可。但是在一般项目情况下,都统一配置消费者的情况,因为基本上都会互相调用!


举报

相关推荐

0 条评论