0
0
Spring Bootframework~10 mins

@Async for async methods in Spring Boot - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to enable asynchronous execution of the method.

Spring Boot
@[1]
public void sendEmail() {
    // email sending logic
}
Drag options to blanks, or click blank then click option'
ATransactional
BAsync
CService
DComponent
Attempts:
3 left
💡 Hint
Common Mistakes
Using @Transactional instead of @Async
Forgetting to enable async support in configuration
2fill in blank
medium

Complete the code to enable async support in the Spring Boot application.

Spring Boot
@Configuration
@Enable[1]
public class AsyncConfig {
}
Drag options to blanks, or click blank then click option'
AScheduling
BTransactionManagement
CCaching
DAsync
Attempts:
3 left
💡 Hint
Common Mistakes
Using @EnableScheduling instead of @EnableAsync
Not adding this annotation causes @Async to be ignored
3fill in blank
hard

Fix the error in the async method declaration to return a Future result.

Spring Boot
@Async
public [1]<String> processData() {
    // processing logic
    return new AsyncResult<>("done");
}
Drag options to blanks, or click blank then click option'
AFuture
BCompletableFuture
CListenableFuture
DCallable
Attempts:
3 left
💡 Hint
Common Mistakes
Returning void when a Future is expected
Using incompatible return types like Callable
4fill in blank
hard

Fill both blanks to correctly configure a custom executor for async methods.

Spring Boot
@Bean
public Executor [1]() {
    ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
    executor.setCorePoolSize(5);
    executor.setMaxPoolSize(10);
    executor.setQueueCapacity(25);
    executor.initialize();
    return [2];
}
Drag options to blanks, or click blank then click option'
AtaskExecutor
Bexecutor
CasyncExecutor
DthreadPool
Attempts:
3 left
💡 Hint
Common Mistakes
Returning a different variable name than created
Using inconsistent method names
5fill in blank
hard

Fill all three blanks to correctly annotate and configure async method with custom executor.

Spring Boot
@Async([1])
public void runTask() {
    // task logic
}

@Bean
public Executor [2]() {
    ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
    executor.setCorePoolSize(3);
    executor.setMaxPoolSize(6);
    executor.setQueueCapacity(10);
    executor.initialize();
    return [3];
}
Drag options to blanks, or click blank then click option'
A"taskExecutor"
BtaskExecutor
Cexecutor
DcustomExecutor
Attempts:
3 left
💡 Hint
Common Mistakes
Using variable names instead of string in @Async
Mismatching bean method name and returned variable