While using the embedded tomcat for deploying my spring boot app, I set the async timeout as follows:
@Bean
public EmbeddedServletContainerFactory servletContainer() {
TomcatEmbeddedServletContainerFactory factory = new TomcatEmbeddedServletContainerFactory();
factory.addConnectorCustomizers(new TomcatConnectorCustomizer() {
@Override
public void customize(Connector connector) {
connector.setAsyncTimeout(60000);
}
});
return factory;
}
But,how to achieve the same when deploying to an external server, for example, websphere?
Tried using the property:
spring.mvc.async.request-timeout=600000
But this did not have any effect.
Edit:
I had tried implementing AsyncConfigurer as per Andrei's suggestion. But it did not work as expected. Below is my configuration class:
@SpringBootApplication
@EnableAsync
public class Application implements AsyncConfigurer {
public static void main(String[] args) {
SpringApplication.run(Application.class, args);
}
@Override
public Executor getAsyncExecutor() {
Executor executor = new ThreadPoolExecutor(10, 20, 60, TimeUnit.SECONDS, new ArrayBlockingQueue<>(10),
new ThreadPoolExecutor.AbortPolicy());
return executor;
}
@Override
public AsyncUncaughtExceptionHandler getAsyncUncaughtExceptionHandler() {
// TODO Auto-generated method stub
return new SimpleAsyncUncaughtExceptionHandler();
}
}
I have given timeout as 60 seconds, but when trying this configuration, the request was timing out after 30 seconds. Was using RestClient.
Is there something I am missing?