Bird
0
0

Consider a Spring Boot app with multiple async executors defined. How can you specify which executor an @Async method should use?

hard📝 Application Q9 of 15
Spring Boot - Async Processing
Consider a Spring Boot app with multiple async executors defined. How can you specify which executor an @Async method should use?
ASet the executor name in application.properties.
BUse @Async("executorBeanName") with the bean name of the desired executor.
CUse @EnableAsync with an executorName parameter.
DName the method with the executor name prefix.
Step-by-Step Solution
Solution:
  1. Step 1: Understand executor selection

    @Async accepts a value specifying the executor bean name to use for that method.
  2. Step 2: Check other options

    application.properties and @EnableAsync do not specify executor per method; method naming has no effect.
  3. Final Answer:

    Use @Async("executorBeanName") with the bean name of the desired executor. -> Option B
  4. Quick Check:

    Specify executor by bean name in @Async [OK]
Quick Trick: Pass executor bean name as @Async value to select executor [OK]
Common Mistakes:
  • Trying to set executor in properties
  • Expecting @EnableAsync to select executor
  • Using method names to select executor

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Spring Boot Quizzes