when returning with a Callable response in a controlller method, I find it will use default AsyncTaskExecutor with thread name prefix "MvcAsync"。 I create a AsyncTaskExecutor, but find I can not be injected into WebAsyncTask with Callable way.
I think when creating a WebAsyncTask with Callable parameter, it should should get a bean with default executorName of type AsyncTaskExecutor.
Comment From: rstoyanchev
I'm not sure I fully understand what you are asking.
Based on the title, WebAsyncTask
does support a custom Executor
. It can be passed in as a constructor arg or configured globally.
From what I can see however the executorName
that can be passed to the constructor is not used unless a BeanFactory
is also set on WebAsyncTask
and I currently don't see that being set anywhere in framework code. Is this what you are trying to do but unable to?
Comment From: yangelaboy
yes, WebAsyncTask does support a custom Executor, but a Callable response in a controller method will be as a arg to construct a WebAsyncTask。When using Callable way, I can't pass a custom Executor into WebAsyncTask which is created by spring-framework。
The last image is the problem:when constructing WebAsyncTask with Callable instance, the method getExecutor return nul becase the executorName is not initialized。
I think that constructing WebAsyncTask with Callable instance, the method getExecutor should get an Executor Bean from beanFactory with default name and AsyncTaskExecutor class.
Comment From: rstoyanchev
We already have a mechanism to select the Executor
to use for a Callable
return value. It's configured via WebMvcConfigurer
. Please, see the docs and use that.