Property to tune WebClient's max buffer sized added (#903)

* webclient.max-in-memory-buffer-size property added

Co-authored-by: Ilya Kuramshin <ikuramshin@provectus.com>
This commit is contained in:
Ilya Kuramshin 2021-09-25 14:39:14 +03:00 committed by GitHub
parent 928dbd7a77
commit 0bf8db5e52
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -6,9 +6,11 @@ import javax.management.remote.JMXConnector;
import org.apache.commons.pool2.KeyedObjectPool;
import org.apache.commons.pool2.impl.GenericKeyedObjectPool;
import org.apache.commons.pool2.impl.GenericKeyedObjectPoolConfig;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.jmx.export.MBeanExporter;
import org.springframework.util.unit.DataSize;
import org.springframework.web.reactive.function.client.WebClient;
@Configuration
@ -37,7 +39,10 @@ public class Config {
}
@Bean
public WebClient webClient() {
return WebClient.create();
public WebClient webClient(
@Value("${webclient.max-in-memory-buffer-size:20MB}") DataSize maxBuffSize) {
return WebClient.builder()
.codecs(c -> c.defaultCodecs().maxInMemorySize((int) maxBuffSize.toBytes()))
.build();
}
}