Search code examples
annotationsspring-cloud-netflixhystrix

Creating default custom Hystrix Property


I'm new on Hystrix, I'm just adding it to my project, but I'd like to know whether I can create a custom annotation "HystrixDefaultTimeoutProperty" that extends the HystrixProperty, so each time I want to use a default value for the timeout I can use that custom annotation instead of using:

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

Thanks in advance!


Solution

  • No, it is not possible, If you were to look at the source code of HystrixCommand and @HystrixProperty

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

    and

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

    Both of these annotations has

    @Target({ElementType.METHOD})

    which implies you can use these annotations only on Methods