Stack Overflow
stackoverflow.com › questions › 60003370 › context-id-is-not-available-for-feignclients-annotation
java - context id is not available for @FeignClients Annotation - Stack Overflow
@FeignClient(name = "ABC") I want to insert contextId like below · @FeignClient(contextId = "dummy", name = "ABC") But in I am not getting able to get ContextId in suggestions it shows me compile time Error · How can I resolve this error? java · spring-boot ·
Getdocs
spring.getdocs.org › en-US › spring-cloud-docs › spring-cloud-openfeign › spring-cloud-feign › spring-cloud-feign-overriding-defaults.html
Untitled :: Spring Docs
If we want to create multiple feign clients with the same name or url so that they would point to the same server but each with a different custom configuration then we have to use contextId attribute of the @FeignClient in order to avoid name collision of these configuration beans.
Spring Cloud
cloud.spring.io › spring-cloud-openfeign › 2.1.x › multi › multi_spring-cloud-feign.html
1. Declarative REST Client: Feign - Spring Cloud Project
If we want to create multiple feign clients with the same name or url so that they would point to the same server but each with a different custom configuration then we have to use contextId attribute of the @FeignClient in order to avoid name collision of these configuration beans.
Spring
docs.spring.io › spring-cloud-openfeign › docs › current › reference › html
Spring Cloud OpenFeign
If we want to create multiple feign clients with the same name or url so that they would point to the same server but each with a different custom configuration then we have to use contextId attribute of the @FeignClient in order to avoid name collision of these configuration beans.
GitHub
github.com › spring-cloud › spring-cloud-openfeign › issues › 781
FeignClient contextId can not be resolved from config file · Issue #781 · spring-cloud/spring-cloud-openfeign
November 4, 2022 - FeignClient contextId can not be resolved from config file#781 · Copy link · dongyinuo · opened · on Nov 4, 2022 · Issue body actions · in spring-cloud-starter-openfeign v2.2.1.RELEASE, it works good, when i upgrade the starter to v2.2.9.RELEASE. it can't work, this is error: when i diff v2.2.1.RELEASE and v2.2.9.RELEASE, i find the changes, and, the latest tag and main branch are the same ·
Author: spring-cloud
Spring
docs.spring.io › spring-cloud-openfeign › reference › spring-cloud-openfeign.html
Spring Cloud OpenFeign Features :: Spring Cloud Openfeign
If we want to create multiple Feign clients with the same name or url so that they would point to the same server but each with a different custom configuration then we have to use contextId attribute of the @FeignClient in order to avoid name collision of these configuration beans.
Stack Overflow
stackoverflow.com › questions › 78838391 › how-to-auto-generate-feign-client-in-java-kotlin-based-on-api-interface
spring - How to auto generate Feign client in java\kotlin based on api interface? - Stack Overflow
And Feign client · @FeignClient( contextId = "resourceClient", name = "service" ) interface ResourceClient : ResourceApi · Share · Improve this answer · Follow · answered Aug 8, 2024 at 15:09 · HolyDrug · 1111 silver badge44 bronze badges ...
Spring Cloud
cloud.spring.io › spring-cloud-openfeign › multi › multi_spring-cloud-feign.html
1. Declarative REST Client: Feign
If we want to create multiple feign clients with the same name or url so that they would point to the same server but each with a different custom configuration then we have to use contextId attribute of the @FeignClient in order to avoid name collision of these configuration beans.
Spring-doc
spring-doc.cn › spring-cloud-openfeign › 3.1.9 › index.en.html
1. Declarative REST Client: Feign (1. Declarative REST Client: Feign) | Spring Cloud OpenFeign3.1.9中文文档|Spring官方文档|SpringBoot 教程|Spring中文网
Spring Cloud creates a new ensemble ... an feign.Decoder, a feign.Encoder, and a feign.Contract. It is possible to override the name of that ensemble by using the contextId attribute of the @FeignClient annotation.spring-doc.cn ·...
Top answer 1 of 2
3
As you have seen in the documentation, you can set timeouts per specific client. But you have only configured it for feign client, not for hystrix command. Remember that they have independent timeouts.
I would recommend to use a configuration class instead of editing your application.yml in order to handle multiples feign clients with hystrix. The following example sets up a Feign.Builder where timeouts are being injected for Feign client and Hystrix command.
# application.yml
microservices:
foo:
feign:
url: xxxx
connect-timeout: 5s
read-timeout: 5s
hystrix:
enabled: true
timeout: 5s
@FeignClient(name = "foo",
url = "${microservice.foo.feign.url}",
configuration = FooFeignConfiguration.class)
public interface FooFeignRepository {
}
@Configuration
@RequiredArgsConstructor
public class FooFeignConfiguration {
@Value("${microservice.foo.hystrix.enabled:true}")
private final Boolean hystrixEnabled;
@DurationUnit(value = ChronoUnit.MILLIS)
@Value("${microservice.foo.feign.connect-timeout:5000}")
private final Duration feignConnectTimeout;
@DurationUnit(value = ChronoUnit.MILLIS)
@Value("${microservice.foo.feign.read-timeout:5000}")
private final Duration feignReadTimeout;
@DurationUnit(value = ChronoUnit.MILLIS)
@Value("${microservice.foo.hystrix.timeout:5000}")
private final Duration hystrixTimeout;
@Bean
@Scope("prototype")
public Feign.Builder feignBuilder() {
return (hystrixEnabled ?
HystrixFeign.builder()
.options(new Request.Options(
(int) feignConnectTimeout.toMillis(),
(int) feignReadTimeout.toMillis()))
.setterFactory((target, method) -> {
return new SetterFactory.Default()
.create(target, method)
.andCommandPropertiesDefaults(HystrixCommandProperties.Setter()
.withExecutionTimeoutInMilliseconds((int) hystrixTimeout.toMillis()));
}):
Feign.builder())
.retryer(Retryer.NEVER_RETRY);
}
}
2 of 2
0
This config works for me.
Feign client:
@FeignClient(name="test", value = "test", url = "https://api.test.com")
public interface TestClient {
@GetMapping("/test")
ResponseEntity<Test> getProducts();
}
application.yml:
spring:
cloud:
openfeign:
client:
config:
default:
connectTimeout: 20000
readTimeout: 60000
test:
connectTimeout: 2000
readTimeout: 3000
pom.xml:
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>3.2.1</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-openfeign</artifactId>
<version>4.1.1</version>
</dependency>
</dependencies>
Stack Overflow
stackoverflow.com › questions › 75421919 › how-to-specify-ribbon-configuration-for-a-specific-feign-client-in-a-spring-boot
How to specify Ribbon Configuration for a specific Feign client in a Spring Boot project having multiple Feign clients? - Stack Overflow
@FeignClient(contextId = "fooClient", name = "stores", configuration = FooConfiguration.class) https://cloud.spring.io/spring-cloud-netflix/multi/multi_spring-cloud-feign.html · Share · Improve this answer · Follow · answered Mar 14, 2023 at 22:29 · smile · 51699 silver badges1919 bronze badges ·