愤怒中的小草

博客园 首页 新随笔 联系 订阅 管理

配置

#开启超时控制 打开feign-hystix
feign.hystrix.enabled=true
ribbon.ReadTimeout=60000
ribbon.ConnectTimeout=60000
#如果enabled设置为false,则请求超时交给ribbon控制
hystrix.command.default.execution.timeout.enabled=true
#设置超时时间  单位是毫秒
hystrix.command.default.execution.isolation.thread.timeoutInMilliseconds=60000  

熔断器一定要引入

<dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-actuator</artifactId>
        </dependency>

代码

@Component
public class SendInfoAuditFallBack implements SendInfoAudit {
    private Logger logger = LoggerFactory.getLogger(SendInfoAuditFallBack.class);

    @Override
    public String proclmInfo(String plyNo) {
        logger.error("请求定责系统异常:" + plyNo);
        return "error 401";
    }
}
@FeignClient(name="claimaudit",fallback = SendInfoAuditFallBack.class)
public interface SendInfoAudit {
    @RequestMapping(value = "/fixDutyServiceController/proclmInfo")
    public String proclmInfo(@RequestParam("plyNo") String plyNo);
}

 

posted on 2018-12-28 20:49  愤怒中的小草  阅读(160)  评论(0编辑  收藏  举报