【问题标题】:Creating default custom Hystrix Property创建默认自定义 Hystrix 属性
【发布时间】:2018-08-01 09:09:12
【问题描述】:

我是 Hystrix 的新手,我只是将它添加到我的项目中,但我想知道是否可以创建一个自定义注释“HystrixDefaultTimeoutProperty”来扩展 HystrixProperty,所​​以每次我想使用超时的默认值我可以使用该自定义注释而不是使用:

@HystrixProperty(name = "execution.isolation.thread.timeoutInMilliseconds", value = "5000")

提前致谢!

【问题讨论】:

    标签: annotations spring-cloud-netflix hystrix


    【解决方案1】:

    不,不可能,如果你要查看HystrixCommand@HystrixProperty的源代码

    @Target({ElementType.METHOD})
    @Retention(RetentionPolicy.RUNTIME)
    @Inherited
    @Documented
    public @interface HystrixCommand {
      .....
    }
    

    @Target({ElementType.METHOD})
    @Retention(RetentionPolicy.RUNTIME)
    @Documented
    public @interface HystrixProperty {
      .....
    }
    

    这两个注解都有

    @Target({ElementType.METHOD})

    这意味着您只能在方法上使用这些注释

    【讨论】:

    • 谢谢,我担心没有机会这样做
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2022-08-23
    • 1970-01-01
    • 2011-11-26
    • 1970-01-01
    • 2012-10-03
    • 1970-01-01
    相关资源
    最近更新 更多