前提:整合教程网上一堆,admin监控网页显示这个监控服务down
控制台:
2019-10-18 16:25:55.465 WARN 18876 --- [io-8040-exec-10] o.s.w.s.m.m.a.ReactiveTypeHandler :
!!!
Streaming through a reactive type requires an Executor to write to the response.
Please, configure a TaskExecutor in the MVC config under "async support".
The SimpleAsyncTaskExecutor currently in use is not suitable under load.
-------------------------------
Controller: de.codecentric.boot.admin.server.web.ApplicationsController
Method: applicationsStream
Returning: reactor.core.publisher.Flux<org.springframework.http.codec.ServerSentEvent<de.codecentric.boot.admin.server.web.ApplicationsController$Application>>
!!!
2019-10-18 16:30:38.570 INFO 18876 --- [trap-executor-0] c.n.d.s.r.aws.ConfigClusterResolver : Resolving eureka endpoints via configuration
解决办法:Please, configure a TaskExecutor in the MVC config under "async support".
@Configuration
public class WebMvcConfig implements WebMvcConfigurer {
@Override
public void configureAsyncSupport(final AsyncSupportConfigurer configurer) {
configurer.setDefaultTimeout(60 * 1000L);
configurer.registerCallableInterceptors(timeoutInterceptor());
configurer.setTaskExecutor(threadPoolTaskExecutor());
}
@Bean
public TimeoutCallableProcessingInterceptor timeoutInterceptor() {
return new TimeoutCallableProcessingInterceptor();
}
@Bean
public ThreadPoolTaskExecutor threadPoolTaskExecutor() {
ThreadPoolTaskExecutor t = new ThreadPoolTaskExecutor();
t.setCorePoolSize(10);
t.setMaxPoolSize(100);
t.setQueueCapacity(20);
t.setThreadNamePrefix("WYF-Thread-");
return t;
}
}
本文详细解析了在使用Spring MVC框架时遇到的Reactive Type Handler警告问题,特别是在高负载下,SimpleAsyncTaskExecutor不再适用的情况。通过配置自定义TaskExecutor,如ThreadPoolTaskExecutor,可以有效解决此问题,确保服务稳定运行。
2088

被折叠的 条评论
为什么被折叠?



