com.netflix.hystrix.exception.HystrixRuntimeException微服务之间第一次调用hystrix超时问题

1.背景

微服务开发,使用Eureka做服务注册中心,Zuul做网关。A服务模块去调用B服务的方法,第一次调用会出现超时问题,报错如下:

com.netflix.hystrix.exception.HystrixRuntimeException: OrderService#plcaceOrders(String) failed and no fallback available.

Caused by:

Caused by: feign.FeignException: status 500 reading OrderService#plcaceOrders(String); content:
{"timestamp":1562332250241,"status":500,"error":"Internal Server Error","exception":"com.netflix.zuul.exception.ZuulException","message":"TIMEOUT"}

一看这个报错原因就知道是服务超时了,因此解决方案就是增加响应时间,让B在足够的时间内完成任务并返回给A。

2.解决方案

Zuul网关的配置文件application.yml中增加如下配置:

#防止服务超时,此处设置为6秒,时长自定义
hystrix:
  command:
    default:
      execution:
        isolation:
          thread:
            timeoutInMilliseconds: 6000
        timeout:
          enabled: false

3.下面的不用看

具体报错信息:

com.netflix.hystrix.exception.HystrixRuntimeException: OrderService#plcaceOrders(String) failed and no fallback available.
	at com.netflix.hystrix.AbstractCommand$22.call(AbstractCommand.java:805)
	at com
  • 2
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值