Spring Cloud: Feign and Http Connection Pooling

Viewed 7473

Can anyone please tell me if the Spring Cloud Feign Client provides or supports Http Connection Pooling, and if so how to configure settings like pool size? I can't seem to find this in the official documentation. Thank you.

2 Answers

This is an example.

@Bean
public ServiceXFeignClient serviceXClient(Encoder encoder, Decoder decoder,
  Contract contract, ClientProperties properties, ProxyProperties proxyProperties) {

  OkHttpClient.Builder okHttpClient = new OkHttpClient.Builder()
    .connectionPool(
      new ConnectionPool(properties.getPoolConnectionMaxIdle(),
      properties.getPoolConnectionKeepMinutesAlive(), TimeUnit.MINUTES))
    .build();

  return Feign.builder()
        .client(new feign.okhttp.OkHttpClient(okHttpClient))
    .encoder(encoder)
    .decoder(decoder)
    .contract(contract)
    .target(ServiceXFeignClient.class, properties.getUrl());
}

Related