如何配置HystrixFeign客户端?

时间:2016-05-18 01:21:32

标签: hystrix netflix-feign spring-cloud-feign

我有一个Spring Boot应用程序,但我无法利用@EnableFeignClient,因为不支持multipart。 (见Can I generate a Spring Feign client with Multipart parameters?)。

我正在使用构建器创建自己的HystrixFeign客户端:

Request.Options options = new Options(connectTimeout, readTimeout);
MyClient client = HystrixFeign.builder()
             .client( new OkHttpClient() )
             .encoder(new FeignSpringFormEncoder())
             .decoder(new JacksonDecoder())
             .logger(new Slf4jLogger())
             .logLevel(Logger.Level.HEADERS)
             .options(options)
             .target(MyClient.class, vbApiUrl, fallback); 

如何配置Hystrix的其他属性?我想设置执行隔离策略,断路器睡眠窗口,音量阈值,错误阈值百分比?

将它们包含在我的application.properties文件中是否足够?如何验证这些属性是否适用于" uploadMedia"端点?

hystrix.command.uploadMedia.execution.isolation.strategy=THREAD  hystrix.command.uploadMedia.execution.isolation.thread.timeoutInMilliseconds=10000
hystrix.command.uploadMedia.execution.timeout.enabled=false
hystrix.command.uploadMedia.execution.isolation.thread.interruptOnTimeout=false
hystrix.command.uploadMedia.fallback.enabled=true
hystrix.command.uploadMedia.circuitBreaker.sleepWindowInMilliseconds=5000
hystrix.command.uploadMedia.circuitBreaker.requestVolumeThreshold=20
hystrix.command.uploadMedia.circuitBreaker.errorThresholdPercentage=50

0 个答案:

没有答案