1

I am using ThreadPoolExecutor as my custom executor with @ASync annotation.

In google, I have found that the task below needs to be configured in xml but I'm not sure how the myExecutor is mapped to my custom executor.

<task:annotation-driven executor="myExecutor" />

Even found that in bean properties, its path is not given.

How is it called then?

2 Answers 2

1

Four options:

  1. Declare a single bean of type TaskExecutor
  2. Declare a single bean with the name AsyncExecutionAspectSupport.DEFAULT_TASK_EXECUTOR_BEAN_NAME ("taskExecutor")
  3. Implement AsyncConfigurer#getAsyncExecutor
  4. For individual classes/methods, provide a qualifier of an executor bean in the @Async#value.
Sign up to request clarification or add additional context in comments.

Comments

0

I am not sure I understand your question but your configuration snippet is correct provided that you have defined an Executor bean with myExecutor as id.

The javadoc of @EnableAsync has a good coverage of how this works. For instance, to create a ThreadPoolTaskExecutor with 5 core threads and 10 max threads:

<task:annotation-driven executor="myExecutor"/>
<task:executor id="myExecutor" pool-size="5-10"/>

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.