Java 如何在SpringWebFlux/WebClient中设置事件循环池大小?
在多反应器框架(如Vert.X)中,我们可以设置事件循环线程的数量,例如:Java 如何在SpringWebFlux/WebClient中设置事件循环池大小?,java,spring,spring-boot,project-reactor,spring-webflux,Java,Spring,Spring Boot,Project Reactor,Spring Webflux,在多反应器框架(如Vert.X)中,我们可以设置事件循环线程的数量,例如: final VertxOptions vertxOptions = new VertxOptions(); vertxOptions.setEventLoopPoolSize(16); final Vertx myVertx = Vertx.vertx(vertxOptions); 如何在Spring Boot 2 WebFlux/WebClient中实现等效功能 您有两个选择: 使用应用事件循环资源配置的自定义程序覆
final VertxOptions vertxOptions = new VertxOptions();
vertxOptions.setEventLoopPoolSize(16);
final Vertx myVertx = Vertx.vertx(vertxOptions);
如何在Spring Boot 2 WebFlux/WebClient中实现等效功能 您有两个选择:
ReactiveWebServerFactory
bean:
@Bean
public ReactiveWebServerFactory reactiveWebServerFactory() {
NettyReactiveWebServerFactory factory = new NettyReactiveWebServerFactory();
factory.addServerCustomizers(builder -> builder.loopResources(LoopResources.create("my-http", 16, true)));
return factory;
}
-Dreactor.ipc.netty.workerCount=16
环境变量。默认情况下,它的值设置为Math.max(availableProcessors(),4)
。
示例:java-jar-your-app.jar-Dreactor.ipc.netty.workerCount=16
reactor.ipc.netty.workerCount在application.properties文件中不起作用。@SaeedZarinfam和它不应该起作用,因为它是一个环境变量,而不是属性。更新了更精确的答案。我正在获取生成器。未定义loopResources。如何验证设置是否正确应用?有没有一种简单的方法可以打印出workerCount的数量?我只是想知道方法“resourceFactory()”的名称是否重要?我可以使用不同的名称来实现相同的目标吗?