WebClient maxConnection池限制? [英] WebClient maxConnection pool limit?

查看:957
本文介绍了WebClient maxConnection池限制?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果远程服务被阻止,我可以发送多少个并发请求? 意思是:使用WebClient时,spring在内部使用的 maxConnection 池限制是什么?

How many concurrent requests can I send if the remote service if blocking? Means: what is the maxConnection pool limit that spring uses internally when using WebClient?

@Autowired
private WebClient webClient;

webClient.post().uri(url).syncBody(req).retrieve().bodyToMono(type);

而且:如何修改它?

推荐答案

在Reactor-netty 0.9.0.M4版本之前,由于使用了弹性"连接提供程序,因此默认情况下没有限制. 此修补程序将其更改为固定"连接提供程序,限制为500.

Before reactor-netty 0.9.0.M4 version there wasn't limit by default because of "elastic" connection provider was used. This fix changed it to "fixed" connection provider with the limit of 500.

要更改连接池限制,可以定义自己的WebClient.Builder bean并使用它创建WebClient

To change the connection pool limit you could define your own WebClient.Builder bean and use it to create WebClient

@Bean
public WebClient.Builder webClientBuilder() {
    String connectionProviderName = "myConnectionProvider";
    int maxConnections = 100;
    int acquireTimeout = 1000;
    HttpClient httpClient = HttpClient.create(ConnectionProvider
            .fixed(connectionProviderName, maxConnections, acquireTimeout));
    return WebClient.builder()
            .clientConnector(new ReactorClientHttpConnector(httpClient));
}

或者您可以以与预定义的WebClient.Builder

Or you could implement custom org.springframework.boot.web.reactive.function.client.WebClientCustomizer in the same manner with the predefined WebClient.Builder

这篇关于WebClient maxConnection池限制?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆