如果远程服务阻塞,我可以发送多少个并发请求?
意思是:什么是最大连接数spring在使用时内部使用的池限制WebClient
?
@Autowired
private WebClient webClient;
webClient.post().uri(url).syncBody(req).retrieve().bodyToMono(type);
此外:我该如何修改它?
在reactor-netty 0.9.0.M4版本之前,默认情况下没有限制,因为使用了“弹性”连接提供程序。This fix https://github.com/reactor/reactor-netty/issues/578将其更改为“固定”连接提供商,限制为 500。
要更改连接池限制,您可以定义自己的连接池限制WebClient.Builder
bean 并用它来创建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));
}
或者你可以实现自定义org.springframework.boot.web.reactive.function.client.WebClientCustomizer
以与预定义相同的方式WebClient.Builder
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)