Challenge - 5 Problems
Async Mastery in Spring Boot
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ component_behavior
intermediate2:00remaining
What happens when @EnableAsync is added to a Spring Boot configuration?
Consider a Spring Boot application where the @EnableAsync annotation is added to a configuration class. What is the effect of this annotation on the application's behavior?
Attempts:
2 left
💡 Hint
Think about what @Async methods need to work properly in Spring.
✗ Incorrect
The @EnableAsync annotation tells Spring to look for methods annotated with @Async and run them in a separate thread, enabling asynchronous execution.
📝 Syntax
intermediate2:00remaining
Identify the correct way to enable async processing in Spring Boot
Which of the following code snippets correctly enables asynchronous method execution in a Spring Boot application?
Spring Boot
public class AppConfig {
// ...
}Attempts:
2 left
💡 Hint
Remember that @EnableAsync is a meta-annotation and usually combined with @Configuration.
✗ Incorrect
The correct way is to annotate a @Configuration class with @EnableAsync without parameters. Option D shows this correctly.
🔧 Debug
advanced2:00remaining
Why does @Async not work despite @EnableAsync being present?
A developer added @EnableAsync to their Spring Boot configuration but notices that methods annotated with @Async still run synchronously. What is the most likely cause?
Attempts:
2 left
💡 Hint
Think about how Spring proxies work with self-invocation.
✗ Incorrect
Spring uses proxies to intercept calls to @Async methods. Calling an @Async method from the same class bypasses the proxy, so it runs synchronously.
❓ state_output
advanced2:00remaining
What thread name prefix is used by default for @Async methods?
When a method annotated with @Async runs, what is the default prefix of the thread name executing it?
Attempts:
2 left
💡 Hint
Look at the default executor Spring uses if none is configured.
✗ Incorrect
By default, Spring uses SimpleAsyncTaskExecutor which names threads with the prefix 'SimpleAsyncTaskExecutor-'.
🧠 Conceptual
expert3:00remaining
How does @EnableAsync affect Spring's proxy creation and bean lifecycle?
Which statement best describes the impact of @EnableAsync on Spring's proxy creation and bean lifecycle?
Attempts:
2 left
💡 Hint
Consider how Spring intercepts method calls to add behavior.
✗ Incorrect
@EnableAsync causes Spring to create proxies around beans that have @Async methods. These proxies intercept calls and run them asynchronously.