3

According to the documentation, when using Feign with Hystrix every request is wrap into a Hystrix command.

Is it possible to set Hystrix Properties to these commands? I'd like to do something like this:

@RequestMapping(commandProperties = {
    @HystrixProperty(name = "execution.isolation.thread.timeoutInMilliseconds", value = "30000")})
List<Team> findAll();

or:

@FeignClient(name = "teams", commandProperties = {
    @HystrixProperty(name = "execution.isolation.thread.timeoutInMilliseconds", value = "30000")})

For the records, I've already tried to use properties but it didn't work. These ones are working:

hystrix.command.default.execution.isolation.thread.timeoutInMilliseconds=10000
hystrix.command.findAll.execution.timeout.enabled=false
hystrix.command.default.execution.timeout.enabled=false

But this one does not:

hystri‌​x.command.findAll.ex‌​ecution.isolation.thread.timeoutInMillis‌​econds=20000

Indeed, we can read the following comment into the HystrixCommandProperties class:

    //this property name is now misleading.  //TODO figure out a good way to deprecate this property name
    this.executionTimeoutInMilliseconds = getProperty(propertyPrefix, key, "execution.isolation.thread.timeoutInMilliseconds", builder.getExecutionIsolationThreadTimeoutInMilliseconds(), default_executionTimeoutInMilliseconds);

EDIT: I have tried to use the feign' Request.Option but these properties doesn't seem to propagate to hystrix.

4

2 回答 2

1

问题已解决:这是一个编码问题。我从文档中复制/粘贴了一行,但它不是 UTF-8 编码的(尽管 STS 的显示是正确的)。

于 2016-09-23T13:37:03.453 回答
0

您还可以像下面这样以编程方式设置属性。

ConfigurationManager.getConfigInstance()
        .setProperty("hystri‌​x.command.default.ex‌​ecution.isolation.th‌​read.timeoutInMillis‌​econds", 1500);
于 2016-09-26T14:45:03.007 回答