Feign

Netflix open source statement HTTP client

Feign components

Feign.Builder: Build each FeignClient

Client: Note that feign.client. default does not use connection pooling, and LoadBalancerFeignClient is a FeignClient with load balancing function by default

Custom Feign log level

Specifies how Java configures classes

Specify the logger. Level class configured in the @FeignClient configuration property via annotations

@FeignClient(name = "userCenter", path = "user", configuration = UserCenterFeignClientConfig.class)
public interface UserCenterFeignClient {... }Copy the code

UserCenterFeignClientConfig.java

public class UserCenterFeignClientConfig {

    @Bean
    public Logger.Level level(a) {
        returnLogger.Level.FULL; }}Copy the code

Specifies how to configure properties

feign.client.config.userCenter.logger-level = full
Copy the code

Feign global configuration

  • Java code approach
  • Configuring Attribute Mode

Java code approach

@EnableFeignClients(defaultConfiguration = CustomDefaultFeignClientConfig.class)
Copy the code
public class CustomDefaultFeignClientConfig {
    @Bean
    public Logger.Level level(a) {
        returnLogger.Level.FULL; }}Copy the code

Configuring Attribute Mode

feign.client.config.default.logger-level = full
Copy the code

Supported configuration items

Java code way support

Supported by the configuration attribute mode

Ribbon configuration versus Feign configuration

Feign performance optimization

  • The connection pool
  • The level of logging

The connection pool

<dependency>
    <groupId>io.github.openfeign</groupId>
    <artifactId>feign-httpclient</artifactId>
</dependency>
Copy the code
feign.httpclient.enabled=true
Copy the code

Feign FAQ summary