1

Is there anyway to be able to specify different Executors for different classes? Seems a bit constricting to have to use one Executor for every async task.

1
  • You can have the pooled executor with enough threads. Commented Jan 5, 2012 at 23:56

2 Answers 2

3

As of Spring 3.2/3.1.2 you can now qualify your @Async use, much like the use of @Transactional, in the following manner:

@Async("beanNameOrQualifierValue")
public void someOp() {
   ...
}

You can look in the following issues SPR-6847 (3.2) / SPR-9443 (3.1.2) for more details.

Sign up to request clarification or add additional context in comments.

Comments

1

You can have several instances of the same task executor type (Pool). But you can not have different Pools.

For example

  <task:executor id="executor" pool-size="10"/>

10 instances of ThreadPoolTaskExecutor

or

   <task:executor id="executorWithPoolSizeRange"
               pool-size="5-25"
               queue-capacity="100"/>

For more details see the spring Reference @see Spring Reference Chapter 25 Task Execution and Scheduling

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.