I am creating a REST client using Feign. My calls are working for me, but I want to add some timeout support, and I have time to figure out how to do this.
The Feign documentation says: "To use Hystrix with Feign, add the Hystrix module to your class path, and then use the HystrixFeign builder." So now I have this:
service = HystrixFeign.builder() .decoder(new GsonDecoder()) .target(ProjectService.class, URL_TO_BE_MOVED_TO_PROPS);
Now all my methods return HystrixCommands, which I can execute or queue, but I still donβt see how to configure them.
The Hystrix wiki ( https://github.com/Netflix/Hystrix/wiki/Configuration ) says that the configuration should be added to the HystrixCommand constructor as follows:
public HystrixCommandInstance(int id) { super(Setter.withGroupKey(HystrixCommandGroupKey.Factory.asKey("ExampleGroup")) .andCommandPropertiesDefaults(HystrixCommandProperties.Setter() .withExecutionTimeoutInMilliseconds(500))); this.id = id;
But my commands are built / returned using Feign, so I don't have access to the constructors.
Another thing worth noting is that in the Feign-Hystrix read mode ( https://github.com/Netflix/feign/tree/master/hystrix ) it says: "To use Hystrix with Feign, add the Hystrix module for your class path. Then configure the Use function to use the HystrixInvocationHandler, but a google search for the HystrixInvocationHandler points me to a non-Netflix repo. Even if I used this, I donβt see how to configure Feign to use it.
Please tell me that I am stupid and that it is very simple, which will make me feel joy that I passed this problem, and a shame that I could not figure it out myself.
TL DR: I want to set timeouts for requests made by my Feign client. How to make?