Skip to content

Commit

Permalink
Property to tune WebClient's max buffer sized added (provectus#903)
Browse files Browse the repository at this point in the history
* webclient.max-in-memory-buffer-size property added

Co-authored-by: Ilya Kuramshin <ikuramshin@provectus.com>
  • Loading branch information
Ilya Kuramshin and Ilya Kuramshin committed Sep 25, 2021
1 parent 528bcf4 commit 47b9b69
Showing 1 changed file with 7 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,11 @@
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
Expand Down Expand Up @@ -37,7 +39,10 @@ public MBeanExporter exporter() {
}

@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();
}
}

0 comments on commit 47b9b69

Please sign in to comment.