Recall & Review
beginner
What does the
@Async annotation do in Spring Boot?It marks a method to run asynchronously, meaning the method runs in a separate thread without blocking the caller.
Click to reveal answer
beginner
How do you enable
@Async support in a Spring Boot application?Add <code>@EnableAsync</code> annotation to a configuration class or the main application class.Click to reveal answer
intermediate
What type of return values can an
@Async method have?It can return
void, CompletableFuture, Future, or ListenableFuture to handle async results.Click to reveal answer
intermediate
Why should
@Async methods be called from a different bean or class?Because Spring proxies the bean to run async methods; calling <code>@Async</code> method from the same class bypasses the proxy and runs synchronously.Click to reveal answer
advanced
What happens if an exception is thrown inside an
@Async method?The exception is not propagated to the caller thread. You need to handle exceptions inside the async method or use a custom AsyncUncaughtExceptionHandler.
Click to reveal answer
Which annotation enables asynchronous method execution in Spring Boot?
✗ Incorrect
You must add @EnableAsync to enable Spring's async support.
What must you do to make a method run asynchronously using @Async?
✗ Incorrect
Only methods annotated with @Async run asynchronously.
What is a common return type for an @Async method to handle results?
✗ Incorrect
@Async methods often return CompletableFuture to handle async results.
Why might calling an @Async method from the same class not run asynchronously?
✗ Incorrect
Spring uses proxies to run async methods; same-class calls bypass proxies.
How can you handle exceptions thrown in an @Async method?
✗ Incorrect
Exceptions in async methods must be handled explicitly or via AsyncUncaughtExceptionHandler.
Explain how to set up and use @Async in a Spring Boot application.
Think about enabling async support, marking methods, and calling them properly.
You got /5 concepts.
Describe why calling an @Async method from the same class does not run it asynchronously and how to fix it.
Consider how Spring manages async calls with proxies.
You got /4 concepts.