Question/Enhancement: Is there any way to have a Per-Request Timeout for a Feign Client?
My current workaround is to create two API Clients, with a different Configuration:
@FeignClient(
name = "slow-api-calls",
configuration = [SlowCallsClientConfig::class]
)
class SlowCallsClientConfig {
@Bean
fun options() = Request.Options(5000, 5000)
}
If there is no better solution, what would a good implementation look like?
-
org.springframework.cloud.openfeign.support.SpringMvcContract is using "@RequestMapping", which is the same Annotation for Controller (request-handling classes) mappings. To add Client-Timeouts there would be misplaced.
-
I could also add a custom
AnnotatedParameterProcessorwhich processes a custom Annotation like@RequesTimeout, but that's feels like another workaround. -
https://github.com/OpenFeign/feign/issues/562 will introduce a new
@ApiTimeoutannoation, which could be picked up bySpringMvcContract
Comment From: ryanjbaxter
I would say option 3 is the best IMO.
Comment From: matt62king
OpenFeign supports adding Request.Options as a method parameter.
https://github.com/OpenFeign/feign/pull/970
Comment From: rowi1de
Thanks @matt62king https://github.com/OpenFeign/feign/pull/970