配置
#开启超时控制 打开feign-hystix
feign.hystrix.enabled=true
ribbon.ReadTimeout=
ribbon.ConnectTimeout=
#如果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);
}